Cramer's Rule & Invertible Matrices
3614 words
18 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Cramer's Rule & Invertible Matrices ## 🎯 Learning Objectives After this topic you will be able to: - State and apply Cramer's rule to solve $A\mathbf{x} = \mathbf{b}$ when $A$ is square and invertible - Compute the adjugate (classical adjoint) of a matrix - Find the inverse of a matrix using the adjugate formula...

Cramer's Rule & Invertible Matrices
🎯 Learning Objectives
After this topic you will be able to:
- State and apply Cramer's rule to solve Ax=b when A is square and invertible
- Compute the adjugate (classical adjoint) of a matrix
- Find the inverse of a matrix using the adjugate formula A−1=det(A)adj(A)
- Determine when Cramer's rule is (and isn't) computationally practical
- Express solutions to linear systems using determinants
📋 Prerequisites
- Determinants (Week 1) — computing det, minors, cofactors
- Gaussian Elimination (this week) — the standard method for solving systems
- Matrix Multiplication (Week 1) — A−1 is defined by AA−1=I
- Cramer's rule provides an elegant theoretical formula, though Gaussian elimination is usually more practical
1. Intuition: What Cramer's Rule Does
Cramer's rule expresses the solution of Ax=b directly in terms of determinants. For each variable xj:
- Take the coefficient matrix A
- Replace column j of A with b
- Compute the determinant of this new matrix
- Divide by det(A) The result is xj. It's a beautiful formula, but computationally expensive for large n (requires n+1 determinants).
2. Cramer's Rule
2.1 Statement
>xj=det(A)det(Aj),j=1,2,…,n>Theorem (Cramer's Rule). Let A be an n×n invertible matrix (so det(A)=0). For any b∈Rn, the unique solution to Ax=b is:
>x1a1+x2a2+⋯+xnan=b>where Aj is the matrix formed by replacing the j-th column of A with b. Proof SketchLet A=[a1a2…an] where aj is column j. Then Ax=b means:
>det(Aj)=det[a1…k=1∑nxkak…an]=xjdet(A)>Consider Aj=[a1…b…an] (column j replaced by b). Using multilinearity of the determinant:
because all terms with k=j have two identical columns (determinant zero). Hence xj=det(Aj)/det(A).
2.2 2×2 Case
For
,
:
>{2x+3y=74x−y=1>Example 1: 2×2 Cramer's ruleSolve:
>A1=[713−1]>det(A)=2(−1)−3(4)=−2−12=−14
>A2=[2471]>, det(A1)=7(−1)−3(1)=−7−3=−10
, det(A2)=2(1)−7(4)=2−28=−26x=−14−10=75, y=−14−26=713Check: 2(75)+3(713)=710+39=7 ✓
2.3 3×3 Case
>⎩⎨⎧x+2y+z=32x−y+3z=23x+y−z=6>Example 2: 3×3 Cramer's ruleSolve:
>A=1232−1113−1>
>det(A)=1(−1)(−1)+2(3)(3)+1(2)(1)−1(−1)(3)−1(3)(1)−2(2)(−1)=1+18+2−(−3)−3−(−4)=1+18+2+3−3+4=25>Step 1: Compute det(A):
>A1=3262−1113−1>Step 2: Compute A1 (replace column 1 with b):
>det(A1)=3(−1)(−1)+2(3)(6)+1(2)(1)−1(−1)(6)−3(3)(1)−2(2)(−1)=3+36+2+6−9+4=42>
>A2=12332613−1>x=2542Step 3: A2 (replace column 2):
>det(A2)=1(2)(−1)+3(3)(3)+1(2)(6)−1(2)(3)−1(3)(6)−3(2)(−1)=−2+27+12−6−18+6=19>
>A3=1232−11326>y=2519Step 4: A3 (replace column 3):
>det(A3)=1(−1)(6)+2(2)(3)+3(2)(1)−3(−1)(3)−1(2)(1)−2(2)(6)=−6+12+6+9−2−24=−5>
z=25−5=−51Solution: x=2542, y=2519, z=−51.
3. Cramer's Rule vs. Gaussian Elimination
| Aspect | Cramer's Rule | Gaussian Elimination |
|---|---|---|
| Computational cost | O(n!) (requires n+1 determinants) | O(n3) |
| Practical for | n≤3 (textbook/exam problems) | n≥3 (real-world) |
| Works for singular A ? | No (requires det(A)=0 ) | Yes (detects inconsistency) |
| Conceptual value | Explicit formula; great for theory | Algorithmic; great for computation |
Why Cramer's rule matters despite being expensive: It proves that the solution depends continuously on the entries of A and b (since determinants are continuous functions). This is useful in theoretical arguments.
4. The Adjugate and Matrix Inverse
4.1 Cofactor Matrix and Adjugate
>adj(A)=CT>Definition (Cofactor Matrix). The cofactor matrix C of A has entries Cij=(−1)i+jMij (the cofactors). Definition (Adjugate). The adjugate (or classical adjoint) of A is the transpose of the cofactor matrix:
4.2 Inverse via Adjugate
>A−1=det(A)1adj(A)>Theorem. If det(A)=0, then:
This formula is theoretically important but computationally inefficient for large n (Gaussian elimination is better).
>A=[acbd]>Example 3: Inverse of a 2×2 matrix using adjugate
>C=[d−b−ca]>Cofactor matrix:
>adj(A)=CT=[d−c−ba]>Adjugate:
>A−1=ad−bc1[d−c−ba]>
>AA−1=ad−bc1[acbd][d−c−ba]=ad−bc1[ad−bc00ad−bc]=I>Check:
>A=105216340>✓ Example 4: Inverse of a 3×3 matrix
>det(A)=1(1⋅0−4⋅6)−2(0⋅0−4⋅5)+3(0⋅6−1⋅5)=1(−24)−2(−20)+3(−5)=−24+40−15=1>Step 1: Compute det(A).
>C11=+det[1640]=0−24=−24>Step 2: Compute all 9 cofactors.
>C12=−det[0540]=−(0−20)=20>
>C13=+det[0516]=0−5=−5>
>C21=−det[2630]=−(0−18)=18>
>C22=+det[1530]=0−15=−15>
>C23=−det[1526]=−(6−10)=4>
>C31=+det[2134]=8−3=5>
>C32=−det[1034]=−(4−0)=−4>
>C33=+det[1021]=1−0=1>
>adj(A)=−2420−518−1545−41>Step 3: Form the adjugate (transpose of cofactor matrix):
>A−1=11adj(A)=−2420−518−1545−41>Step 4: Since det(A)=1:
Verify: AA−1=I (check one entry: first row of A times first column of A−1: 1(−24)+2(20)+3(−5)=−24+40−15=1 ✓).
4.3 Properties of the Adjugate
| Property | Formula |
|---|---|
| Product | adj(AB)=adj(B)adj(A) |
| Transpose | adj(AT)=(adj(A))T |
| Inverse | adj(A−1)=(adj(A))−1 |
| Determinant | det(adj(A))=(det(A))n−1 |
| Scalar | adj(cA)=cn−1adj(A) |
| Fundamental identity | A⋅adj(A)=adj(A)⋅A=det(A)⋅In |
5. Edge Cases & Gotchas
| Situation | What Happens |
|---|---|
| ** det(A)=0 ** | Cramer's rule is undefined; the system may have 0 or infinitely many solutions |
| Rectangular matrices | Cramer's rule only works for square A |
| ** 1×1 system** | A=[a] , x=b/a (Cramer's rule reduces to division) |
| Near-zero determinant | Numerically unstable — small errors in det blow up the solution |
6. Common Pitfalls
❌ Pitfall 1: Forgetting to divide by det(A)
The formula is xj=det(Aj)/det(A), not xj=det(Aj). The determinant of the modified matrix alone is not the solution.
❌ Pitfall 2: Misplacing b in the wrong column
To find x2, replace column 2 of A with b — not column 1 or 3.
❌ Pitfall 3: Applying Cramer's rule to non-square or singular systems
The rule requires A to be square with det(A)=0. Check this first before computing anything.
❌ Pitfall 4: Confusing adjugate and inverse
A−1=adj(A)/det(A), not adj(A) alone (unless det(A)=1).
7. Formula Summary Table
| Concept | Formula |
|---|---|
| Cramer's rule | xj=det(A)det(Aj) , Aj = A with column j replaced by b |
| Cofactor | Cij=(−1)i+jMij |
| Adjugate | adj(A)=CT |
| Inverse via adjugate | A−1=det(A)1adj(A) |
| 2×2 inverse (memorise) | [acbd]−1=ad−bc1[d−c−ba] |
| Fundamental identity | A⋅adj(A)=det(A)⋅I |
8. 📝 Practice Questions
>{3x+2y=7x−5y=−2>Q1: 2×2 Cramer's ruleSolve:
>det(A1)=7−22−5=7(−5)−2(−2)=−35+4=−31>Strategy: Compute det(A), det(A1), det(A2), then x and y.Solution: det(A)=3(−5)−2(1)=−15−2=−17
>det(A2)=317−2=3(−2)−7(1)=−6−7=−13>
>⎩⎨⎧x+y+z=62x−y+z=3x+2y−z=2>x=−17−31=1731, y=−17−13=1713. Q2: 3×3 Cramer's ruleSolve:
>det(A)=1211−1211−1>Solution:
>A1=6321−1211−1>=1(−1)(−1)+1(1)(1)+1(2)(2)−1(−1)(1)−1(1)(2)−1(2)(−1) =1+1+4+1−2+2=7
>A2=12163211−1>, det(A1)=6(−1)(−1)+1(1)(2)+1(3)(2)−1(−1)(2)−6(1)(2)−1(3)(−1) =6+2+6+2−12+3=7x=77=1
>A3=1211−12632>, det(A2)=1(3)(−1)+6(1)(1)+1(2)(2)−1(3)(1)−1(1)(2)−6(2)(−1) =−3+6+4−3−2+12=14y=714=2
>A=[4231]>, det(A3)=1(−1)(2)+1(3)(1)+6(2)(2)−6(−1)(1)−1(3)(2)−1(2)(2) =−2+3+24+6−6−4=21z=721=3Solution: x=1, y=2, z=3. Q3: 2×2 inverseFind A−1 for
>A−1=−21[1−2−34]=[−21123−2]>.Solution: det(A)=4(1)−3(2)=4−6=−2
>AA−1=[4231][−21123−2]=[−2+3−1+16−63−2]=[1001]>Verify:
>A=1240−11238>✓ Q4: 3×3 inverseFind A−1 for
>C11=+det[−1138]=−8−3=−11>.Solution: det(A)=1(−1)(8)+0(3)(4)+2(2)(1)−2(−1)(4)−1(3)(1)−0(2)(8) =−8+0+4+8−3−0=1Cofactors:
>C12=−det[2438]=−(16−12)=−4>
>C13=+det[24−11]=2−(−4)=6>
>C21=−det[0128]=−(0−2)=2>
>C22=+det[1428]=8−8=0>
>C23=−det[1401]=−(1−0)=−1>
>C31=+det[0−123]=0−(−2)=2>
>C32=−det[1223]=−(3−4)=1>
>C33=+det[120−1]=−1−0=−1>
>adj(A)=CT=−11−4620−121−1>
>{kx+y=1x+ky=1>Since det(A)=1, A−1=adj(A). Q5: Using Cramer's rule with parametersFor what k does Cramer's rule apply? Solve for x and y:
>det(A1)=111k=k−1>Solution: det(A)=k(k)−1(1)=k2−1=(k−1)(k+1)Cramer's rule applies when det(A)=0, i.e., k=±1.
>det(A2)=k111=k−1>
>A=[2314]>x=(k−1)(k+1)k−1=k+11 (for k=±1) y=(k−1)(k+1)k−1=k+11 (for k=±1)Check: When k=1, the system is x+y=1, x+y=1 (infinitely many solutions). When k=−1, the system is −x+y=1, x−y=1 (inconsistent). Q6: Adjugate propertiesVerify A⋅adj(A)=det(A)⋅I for
>adj(A)=[4−3−12]>.Solution: det(A)=8−3=5
>A⋅adj(A)=[2314][4−3−12]=[8−312−12−2+2−3+8]=[5005]=5I>
>A=[1225]>✓ Q7: Solving with inverseSolve Ax=b using A−1 where
>b=[37]>,
>A−1=11[5−2−21]=[5−2−21]>.Solution: det(A)=5−4=1
>x=A−1b=[5−2−21][37]=[15−14−6+7]=[11]>
>{5x+3y=1902x+4y=120>Check: 1(1)+2(1)=3 ✓, 2(1)+5(1)=7 ✓. Q8: Cramer's rule — word problemA company makes two products. The profit equations are:
>det(A1)=19012034=190(4)−3(120)=760−360=400>where x = units of product A, y = units of product B. Find x and y.Solution: det(A)=5(4)−3(2)=20−6=14
>det(A2)=52190120=5(120)−190(2)=600−380=220>
>{x+2y=52x+4y=10>x=14400≈28.57, y=14220≈15.71. Q9: Determinant of adjugateIf A is 3×3 with det(A)=−4, find det(adj(A)).Solution: det(adj(A))=(det(A))n−1=(−4)2=16. Q10: When Cramer's rule failsExplain why Cramer's rule cannot solve the system:
>[xy]=[50]+y[−21]>and find all solutions.Solution: det(A)=1(4)−2(2)=4−4=0, so Cramer's rule is inapplicable.The second equation is twice the first, so we have x+2y=5. x=5−2y, y free. Infinitely many solutions.Parametric:
.
🔗 Cross-References
- Next topic: Vector Spaces Definition
- Week 1 (Determinants): Foundation for Cramer's rule
- Week 5 (Rank-Nullity): det(A)=0 means full rank, zero nullity
- Week 12 (Eigenvalues): The characteristic polynomial uses det(A−λI)
- BSCS3004 (Deep Learning): Matrix inverses appear in normal equations for linear regression Join Discord Previous2.1 Gaussian EliminationNext3.1 Vector Spaces Definition