Cramer's Rule for Linear Systems

Part 18, Chapter 18: Matrices and Determinants

Learning objectives

  • State Cramer's rule for 2x2 and 3x3 systems
  • Solve a 2x2 system using Cramer's rule
  • Determine when Cramer's rule applies

You can stare at Amathbfx=mathbfbA \mathbf{x} = \mathbf{b} for a long time and not see how to solve it. The determinant gives you an explicit closed-form answer, one short formula per unknown, expressed entirely in determinants of AA and modified versions of AA. That formula is Cramer's rule, and the closing section of this chapter shows you why it works and where it fails.

The 2x2 statement

Consider the system

begincasesax+by=ecx+dy=fendcases\begin{cases} ax + by = e \\ cx + dy = f \end{cases}

Let D = \det\begin{pmatrix} a & b \\ c & d \end{pmatrix}. If Dneq0D \neq 0, then

x = \frac{D_x}{D} = \frac{\det\begin{pmatrix} e & b \\ f & d \end{pmatrix}}{D}, \qquad y = \frac{D_y}{D} = \frac{\det\begin{pmatrix} a & e \\ c & f \end{pmatrix}}{D}.

The recipe in words: to find xx, replace the first column of AA with the right-hand-side vector (e,f)(e, f) and take the determinant. To find yy, replace the second column instead. Divide each by DD.

Where this shows up
  • Circuit Analysis: Solving Kirchhoff's mesh equations for currents in a 3-loop circuit is a textbook Cramer's-rule application; the determinant in the denominator vanishes only when the circuit has redundant components.
  • Statics: Finding the three unknown reaction forces on a beam supported at three points is a 3x3 linear system; Cramer's rule gives a closed-form for each reaction in terms of the load distribution.
  • Cryptography: Hill ciphers encrypt by multiplying plaintext blocks by a key matrix; decryption requires solving the inverse system, Cramer's rule (mod 26) is one way classical cipher textbooks present this.

(Left canvas shows A = [\mathbf{u} \mid \mathbf{v}], with det(A)=D\det(A) = D. Right canvas shows A_x = [\mathbf{b} \mid \mathbf{v}], where mathbfb\mathbf{b} has replaced the first column. The readout below shows DD, DxD_xx, and x=Dx/Dx = D_x / Dx/D. Drag mathbfb\mathbf{b} to change the right-hand side and watch xx update. Toggle the radio button to compute yy instead.)

The 3x3 (and general) statement

For an ntimesnn \times n system Amathbfx=mathbfbA \mathbf{x} = \mathbf{b} with det(A)neq0\det(A) \neq 0,

xi=fracdet(Ai)det(A)x_i = \frac{\det(A_i)}{\det(A)}i)det(A)

where AiA_ii is the matrix you get by replacing the ii-th column of AA with mathbfb\mathbf{b}. The pattern is identical to the 2times22 \times 2 case, just more columns to track.

Why it works

The proof is a one-line application of column properties. Amathbfx=mathbfbA \mathbf{x} = \mathbf{b} says the linear combination x1mathbfa1+x2mathbfa2+cdots+xnmathbfan=mathbfbx_1 \mathbf{a}_1 + x_2 \mathbf{a}_2 + \cdots + x_n \mathbf{a}_n = \mathbf{b}nmathbfan=mathbfb. So mathbfb\mathbf{b} is built from the columns of AA with coefficients xix_ii. Substitute mathbfb\mathbf{b} for column ii in AA and use the multilinear property of det\det in that column: only the ximathbfaix_i \mathbf{a}_ii term survives, giving det(Ai)=xidet(A)\det(A_i) = x_i \det(A)idet(A). Divide by det(A)\det(A).

When Cramer's rule fails

The rule requires det(A)neq0\det(A) \neq 0. If det(A)=0\det(A) = 0, the formula has 00 in the denominator, meaningless. Geometrically, a zero determinant means the columns of AA are linearly dependent, the matrix is singular, and the system either has no solution at all (inconsistent) or has infinitely many (dependent). Either way, there is no unique answer for Cramer's rule to deliver.

When to use it, when not to

Cramer's rule is conceptually elegant and theoretically powerful: it expresses the solution as an explicit ratio of determinants, which is useful for proofs and for studying how the solution depends on the right-hand side. It also works well for tiny systems (nleq3)(n \leq 3) that you compute by hand.

For larger systems, however, it is computationally terrible. An ntimesnn \times n determinant via cofactor expansion costs roughly n!n! operations; Cramer's rule needs n+1n+1 of them. So a 10times1010 \times 10 system via Cramer's rule needs about 11cdot10!approx40,000,00011 \cdot 10! \approx 40\,000\,000 operations, while Gaussian elimination handles it in around 10001000. Use Cramer's rule for understanding; use elimination for computation.

Try it

  • Predict first: solve 3x+y=5,x+2y=43x + y = 5, x + 2y = 4 by hand, what are xx and yy? Set mathbfu=(3,1),mathbfv=(1,2),mathbfb=(5,4)\mathbf{u} = (3, 1), \mathbf{v} = (1, 2), \mathbf{b} = (5, 4) in the widget and verify, then substitute back into the original system to double-check.
  • Solve on paper: 2x+3y=82x + 3y = 8, xy=1x - y = 1. Find DD, DxD_xx, DyD_yy, then xx and yy.
  • Try to apply Cramer's rule to x+2y=3x + 2y = 3, 2x+4y=62x + 4y = 6. Compute DD. What goes wrong? What does it tell you about the system?
  • For the 3times33 \times 3 system x+y+z=6,2y+z=4,3z=9x + y + z = 6, \ 2y + z = 4, \ 3z = 9 (already triangular), use Cramer's rule to find xx. Confirm against back-substitution.
  • Pause: Cramer's rule requires Dneq0D \neq 0. But D=0D = 0 can mean two different things, no solution or infinitely many. How would you tell which?

    A trap to watch for

    The most common error: replacing the wrong column. To find x3x_3, you replace column 3. Students sometimes replace column 1, the column that contains x3x_3-related entries in their head, but Cramer's rule is about the position of the unknown, not the position of the coefficient. **Always: xix_ii means replace column ii.**

    A second trap: applying Cramer's rule when D=0D = 0. The formula gives tfrac00\tfrac{0}{0} or tfractextnonzero0\tfrac{\text{nonzero}}{0}, both meaningless. Beginners sometimes write "x=tfrac00=0x = \tfrac{0}{0} = 0" and march on. The correct response when D=0D = 0 is to stop and use elimination or substitution to determine whether the system has no solution or infinitely many. Cramer's rule is silent on those cases.

    What you now know

    You can apply Cramer's rule to any 2times22 \times 2 or 3times33 \times 3 linear system with a non-zero coefficient determinant, recognise when the rule fails and what that failure means geometrically, and choose between Cramer's rule and elimination depending on the size of the system. This is the closing section of the textbook. You now have the working machinery, numbers, operations, linearity, geometry, induction, summation, matrices, determinants, that supports every elementary mathematics course you will take next.

    Quick check

    Mark section complete →

    References

    • Lang, S. (1971). Basic Mathematics. Springer. Chapter 17, §6, Cramer's rule with both 2times22 \times 2 and 3times33 \times 3 derivations.
    • Strang, G. (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge Press. Chapter 5: Cramer's rule alongside the cost comparison with elimination.
    • Hoffman, K.; Kunze, R. (1971). Linear Algebra (2nd ed.). Prentice-Hall. §5.6, the column-replacement proof via multilinear algebra.
    • Axler, S. (2015). Linear Algebra Done Right (3rd ed.). Springer. Chapter 10: the determinant of the inverse and Cramer's rule in operator language.

    This page is prerendered for SEO and accessibility. The interactive widgets above hydrate on JavaScript load.