82. Cramer's Rule

For a square system 𝐴𝑥=𝑏 where 𝐴 is 𝑛×𝑛 and invertible (i.e., det(𝐴)0), each component of the solution is a ratio of determinants:

𝑥𝑖=det(𝐴𝑖)det(𝐴)

where 𝐴𝑖 is the matrix 𝐴 with its 𝑖-th column replaced by 𝑏.

Example

Solve

2𝑥+𝑦=5𝑥+3𝑦=10

Then 𝐴=[2113], 𝑏=[510], and det(𝐴)=61=5.

Replace column 1:

𝐴1=[51103]det(𝐴1)=1510=5

Replace column 2:

𝐴2=[25110]det(𝐴2)=205=15𝑥=55=1,𝑦=155=3

82.1. Why it works (sketch)

Let 𝐸𝑖 be the identity with the 𝑖-th column replaced by 𝑥. Then 𝐴𝐸𝑖=𝐴𝑖 (column-by-column), so

det(𝐴𝑖)=det(𝐴𝐸𝑖)=det(𝐴)det(𝐸𝑖)=det(𝐴)𝑥𝑖

(since 𝐸𝑖 is upper triangular with 𝑥𝑖 on its 𝑖-th diagonal entry).

82.2. Practical remarks

Cramer’s rule is theoretically beautiful but computationally awful for 𝑛>3:

Use Cramer’s rule for:

Don’t use it for serious numerical work.

82.3. When it fails

If det(𝐴)=0, the formula divides by zero — meaning 𝐴 is singular and the system either has no solution or infinitely many (depending on 𝑏). See Linear System Solutions.

82.4. See also