Cramer's Rule

Cramer’s Rule

The Definition of Cramer’s Rule

Cramer's Rule

Let the n-variable linear system be:

{a11x1+a12x2+⋯+a1nxn=b1a21x1+a22x2+⋯+a2nxn=b2⋮an1x1+an2x2+⋯+annxn=bn\begin{cases} a_{11}x_1 + a_{12}x_2 + \dots + a_{1n}x_n = b_1 \\ a_{21}x_1 + a_{22}x_2 + \dots + a_{2n}x_n = b_2 \\ \vdots \\ a_{n1}x_1 + a_{n2}x_2 + \dots + a_{nn}x_n = b_n \end{cases}

If the determinant det⁡(A)\det(A) of the coefficient matrix A=(aij)A = (a_{ij}) satisfies det⁡(A)≠0\det(A) \neq 0, then the system has a unique solution: xj=det⁡(Aj)det⁡(A)(j=1,2,…,n)x_j = \frac{\det(A_j)}{\det(A)} \qquad (j=1,2,\dots,n)

where AjA_j is the matrix obtained from the coefficient matrix AA by replacing its jj-th column with the constant terms b⃗\vec{b}.

The Conditions of Cramer’s Rule

Conditions:

  1. The system must have n equations in n unknowns (a square matrix)
  2. The determinant ∣A∣|A| of the coefficient matrix must satisfy ∣A∣≠0|A| \neq 0

Note: when ∣A∣=0|A| = 0, Cramer’s rule does not apply and another method has to be used to solve the system.

The Proof of Cramer’s Rule

Proof idea:

  1. Suppose Ax⃗=b⃗A\vec{x} = \vec{b} has the unique solution x⃗=A−1b⃗\vec{x} = A^{-1}\vec{b}
  2. Use the property of the adjugate matrix: A−1=1∣A∣A∗A^{-1} = \frac{1}{|A|}A^*
  3. This gives xi=1∣A∣∑j=1nAjibjx_i = \frac{1}{|A|}\sum_{j=1}^n A_{ji}b_j
  4. Here AjiA_{ji} is the algebraic cofactor of AA
  5. One can prove that ∑j=1nAjibj=∣Ai∣\sum_{j=1}^n A_{ji}b_j = |A_i|

Applications of Cramer’s Rule

The Solving Steps

  1. Check the conditions: confirm that the system is n×n and that ∣A∣≠0|A| \neq 0
  2. Compute ∣A∣|A|: compute the determinant of the coefficient matrix
  3. Compute ∣Ai∣|A_i|: replace the i-th column with the vector of constant terms and compute the determinant
  4. Solve: xi=∣Ai∣∣A∣x_i = \frac{|A_i|}{|A|}

Example

Example 1: solve the system by Cramer’s rule: {x+2y=53x−y=4\begin{cases} x + 2y = 5 \\ 3x - y = 4 \end{cases}

Solution:

  1. The coefficient matrix: A=(123−1)A = \begin{pmatrix} 1 & 2 \\ 3 & -1 \end{pmatrix}
  2. ∣A∣=1×(−1)−2×3=−1−6=−7≠0|A| = 1 \times (-1) - 2 \times 3 = -1 - 6 = -7 \neq 0
  3. ∣A1∣=∣524−1∣=5×(−1)−2×4=−5−8=−13|A_1| = \begin{vmatrix} 5 & 2 \\ 4 & -1 \end{vmatrix} = 5 \times (-1) - 2 \times 4 = -5 - 8 = -13
  4. ∣A2∣=∣1534∣=1×4−5×3=4−15=−11|A_2| = \begin{vmatrix} 1 & 5 \\ 3 & 4 \end{vmatrix} = 1 \times 4 - 5 \times 3 = 4 - 15 = -11
  5. x=−13−7=137x = \frac{-13}{-7} = \frac{13}{7}, y=−11−7=117y = \frac{-11}{-7} = \frac{11}{7}

The Advantages and Disadvantages of Cramer’s Rule

Advantages

  1. Theoretical significance: it gives an explicit expression for the solution
  2. Simple computation: for small systems the computation is relatively simple
  3. Exact solutions: it yields exact fractional solutions

Disadvantages

  1. Heavy computation: for large systems, several determinants have to be computed
  2. Restricted applicability: it works only for square matrices with a nonzero determinant
  3. Numerical stability: when the determinant is close to zero, the computational error is large

Extensions of Cramer’s Rule

Homogeneous Systems

The Necessary and Sufficient Condition for a Homogeneous System to Have a Nonzero Solution

The homogeneous linear system Ax⃗=0⃗A\vec{x} = \vec{0} has a nonzero solution if and only if ∣A∣=0|A| = 0.

Proof

Proof:

  • If ∣A∣≠0|A| \neq 0, then the only solution is the zero solution
  • If ∣A∣=0|A| = 0, then there are infinitely many solutions, including nonzero ones

The Non-Square Case

For a system of size m×n (m ≠ n), Cramer’s rule does not apply and another method has to be used to solve it.

Exercises

Exercise 1

Solve the system {2x+y=7x−3y=−4\begin{cases} 2x + y = 7 \\ x - 3y = -4 \end{cases} by Cramer’s rule.

Cramer's rulesystem of linear equationsdeterminantcoefficient matrix

Approach: Follow the steps of Cramer’s rule.

Steps:

  1. The coefficient matrix: A=(211−3)A = \begin{pmatrix} 2 & 1 \\ 1 & -3 \end{pmatrix}
  2. ∣A∣=2×(−3)−1×1=−6−1=−7≠0|A| = 2 \times (-3) - 1 \times 1 = -6 - 1 = -7 \neq 0
  3. ∣A1∣=∣71−4−3∣=7×(−3)−1×(−4)=−21+4=−17|A_1| = \begin{vmatrix} 7 & 1 \\ -4 & -3 \end{vmatrix} = 7 \times (-3) - 1 \times (-4) = -21 + 4 = -17
  4. ∣A2∣=∣271−4∣=2×(−4)−7×1=−8−7=−15|A_2| = \begin{vmatrix} 2 & 7 \\ 1 & -4 \end{vmatrix} = 2 \times (-4) - 7 \times 1 = -8 - 7 = -15
  5. x=−17−7=177x = \frac{-17}{-7} = \frac{17}{7}, y=−15−7=157y = \frac{-15}{-7} = \frac{15}{7}

Answer: x=177x = \frac{17}{7}, y=157y = \frac{15}{7}

Exercise 2

Decide whether the system {x+y=12x+2y=2\begin{cases} x + y = 1 \\ 2x + 2y = 2 \end{cases} can be solved by Cramer’s rule.

Cramer's rulesystem of linear equationsdeterminantcoefficient matrix

Approach: Check the determinant of the coefficient matrix.

Steps:

  1. The coefficient matrix: A=(1122)A = \begin{pmatrix} 1 & 1 \\ 2 & 2 \end{pmatrix}
  2. ∣A∣=1×2−1×2=2−2=0|A| = 1 \times 2 - 1 \times 2 = 2 - 2 = 0
  3. The determinant is zero, so Cramer’s rule does not apply

Answer: it cannot be solved by Cramer’s rule

Exercise 3

Solve the system {x+y+z=62x+3y+z=13x−y+2z=4\begin{cases} x + y + z = 6 \\ 2x + 3y + z = 13 \\ x - y + 2z = 4 \end{cases} by Cramer’s rule.

Cramer's rulesystem of linear equationsdeterminantcoefficient matrix

Approach: Follow the steps of Cramer’s rule for the three-variable system.

Steps:

  1. The coefficient matrix: A=(1112311−12)A = \begin{pmatrix} 1 & 1 & 1 \\ 2 & 3 & 1 \\ 1 & -1 & 2 \end{pmatrix}
  2. ∣A∣=1×(3×2−1×(−1))−1×(2×2−1×1)+1×(2×(−1)−3×1)=1×7−1×3+1×(−5)=7−3−5=−1≠0|A| = 1 \times (3 \times 2 - 1 \times (-1)) - 1 \times (2 \times 2 - 1 \times 1) + 1 \times (2 \times (-1) - 3 \times 1) = 1 \times 7 - 1 \times 3 + 1 \times (-5) = 7 - 3 - 5 = -1 \neq 0
  3. ∣A1∣=∣61113314−12∣=6×(3×2−1×(−1))−1×(13×2−1×4)+1×(13×(−1)−3×4)=6×7−1×22+1×(−25)=42−22−25=−5|A_1| = \begin{vmatrix} 6 & 1 & 1 \\ 13 & 3 & 1 \\ 4 & -1 & 2 \end{vmatrix} = 6 \times (3 \times 2 - 1 \times (-1)) - 1 \times (13 \times 2 - 1 \times 4) + 1 \times (13 \times (-1) - 3 \times 4) = 6 \times 7 - 1 \times 22 + 1 \times (-25) = 42 - 22 - 25 = -5
  4. ∣A2∣=∣1612131142∣=1×(13×2−1×4)−6×(2×2−1×1)+1×(2×4−13×1)=1×22−6×3+1×(−5)=22−18−5=−1|A_2| = \begin{vmatrix} 1 & 6 & 1 \\ 2 & 13 & 1 \\ 1 & 4 & 2 \end{vmatrix} = 1 \times (13 \times 2 - 1 \times 4) - 6 \times (2 \times 2 - 1 \times 1) + 1 \times (2 \times 4 - 13 \times 1) = 1 \times 22 - 6 \times 3 + 1 \times (-5) = 22 - 18 - 5 = -1
  5. ∣A3∣=∣11623131−14∣=1×(3×4−13×(−1))−1×(2×4−13×1)+6×(2×(−1)−3×1)=1×25−1×(−5)+6×(−5)=25+5−30=0|A_3| = \begin{vmatrix} 1 & 1 & 6 \\ 2 & 3 & 13 \\ 1 & -1 & 4 \end{vmatrix} = 1 \times (3 \times 4 - 13 \times (-1)) - 1 \times (2 \times 4 - 13 \times 1) + 6 \times (2 \times (-1) - 3 \times 1) = 1 \times 25 - 1 \times (-5) + 6 \times (-5) = 25 + 5 - 30 = 0
  6. x=−5−1=5x = \frac{-5}{-1} = 5, y=−1−1=1y = \frac{-1}{-1} = 1, z=0−1=0z = \frac{0}{-1} = 0

Answer: x=5x = 5, y=1y = 1, z=0z = 0

Exercise 4

Prove that: if the homogeneous linear system Ax⃗=0⃗A\vec{x} = \vec{0} has a nonzero solution, then ∣A∣=0|A| = 0.

Cramer's rulesystem of linear equationsdeterminantcriterion for solutions

Approach: Use Cramer’s rule together with a proof by contradiction.

Steps:

  1. Assume ∣A∣≠0|A| \neq 0
  2. By Cramer’s rule, the system has a unique solution
  3. Since the system is homogeneous, the unique solution is the zero solution
  4. This contradicts the assumption that a nonzero solution exists
  5. Therefore ∣A∣=0|A| = 0

Answer: the proof is complete

Exercise 5

Decide which case the system {x+2y=52x+4y=10\begin{cases} x + 2y = 5 \\ 2x + 4y = 10 \end{cases} falls into.

Cramer's rulesystem of linear equationsdeterminantcoefficient matrix

Approach: First check the determinant, then analyse which case you are in.

Steps:

  1. The coefficient matrix: A=(1224)A = \begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix}
  2. ∣A∣=1×4−2×2=4−4=0|A| = 1 \times 4 - 2 \times 2 = 4 - 4 = 0
  3. Cramer’s rule does not apply
  4. Look at the two equations: the second equation is twice the first
  5. The two equations are equivalent, so there are infinitely many solutions

Answer: there are infinitely many solutions

Summary

Symbols Used in This Article

SymbolTypePronunciation / NoteMeaning in This Article
det⁡(A)\det(A)Mathematical symboldeterminant of AThe determinant of the coefficient matrix AA; Cramer’s rule requires det⁡(A)≠0\det(A) \neq 0
xj=det⁡(Aj)det⁡(A)x_j = \dfrac{\det(A_j)}{\det(A)}Mathematical symbolx sub j equals A j over ACramer’s rule: the jj-th unknown equals the ratio of two determinants
AjA_jMathematical symbolA sub jThe matrix obtained from AA by replacing its jj-th column with the constant terms b⃗\vec{b}
A∗A^*Mathematical symbolA starThe adjugate matrix, used in A−1=1det⁡(A)A∗A^{-1} = \dfrac{1}{\det(A)}A^*
AjiA_{ji}Mathematical symbolA sub j iThe algebraic cofactor in the determinant
Ax⃗=0⃗A\vec{x} = \vec{0}Mathematical symbolA x equals zeroThe homogeneous system, which has a nonzero solution if and only if det⁡(A)=0\det(A) = 0

Found an issue with this content?

Tell us what could be improved.