Session 20 · Unit 2

Cramer's Rule, Inverse Matrix, and Volume


The payoff lecture for determinants. The single number det A produces a formula for the inverse matrix (a transposed matrix of cofactors over the determinant), a formula for the solution of Ax = b (Cramer's Rule), and a formula for volume — the determinant of A is the volume of the box whose edges are the rows of A. Beautiful for algebra, disastrous for computation: elimination still wins in practice.

A formula for the inverse

Two lectures of hard work produced the formula for the determinant and its properties. This final determinant lecture is about the applications — “always this determinant packs all this information into a single number,” and that number now gives us formulas for things we’ve been computing all along without formulas.

Start with the one inverse we know by heart. For a 2×2 matrix,

[abcd]1=1adbc[dbca].\begin{bmatrix} a & b \\ c & d \end{bmatrix}^{-1} = \frac{1}{ad - bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}.

What are we dividing by? The determinant — and that makes good sense, because the formula is perfect exactly as long as the determinant isn’t zero, which is exactly when the inverse exists. But can we recognize the entries d,b,c,ad, -b, -c, a? Strang’s hint: think cofactors. The dd is the cofactor of aa — strike out row one and column one and dd is what’s left. The b-b sitting in the (1,2)(1,2) position is the cofactor of cc: strike out cc‘s row and column and you’re left with bb, and the sign is minus because cc sits in position (2,1)(2,1) and 2+12 + 1 is odd.

What kind of formula is this? For a 3×3 matrix, detA\det A is a sum of products of three entries (aeiaei, bfgbfg, cdhcdh, ceg-ceg, and so on), while each cofactor is a determinant one size smaller — products of two entries. In general: the determinant involves products of nn entries, the cofactors products of n1n-1. We never noticed any of this when we computed inverses by Gauss–Jordan — tuck the identity next to AA, eliminate until AA becomes II, and the identity has become A1A^{-1}. That was great numerically, “but we never knew what was going on.” Now we have the algebra instead of the algorithm.

Why the formula is true

It’s a pretty magic formula, so it needs checking. The claim to verify is

ACT=(detA)I.A\, C^{\mathsf{T}} = (\det A)\, I.

Multiply row one of AA against column one of CTC^{\mathsf{T}} — which, because of the transpose, holds the cofactors from row one. The (1,1)(1,1) entry of the product is

a11c11+a12c12++a1nc1n.a_{11} c_{11} + a_{12} c_{12} + \cdots + a_{1n} c_{1n}.

What does that sum up to? That is exactly the cofactor formula for the determinant from last lecture — entries of a row times their own cofactors give detA\det A. The same happens down the whole diagonal: row two times the cofactors from row two is detA\det A again, and so on to row nn. The cofactor expansion is a sum of products, so of course it’s secretly a matrix multiplication.

The remaining question is the off-diagonal entries: why does a row of AA times the cofactors from a different row automatically give zero? Check it in the 2×2 case: row one is (a,b)(a, b); the cofactors from row two are (b,a)(-b, a), and sure enough a(b)+b(a)=0a(-b) + b(a) = 0. But we want a reason that works for n×nn \times n.

So ACT=(detA)IA C^{\mathsf{T}} = (\det A) I is an identity — “a beautiful identity” — and dividing by detA\det A gives the inverse. One thing the formula buys us that Gauss–Jordan never could: sensitivity. If you nudge the (1,1)(1,1) entry of a nonsingular matrix — add one to it, say — what happens to the inverse? The formula answers: watch what happens to the determinant and to the cofactors. It’s all there.

Cramer’s Rule

Second application: solving Ax=bA\mathbf{x} = \mathbf{b}. Of course the solution is x=A1b\mathbf{x} = A^{-1}\mathbf{b}, and now there’s a formula for A1A^{-1}:

x=1detACTb.\mathbf{x} = \frac{1}{\det A}\, C^{\mathsf{T}} \mathbf{b}.

This is the very same answer elimination produced on the first day of class — but now it’s a formula, and Cramer’s Rule is a way of looking at this formula. Every component of x\mathbf{x} has detA\det A underneath; no surprise. The question is what sits on top. The first entry of CTbC^{\mathsf{T}}\mathbf{b} is b1c11+b2c21++bncn1b_1 c_{11} + b_2 c_{21} + \cdots + b_n c_{n1} — cofactors times numbers. And any time you multiply cofactors by numbers, you’re computing the determinant of something. Cramer’s good idea was to realize which matrix.

Why does detB1\det B_1 equal the first entry of CTbC^{\mathsf{T}}\mathbf{b}? Expand detB1\det B_1 in cofactors down its first column — the column that is now b\mathbf{b}. The entry b1b_1 multiplies its cofactor, which is a determinant one size smaller and is exactly c11c_{11} of the original AA (the rest of B1B_1 is AA). Then b2b_2 gets multiplied by c21c_{21}, and so on: precisely the sum we wanted. The book gives another, cuter proof that leans less on cofactors, but with cofactors already on the board, this one is free.

Is the rule any good in practice? Cramer might say: all you have to do is compute n+1n+1 determinants — the nn matrices BjB_j and AA itself. Strang remembers a popular math book from his childhood, Mathematics for the Million, which explained elimination in a complicated way and then presented Cramer’s Rule as the way to go. “Actually, Cramer’s Rule is a disastrous way to go, because to compute these determinants, it takes, like, approximately forever” — he now thinks of the title as Mathematics for the Millionaire, since you’d have to pay for a hopelessly long calculation that elimination does in an instant. MATLAB would never use it. The value of the formula is algebraic, not computational: it lets you do algebra with letters instead of running algorithms. “They’re nice formulas, but I just don’t want you to use them.”

The determinant is a volume

Third application, and the amazing one: the determinant equals the volume of a box. Take a 3×3 matrix AA. Draw the vector to the point (a11,a12,a13)(a_{11}, a_{12}, a_{13}) — row one — as one edge of a box starting at the origin. Row two gives a second edge, row three a third. Complete the figure: the proper word is parallelepiped, but “for obvious reasons, I wrote box.” Every face is a parallelogram.

The elegant proof: show that box volume satisfies the same three defining properties as the determinant — then it must be the determinant.

Property 1. If A=IA = I, the rows are the coordinate vectors and the box is the unit cube, volume one. Determinant one. ✓

Go up one level, and bring back the previous chapter: let A=QA = Q, an orthogonal matrix — orthonormal columns, perpendicular unit vectors. The box is again a cube, just rotated in space, so its volume is one. Is detQ=±1\det Q = \pm 1? Start from the defining equation QTQ=IQ^{\mathsf{T}} Q = I and take determinants of both sides. Rule 9 (the product rule) pays off: detQTdetQ=1\det Q^{\mathsf{T}} \cdot \det Q = 1. Rule 10 pays off: detQT=detQ\det Q^{\mathsf{T}} = \det Q. So (detQ)2=1(\det Q)^2 = 1 and detQ=±1\det Q = \pm 1. ✓

Property 2. Exchanging two rows reverses the sign of the determinant — but it doesn’t change the box at all, and it doesn’t change the absolute value. No problem.

Property 3a. Stretch one edge — double row one, keeping the other edges fixed. The volume doubles: the new box is two identical copies stacked together. And doubling a row of the matrix doubles the determinant — that’s rule 3a, factoring tt out of a row. ✓

Property 3b — linearity in a single row, det\det of a matrix with first row (a+a,b+b)(a + a', b + b') splitting into two determinants — is the one that forces us away from right angles, and it’s where the lecture’s clock runs out. Strang leaves it: “the book has a carefully drawn figure to show why that works.” With all the defining properties matched, volume equals determinant.

Areas without lengths or angles

In two dimensions, the box is a parallelogram and volume means area. Take the parallelogram with one edge to (a,b)(a, b), another to (c,d)(c, d), and fourth vertex at (a+c,b+d)(a+c, b+d). Last year you’d have computed base times height: the base is a2+b2\sqrt{a^2 + b^2}, and the height is “other revolting stuff” — square roots everywhere. Now:

area of parallelogram=det[abcd]=adbc.\text{area of parallelogram} = \left| \det \begin{bmatrix} a & b \\ c & d \end{bmatrix} \right| = |ad - bc|.

No square roots. Totally rememberable — it’s exactly the formula we’ve studied for three lectures. This, more than Cramer’s Rule, is the formula that impresses Strang: if you know the coordinates of the corners, you have a great formula for area or volume with no lengths, no angles, no heights.

Next lectures are about eigenvalues — “so we’re really into the big stuff.”

Problems

Work these before revealing the solutions. Everything you need is in the lecture’s three formulas.

Problem 20.1 Inverse by cofactors

Use the cofactor formula A1=1detACTA^{-1} = \frac{1}{\det A} C^{\mathsf{T}} to invert

A=[210031004].A = \begin{bmatrix} 2 & 1 & 0 \\ 0 & 3 & 1 \\ 0 & 0 & 4 \end{bmatrix}.
Show solution

The matrix is triangular, so detA=234=24\det A = 2 \cdot 3 \cdot 4 = 24.

Compute the nine cofactors cij=(1)i+jMijc_{ij} = (-1)^{i+j} M_{ij}:

c11=12,c12=0,c13=0,c_{11} = 12,\quad c_{12} = 0,\quad c_{13} = 0,c21=4,c22=8,c23=0,c_{21} = -4,\quad c_{22} = 8,\quad c_{23} = 0,c31=1,c32=2,c33=6.c_{31} = 1,\quad c_{32} = -2,\quad c_{33} = 6.

So

A1=124CT=124[1241082006]=[12161240131120014].A^{-1} = \frac{1}{24} C^{\mathsf{T}} = \frac{1}{24} \begin{bmatrix} 12 & -4 & 1 \\ 0 & 8 & -2 \\ 0 & 0 & 6 \end{bmatrix} = \begin{bmatrix} \tfrac{1}{2} & -\tfrac{1}{6} & \tfrac{1}{24} \\ 0 & \tfrac{1}{3} & -\tfrac{1}{12} \\ 0 & 0 & \tfrac{1}{4} \end{bmatrix}.

Check the (1,1)(1,1) entry of AA1AA^{-1}: 212+10+0=12 \cdot \tfrac{1}{2} + 1 \cdot 0 + 0 = 1. ✓ (Notice the inverse of an upper triangular matrix is upper triangular — the formula shows why: the cofactors c12c_{12}, c13c_{13}, c23c_{23} below the diagonal of CTC^{\mathsf{T}} all vanish.)

Problem 20.2 Cramer's Rule, 2×2

Solve by Cramer’s Rule:

3x+2y=7x+4y=9.\begin{aligned} 3x + 2y &= 7 \\ x + 4y &= 9. \end{aligned}
Show solution
detA=det[3214]=122=10.\det A = \det \begin{bmatrix} 3 & 2 \\ 1 & 4 \end{bmatrix} = 12 - 2 = 10.

Replace column one by b\mathbf{b} for B1B_1, column two for B2B_2:

detB1=det[7294]=2818=10,detB2=det[3719]=277=20.\det B_1 = \det \begin{bmatrix} 7 & 2 \\ 9 & 4 \end{bmatrix} = 28 - 18 = 10, \qquad \det B_2 = \det \begin{bmatrix} 3 & 7 \\ 1 & 9 \end{bmatrix} = 27 - 7 = 20.

So

x=detB1detA=1010=1,y=detB2detA=2010=2.x = \frac{\det B_1}{\det A} = \frac{10}{10} = 1, \qquad y = \frac{\det B_2}{\det A} = \frac{20}{10} = 2.

Check: 3(1)+2(2)=73(1) + 2(2) = 7 ✓ and 1+4(2)=91 + 4(2) = 9 ✓.

Problem 20.3 Why off-diagonals vanish

Let

A=[1234].A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}.

Write down the cofactor matrix CC, compute the product ACTA C^{\mathsf{T}} in full, and explain — using the “matrix with two equal rows” argument from lecture — why the off-diagonal entries had to be zero.

Show solution

The cofactors: c11=4c_{11} = 4, c12=3c_{12} = -3, c21=2c_{21} = -2, c22=1c_{22} = 1, so

C=[4321],CT=[4231].C = \begin{bmatrix} 4 & -3 \\ -2 & 1 \end{bmatrix}, \qquad C^{\mathsf{T}} = \begin{bmatrix} 4 & -2 \\ -3 & 1 \end{bmatrix}.

Multiply:

ACT=[1234][4231]=[462+212126+4]=[2002]=(detA)I,A C^{\mathsf{T}} = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}\begin{bmatrix} 4 & -2 \\ -3 & 1 \end{bmatrix} = \begin{bmatrix} 4 - 6 & -2 + 2 \\ 12 - 12 & -6 + 4 \end{bmatrix} = \begin{bmatrix} -2 & 0 \\ 0 & -2 \end{bmatrix} = (\det A)\, I,

since detA=46=2\det A = 4 - 6 = -2.

The (1,2)(1,2) entry is row one of AA times the cofactors from row two of AA: 1(2)+211 \cdot (-2) + 2 \cdot 1. That is exactly the cofactor expansion of the determinant of the “screwed up” matrix

AS=[1212]A_S = \begin{bmatrix} 1 & 2 \\ 1 & 2 \end{bmatrix}

— row one of AA appearing twice, expanded along its second row. A matrix with two equal rows is singular, so the expansion must give zero.

Problem 20.4 Volume of a box

Find the volume of the parallelepiped with edges from the origin to (1,1,0)(1, 1, 0), (0,2,1)(0, 2, 1), and (1,0,3)(1, 0, 3). Is the ordering of these three edges right-handed or left-handed?

Show solution

Put the edges in the rows and take the determinant, expanding along row one:

det[110021103]=1det[2103]1det[0113]+0=1(6)1(1)=7.\det \begin{bmatrix} 1 & 1 & 0 \\ 0 & 2 & 1 \\ 1 & 0 & 3 \end{bmatrix} = 1 \det \begin{bmatrix} 2 & 1 \\ 0 & 3 \end{bmatrix} - 1 \det \begin{bmatrix} 0 & 1 \\ 1 & 3 \end{bmatrix} + 0 = 1(6) - 1(-1) = 7.

The volume is 7=7|7| = 7. Since the determinant is positive, the three edges in this order form a right-handed box. (Exchanging any two of the edges would flip the sign to 7-7 — same volume, left-handed orientation.)

Problem 20.5 Triangle from three corners

Find the area of the triangle with vertices (1,2)(1, 2), (4,3)(4, 3), and (2,6)(2, 6), using the lecture’s determinant formula with the column of ones. Then verify by translating the triangle so one vertex is at the origin.

Show solution

The formula:

area=12det[121431261].\text{area} = \frac{1}{2} \left| \det \begin{bmatrix} 1 & 2 & 1 \\ 4 & 3 & 1 \\ 2 & 6 & 1 \end{bmatrix} \right|.

Subtract row one from rows two and three (determinant unchanged):

det[121310140]=1det[3114]=121=11,\det \begin{bmatrix} 1 & 2 & 1 \\ 3 & 1 & 0 \\ 1 & 4 & 0 \end{bmatrix} = 1 \cdot \det \begin{bmatrix} 3 & 1 \\ 1 & 4 \end{bmatrix} = 12 - 1 = 11,

expanding down the third column. So the area is 112\tfrac{11}{2}.

Verification by translation: shift every vertex by (1,2)(-1, -2), giving (0,0)(0,0), (3,1)(3, 1), (1,4)(1, 4). Then

area=12adbc=123411=112.\text{area} = \frac{1}{2} |ad - bc| = \frac{1}{2} |3 \cdot 4 - 1 \cdot 1| = \frac{11}{2}. \checkmark

The row subtractions in the 3×3 determinant were exactly this translation to the origin.