Unit 5, lesson 26

Determinants, Invertibility and Cramer's Rule

Why a square matrix is invertible exactly when its determinant is nonzero, which right-hand sides a singular square system can reach, how Cramer's rule solves a nonsingular system, and when elimination is the better method.

  • Video 26
  • Computing and Using Determinants

A 2×22 \times 2 matrix that sends the whole plane onto a line has determinant zero. A target on that line is reached by infinitely many inputs, a target off the line by none, and the determinant, which is computed from the matrix alone, cannot tell the two targets apart. When the determinant is not zero, every target has exactly one input, and Cramer’s rule writes each coordinate of that input as a ratio of two determinants. This lesson proves the determinant test for invertibility, sorts the right-hand sides of a singular system into reachable and unreachable ones, derives Cramer’s rule and compares it with elimination. A tuple such as (3,6)(3, 6) stands for a column vector.

Key terms

Determinant test for invertibility

Definition A real n×nn \times n matrix AA is invertible if and only if det⁡A≠0\det A \ne 0. In that case

det⁡(A−1)=1det⁡A.\det(A^{-1}) = \frac{1}{\det A}.

If AA is invertible, then AA−1=IAA^{-1} = I, and the product rule gives det⁡A det⁡(A−1)=det⁡I=1\det A \, \det(A^{-1}) = \det I = 1, so neither factor is 00. If AA is not invertible, its columns are linearly dependent, and a matrix with dependent columns has determinant 00. So a nonzero determinant forces AA to be invertible. Elimination tells the same story. Reducing AA with row swaps and replacements to an echelon form UU, which is upper triangular, gives det⁡A=±u11u22⋯unn\det A = \pm u_{11} u_{22} \cdots u_{nn}, which is nonzero exactly when every column has a pivot. For an n×nn \times n matrix AA the following statements are therefore equivalent.

  • The determinant det⁡A\det A is not zero.
  • The matrix AA is invertible.
  • The matrix AA has nn pivots, so rank⁡A=n\operatorname{rank} A = n.
  • The null space Null⁡A\operatorname{Null} A is {0}\{\mathbf{0}\}.
  • The columns of AA form a basis of Rn\mathbb{R}^n.
  • The system Ax=bA\mathbf{x} = \mathbf{b} has exactly one solution for every b\mathbf{b} in Rn\mathbb{R}^n.

Only square matrices have determinants, so a rectangular matrix or an augmented matrix [A∣b][A \mid \mathbf{b}] is studied with rank instead.

In plain words A nonzero determinant means the map keeps full dimension, so it can be undone. A zero determinant means some direction is flattened, and nothing can bring it back.

Example The matrices

M=[120251013],N=[123456789]\begin{gathered} M = \begin{bmatrix} 1 & 2 & 0 \\ 2 & 5 & 1 \\ 0 & 1 & 3 \end{bmatrix}, \\[0.4em] N = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix} \end{gathered}

have det⁡M=2\det M = 2 and det⁡N=0\det N = 0. So MM is invertible and det⁡(M−1)=12\det(M^{-1}) = \tfrac{1}{2}, found without computing M−1M^{-1}. The matrix NN is singular, and indeed its columns n1,n2,n3\mathbf{n}_1, \mathbf{n}_2, \mathbf{n}_3 satisfy n1−2n2+n3=0\mathbf{n}_1 - 2\mathbf{n}_2 + \mathbf{n}_3 = \mathbf{0}.

The test separates zero from nonzero, and the size of a nonzero determinant does not measure how close a matrix is to singular. The 10×1010 \times 10 matrix 110I\tfrac{1}{10}I has determinant 10−1010^{-10}, yet solving with it only multiplies by 1010. The matrix diag⁡(100,1100)\operatorname{diag}(100, \tfrac{1}{100}) has determinant 11, yet it stretches one axis 10410^4 times as much as the other. How sensitive a solution is to small changes in the data is the subject of conditioning.

Singular square system

Definition A square system Ax=bA\mathbf{x} = \mathbf{b}, with AA of size n×nn \times n, is singular when AA is singular, that is, when det⁡A=0\det A = 0. Such a system never has exactly one solution. Either it has no solution, or it has a solution xp\mathbf{x}_p, and then its solution set is

{xp+h:h∈Null⁡A},\{\mathbf{x}_p + \mathbf{h} : \mathbf{h} \in \operatorname{Null} A\},

which is infinite, because Null⁡A\operatorname{Null} A contains a nonzero vector w\mathbf{w} and all of its multiples twt\mathbf{w}.

In plain words A zero determinant rules out a unique answer, but it does not say whether there is any answer. That depends on the right-hand side.

Example Let

S=[2142],det⁡S=4−4=0.\begin{gathered} S = \begin{bmatrix} 2 & 1 \\ 4 & 2 \end{bmatrix}, \\[0.4em] \det S = 4 - 4 = 0. \end{gathered}

For b=(3,6)\mathbf{b} = (3, 6) the equations are 2x1+x2=32x_1 + x_2 = 3 and 4x1+2x2=64x_1 + 2x_2 = 6, and the second is twice the first. Taking x1=tx_1 = t gives x2=3−2tx_2 = 3 - 2t, so the solutions are

x=[03]+t[1−2],t∈R.\mathbf{x} = \begin{bmatrix} 0 \\ 3 \end{bmatrix} + t\begin{bmatrix} 1 \\ -2 \end{bmatrix}, \qquad t \in \mathbb{R}.

Here (0,3)(0, 3) is one particular solution, and (1,−2)(1, -2) spans Null⁡S\operatorname{Null} S, since S(1,−2)=(0,0)S(1, -2) = (0, 0). For instance, t=1t = 1 gives the solution (1,1)(1, 1).

Reachable and unreachable right-hand sides

Definition A right-hand side b\mathbf{b} is reachable for a matrix AA if Ax=bA\mathbf{x} = \mathbf{b} for some x\mathbf{x}, that is, if b\mathbf{b} lies in the image Col⁡A\operatorname{Col} A. Otherwise it is unreachable, and the system has no solution. For an n×nn \times n matrix with det⁡A≠0\det A \ne 0, every b\mathbf{b} in Rn\mathbb{R}^n is reachable. When det⁡A=0\det A = 0, the image Col⁡A\operatorname{Col} A is a subspace of dimension rank⁡A<n\operatorname{rank} A < n, so some right-hand sides are reachable and others are not. The number det⁡A\det A depends on AA alone, so it cannot decide which. Row reduction of the augmented matrix [A∣b][A \mid \mathbf{b}] does decide, since the system is inconsistent exactly when an echelon form has a row [ 0 ⋯ 0∣c ][\,0 \ \cdots \ 0 \mid c\,] with c≠0c \ne 0.

In plain words A singular map covers only a line, a plane or another proper subspace of its output space. Targets on that subspace are reachable, each by infinitely many inputs. Targets off it are not reachable at all.

Example For SS above, Col⁡S\operatorname{Col} S is the line spanned by (1,2)(1, 2), made of the vectors whose second coordinate is twice the first. So (3,6)(3, 6) is reachable and (3,5)(3, 5) is not. Row reduction shows the same thing. For (3,6)(3, 6) it gives

[213426]→R2→R2−2R1[213000],\begin{aligned} &\left[\begin{array}{cc|c} 2 & 1 & 3 \\ 4 & 2 & 6 \end{array}\right] \\[0.4em] &\xrightarrow{R_2 \to R_2 - 2R_1} \left[\begin{array}{cc|c} 2 & 1 & 3 \\ 0 & 0 & 0 \end{array}\right], \end{aligned}

and for (3,5)(3, 5) it gives

[213425]→R2→R2−2R1[21300−1].\begin{aligned} &\left[\begin{array}{cc|c} 2 & 1 & 3 \\ 4 & 2 & 5 \end{array}\right] \\[0.4em] &\xrightarrow{R_2 \to R_2 - 2R_1} \left[\begin{array}{cc|c} 2 & 1 & 3 \\ 0 & 0 & -1 \end{array}\right]. \end{aligned}

The last row of the second reduction says 0=−10 = -1, so that system has no solution. Both systems have the same coefficient matrix and the same determinant 00.

Cramer’s rule

Definition Let AA be a real n×nn \times n matrix with det⁡A≠0\det A \ne 0, let b\mathbf{b} be in Rn\mathbb{R}^n, and for each ii let AiA_i be the matrix obtained from AA by replacing column ii with b\mathbf{b}, keeping every other column in place. Then the unique solution x=(x1,…,xn)\mathbf{x} = (x_1, \dots, x_n) of Ax=bA\mathbf{x} = \mathbf{b} is given by

xi=det⁡Aidet⁡A,i=1,…,n.x_i = \frac{\det A_i}{\det A}, \qquad i = 1, \dots, n.

To see why, write the columns of AA as a1,…,an\mathbf{a}_1, \dots, \mathbf{a}_n, so that b=x1a1+⋯+xnan\mathbf{b} = x_1\mathbf{a}_1 + \cdots + x_n\mathbf{a}_n. By linearity in column ii, the number det⁡Ai\det A_i is the sum over jj of xjx_j times the determinant of AA with column ii replaced by aj\mathbf{a}_j. For j≠ij \ne i that matrix has two equal columns, so its determinant is 00. For j=ij = i it is AA itself. Hence det⁡Ai=xidet⁡A\det A_i = x_i \det A, and dividing by det⁡A≠0\det A \ne 0 gives the formula.

In plain words To find one unknown, put the right-hand side into that unknown’s column and divide the new determinant by the old one. The rule needs det⁡A≠0\det A \ne 0. When det⁡A=0\det A = 0 the division is undefined, and an expression such as 0/00/0 does not pick out a solution.

Example The system 3x1+2x2=73x_1 + 2x_2 = 7, x1+4x2=9x_1 + 4x_2 = 9 has

A=[3214],det⁡A=12−2=10.\begin{gathered} A = \begin{bmatrix} 3 & 2 \\ 1 & 4 \end{bmatrix}, \\[0.4em] \det A = 12 - 2 = 10. \end{gathered}

Replacing each column in turn by b=(7,9)\mathbf{b} = (7, 9) gives

x1=110∣7294∣=28−1810=1,x2=110∣3719∣=27−710=2.\begin{aligned} x_1 &= \frac{1}{10}\begin{vmatrix} 7 & 2 \\ 9 & 4 \end{vmatrix} = \frac{28 - 18}{10} = 1, \\[0.4em] x_2 &= \frac{1}{10}\begin{vmatrix} 3 & 7 \\ 1 & 9 \end{vmatrix} = \frac{27 - 7}{10} = 2. \end{aligned}

Substituting back, 3⋅1+2⋅2=73 \cdot 1 + 2 \cdot 2 = 7 and 1+4⋅2=91 + 4 \cdot 2 = 9.

Cramer’s rule versus elimination

Definition For an n×nn \times n system with det⁡A≠0\det A \ne 0, Cramer’s rule and elimination give the same unique solution, but for larger nn at very different cost. Cramer’s rule needs the n+1n + 1 determinants det⁡A,det⁡A1,…,det⁡An\det A, \det A_1, \dots, \det A_n. Computed by elimination, each of them costs about as much as solving the whole system once by elimination, so the rule does roughly n+1n + 1 times the work. Computed by full cofactor expansion, each is a sum of n!n! products. Elimination also handles det⁡A=0\det A = 0, where it decides consistency and describes every solution. A factorization A=LUA = LU, or PA=LUPA = LU when rows must be swapped, is computed once and then solves each new right-hand side with two triangular solves. Cramer’s rule suits small systems, especially when only one unknown is needed or the entries are symbolic, and it shows how each coordinate of the solution depends on b\mathbf{b}.

In plain words Cramer’s rule is an exact formula that explains where the solution comes from. Elimination and factorizations are how solutions are computed for anything beyond a few unknowns, and elimination keeps working when the matrix is singular.

Example The system 3x1+2x2=73x_1 + 2x_2 = 7, x1+4x2=9x_1 + 4x_2 = 9 above takes one elimination step. The replacement R2→R2−13R1R_2 \to R_2 - \tfrac{1}{3}R_1 leaves 103x2=9−73=203\tfrac{10}{3}x_2 = 9 - \tfrac{7}{3} = \tfrac{20}{3}, so x2=2x_2 = 2, and back-substitution gives 3x1=7−43x_1 = 7 - 4, so x1=1x_1 = 1. For the singular system Sx=(3,6)S\mathbf{x} = (3, 6), the two numerators would be

∣3162∣=0,∣2346∣=0,\begin{vmatrix} 3 & 1 \\ 6 & 2 \end{vmatrix} = 0, \qquad \begin{vmatrix} 2 & 3 \\ 4 & 6 \end{vmatrix} = 0,

so Cramer’s formula would read 0/00/0 and say nothing, while elimination produced the whole line of solutions. For a 10×1010 \times 10 system, a full cofactor expansion of each of the 1111 determinants has 10!=3,628,80010! = 3{,}628{,}800 terms.

Check yourself

  1. For which numbers kk is the following matrix invertible?
A=[12k011101]A = \begin{bmatrix} 1 & 2 & k \\ 0 & 1 & 1 \\ 1 & 0 & 1 \end{bmatrix}
Show the answer

Expanding along the first column, whose middle entry is 00,

det⁡A=1∣1101∣+1∣2k11∣=1+(2−k)=3−k.\begin{aligned} \det A &= 1\begin{vmatrix} 1 & 1 \\ 0 & 1 \end{vmatrix} + 1\begin{vmatrix} 2 & k \\ 1 & 1 \end{vmatrix} \\[0.4em] &= 1 + (2 - k) = 3 - k. \end{aligned}

So AA is invertible exactly when k≠3k \ne 3. For k=3k = 3 the third column (3,1,1)(3, 1, 1) is the sum of the first two, (1,0,1)+(2,1,0)(1, 0, 1) + (2, 1, 0).

  1. Use Cramer’s rule to find only x2x_2 in the system Ax=bA\mathbf{x} = \mathbf{b} with
A=[210131012],b=[102].A = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 3 & 1 \\ 0 & 1 & 2 \end{bmatrix}, \qquad \mathbf{b} = \begin{bmatrix} 1 \\ 0 \\ 2 \end{bmatrix}.
Show the answer

Expanding along the first row,

det⁡A=2(3⋅2−1⋅1)−1(1⋅2−1⋅0)=10−2=8.\begin{aligned} \det A &= 2(3 \cdot 2 - 1 \cdot 1) \\[0.4em] &\qquad - 1(1 \cdot 2 - 1 \cdot 0) \\[0.4em] &= 10 - 2 = 8. \end{aligned}

Replacing column 22 with b\mathbf{b} gives

det⁡A2=∣210101022∣=2(0−2)−1(2−0)=−6.\begin{aligned} \det A_2 &= \begin{vmatrix} 2 & 1 & 0 \\ 1 & 0 & 1 \\ 0 & 2 & 2 \end{vmatrix} \\[0.4em] &= 2(0 - 2) - 1(2 - 0) \\[0.4em] &= -6. \end{aligned}

So x2=−68=−34x_2 = -\tfrac{6}{8} = -\tfrac{3}{4}. The full solution is (78,−34,118)(\tfrac{7}{8}, -\tfrac{3}{4}, \tfrac{11}{8}), and it checks in all three equations, since 148−68=1\tfrac{14}{8} - \tfrac{6}{8} = 1, 78−188+118=0\tfrac{7}{8} - \tfrac{18}{8} + \tfrac{11}{8} = 0 and −34+114=2-\tfrac{3}{4} + \tfrac{11}{4} = 2.

  1. Let AA be the 3×33 \times 3 matrix with every entry equal to 11, and let b=(1,2,3)\mathbf{b} = (1, 2, 3). A student finds det⁡A=0\det A = 0 and det⁡A1=det⁡A2=det⁡A3=0\det A_1 = \det A_2 = \det A_3 = 0, and concludes from 0/00/0 that Ax=bA\mathbf{x} = \mathbf{b} has infinitely many solutions. Is that right?
Show the answer

No. Each AiA_i still contains two equal columns of ones, so its determinant is 00 for every b\mathbf{b} and carries no information about b\mathbf{b}. The first two equations read x1+x2+x3=1x_1 + x_2 + x_3 = 1 and x1+x2+x3=2x_1 + x_2 + x_3 = 2, which contradict each other. The replacement R2→R2−R1R_2 \to R_2 - R_1 on [A∣b][A \mid \mathbf{b}] produces the row [ 0 0 0∣1 ][\,0 \ 0 \ 0 \mid 1\,], so b\mathbf{b} is unreachable and the system has no solution. Cramer’s rule applies only when det⁡A≠0\det A \ne 0.

How this lesson connects