Cramer's rule is a clever solution to the classical system of linear equations :
Using determinants (and assuming ).
We start by constructing a special matrix: the identity matrix whose first column is replaced by the column vector x, and then multiplying A by it [1]:
If we call our special matrix and the result , then:
One of the fundamental properties of determinants is the product property:
But what is ? It's easy to check that it's just . Therefore:
Or:
We can proceed similarly with :
And from this:
So we get Cramer's rule:
For the n-by-n system of equations , the solutions can be determined with:
Where is the matrix formed by replacing the i-th column of A by the column vector b.
While the construction detailed above should provide good motivation for why Cramer's rule works, it's not a rigorous proof; Wikipedia has a nice one.
Uses for matrix inversion
Given a matrix A, we'd like to find such that:
We can do this by repeated application of Cramer's rule, using the columns of as unknowns. Let's represent our matrices symbolically as:
Multiplying A by the first column of , we get the first column of the identity matrix [2]:
We can use Cramer's rule to find the values of x and v from this. First, we need matrices and :
Then, compute the determinants:
And applying Cramer's rule:
Similarly, multiplying A by the second column of , we have:
And after applying Cramer's rule for this, we'll find that:
Overall, we get the nice formula:
Which you may be familiar with; it works whenever (meaning that the matrix A is actually invertible).
Inverting larger matrices
We've seen how to derive the well-known symbolic form of for 2-by-2 matrices. The same method works for any size. Let's take 3-by-3:
To obtain the first column of , we multiply by it to get the first column of I:
To solve this using Cramer's rule, we'll need three B matrices:
And calculate their determinants. Because of the column borrowed from I, the determinants of these B matrices are the cofactors of A, meaning they are determinants of 2-by-2 matrices. To get all elements of , we'll need to find a total of nine determinants of 2-by-2 matrices. This extends to larger matrices as well: for an n-by-n matrix, we'll need to calculate n determinants of (n-1)-by-(n-1) matrices. Overall the time it takes to invert a matrix using this approach is O(n!), which is clearly infeasible for any reasonable size.
Thankfully, more efficient methods of inverting matrices exist - like the
simple Gauss-Jordan elimination ().
Therefore, Cramer's rule is rarely used to invert matrices (or solve systems of equations) in practice. It's mostly useful for very small sizes, and also good for generating symbolic formulas for the simplest cases like the 2-by-2 inverse matrix formula shown above.
[1] | This is just straightforward matrix multiplication, and using the fact that etc. |
[2] | Feel free to check this on paper by performing the full multiplication between A and in their symbolic form and noticing that you only need the first column of to obtain the first column of the result. |