✖

Cramer’s rule

Cramer’s rule is used to solve a system of linear equations whose coefficient matrix is non-singular.

Cramer systems

Take a system of linear equations Ax = b. We call this system a Cramer system if A is a square non-singular matrix. This means that the determinant of the matrix is always non-zero, so the matrix has no linearly dependent rows or columns.

By the Rouché–Capelli theorem, every Cramer system has exactly one solution. The Rouché–Capelli theorem says that if rank(A) = rank(A|b) = k, then the system has a solution. The matrix A of a Cramer system is square and has the greatest possible rank. This means that if we attach any further column to this matrix, that column must be a linear combination of the columns of A. So attaching the column b does not increase the rank of A.

The Rouché–Capelli theorem also says that we need n − k parameters to express the solution, where n is the number of variables and k is the rank rank(A|b). For a Cramer system, n = k, so we need zero parameters to express the solution. That is why every Cramer system has exactly one solution.

Next, let Ai be the matrix A modified so that column i is replaced by the column b. Formally, we define the matrix Ai like this:

Ai=(a1,1…a1,i−1b1a1,i+1…a1,na2,1…a2,i−1b2a2,i+1…a2,n⋮⋮⋮⋮⋮⋮⋮an,1…an,i−1bnan,i+1…an,n)

where aij are the elements of A and bi are the elements of b.

Cramer’s rule

Let Ax = b be a Cramer system of linear equations. Cramer’s rule says that this system has exactly one solution (x1, x2, …, xn), where

xi=det Aidet A=|Ai||A|.

Let’s see the rule in action on a small example. We solve the following system using Cramer’s rule.

x1+2x2=54x1+3x2=15

The coefficient matrix is:

A=(1243)

The determinant of the matrix is:

|A|=3−8=−5.

Next we form the matrices A1 and A2. They are:

A1=(52153),A2=(15415)

We work out the determinants of these matrices:

|A1|=5⋅3−15⋅2=−15|A2|=1⋅15−4⋅5=−5

Now we work out x1 and x2 in turn. By Cramer’s rule, for x1 we have

x1=|A1||A|

Substituting, we get

x1=−15−5=3

The same for the second element x2:

x2=|A2||A|=−5−5=1

The solution of the system is therefore the pair (x1, x2) = (3, 1).

Cramer’s rule is most useful when you want to turn the method into an algorithm, because it is easy to program. Solving a system by hand with Cramer’s rule is usually more work than solving it by Gaussian elimination.

Chapters: Systems of linear equations, Cramer’s rule, Homogeneous systems of linear equations