Finding an inverse by row reducing A next to I
The swap-and-divide formula only covers 2 by 2 matrices. How do you find the inverse of a larger square matrix, or find out that it has none, and why does the same row reduction answer both?
Where you are 12 in Matrices
When you reach for it
A square matrix A sends an input \mathbf{x} to an output A\mathbf{x}, and its inverse A^{-1} returns the input from the output. For a 2 \times 2 matrix the swap, negate and divide formula gives A^{-1} at a glance. From 3 \times 3 on, the tool is row reduction.
Ketsana runs a letterpress print shop. Every shade is mixed from three stock inks, each a fixed blend of three pigments. If \mathbf{x} lists the spoons of each stock ink, then A\mathbf{x} lists the grams of each pigment, where column j of A is the pigment content of one spoon of ink j. Mixing is multiplying by A. A customer brings a wanted shade \mathbf{b}; undoing the mix is multiplying by A^{-1}, and one inverse serves every customer.
Reach for it when you need A^{-1} itself, or to decide whether it exists. For one system, reducing [A \mid \mathbf{b}] as in Solving a system by row reduction: one, none or infinitely many solutions is less work.
The procedure
Reduce A with the identity beside it
Set the n \times n identity beside A and carry [A \mid I] toward Reduced row echelon form with the Augmented matrices and row operations. Each operation is chosen by the left half and applied to the whole row. There are two possible endings.
- The left half becomes I. Then the right half is A^{-1}:
- The left half produces a row of zeros (some column of A gets no pivot). Then A has no inverse, and you can stop.
Every order of operations gives the same matrix, since an inverse is unique (Exercise 18).
Why it works: one column at a time
By the Matrix multiplication, column j of AX is A times column j of X. So AX = I says column j of X solves A\mathbf{x} = \mathbf{e}_j, column j of I: n systems with one coefficient matrix, reduced together. This shows AX = I; the next argument shows XA = I too.
Why it works: each row operation is a matrix
An elementary matrix is I with one row operation done to it. For 3 \times 3 matrices, the operations R_2 - 2R_1 \to R_2 and 5R_2 \to R_2 give
Doing a row operation to any matrix M gives EM, where E is that operation’s elementary matrix. Row i of EM is row i of E times M, the combination of the rows of M weighted by row i of E. A row of I picks out one row of M unchanged, and the changed row of E builds the changed row: (-2, 1, 0) builds -2R_1 + R_2.
Suppose E_1, E_2, \dots, E_k, in that order, turn the left half into I, and let E = E_k \cdots E_2 E_1. A matrix split into two blocks is multiplied block by block, so
The left half is I, so EA = I, and the right half is E: the identity is a ledger recording the product of every operation.
Each row operation is undone by one of the same kind (subtract back, swap again, scale by \displaystyle \frac{1}{c}), so each E_i is invertible, and so is the product E, as Inverse of a 2 by 2 matrix, and solving with it showed for products. Multiplying EA = I on the left by E^{-1} gives A = E^{-1}, so AE = E^{-1}E = I as well, and
Also A = E_1^{-1} \cdots E_k^{-1}: every invertible matrix is a product of elementary matrices.
Why a zero row means no inverse
Row operations never change which vectors solve A\mathbf{x} = \mathbf{0}. If a column of A gets no pivot, its variable is free, so some \mathbf{x} \neq \mathbf{0} has A\mathbf{x} = \mathbf{0}. An inverse would force \mathbf{x} = A^{-1}A\mathbf{x} = \mathbf{0}. For a square matrix, a pivotless column and a zero row come together. In terms of the Rank:
Stated here without full proof: for square matrices a one-sided inverse is two-sided: BA = I implies AB = I, and the reverse. Exercise 16 proves the first half from the pivot argument; the The invertible matrix theorem gives the whole picture.
Worked examples
A 3 by 3 inverse with integer entries
Find the inverse of A = \begin{bmatrix} 1 & 3 & 2 \\ 2 & 7 & 5 \\ 1 & 1 & -1 \end{bmatrix}.
SolutionClear below the corner pivot with R_2 - 2R_1 \to R_2 and R_3 - R_1 \to R_3, giving rows (0, 1, 1 \mid -2, 1, 0) and (0, -2, -3 \mid -1, 0, 1). Clear below the second pivot with R_3 + 2R_2 \to R_3:
Three pivots, so A is invertible. Now -R_3 \to R_3 gives (0, 0, 1 \mid 5, -2, -1); R_2 - R_3 \to R_2 and R_1 - 2R_3 \to R_1 give (0, 1, 0 \mid -7, 3, 1) and (1, 3, 0 \mid -9, 4, 2); and R_1 - 3R_2 \to R_1 gives (1, 0, 0 \mid 12, -5, -1).
Check. Row 1 of A times the columns of A^{-1}: 12 - 21 + 10 = 1, -5 + 9 - 4 = 0, -1 + 3 - 2 = 0; rows 2 and 3 likewise. One product suffices, by the two-sided argument.
The ledger of elementary matrices
Find the inverse of A = \begin{bmatrix} 0 & 2 \\ 1 & 3 \end{bmatrix} by row reduction, and confirm that the product of the elementary matrices used is A^{-1}.
SolutionThe corner is 0: swap first. R_1 \leftrightarrow R_2 gives rows (1, 3 \mid 0, 1) and (0, 2 \mid 1, 0). Then \displaystyle \frac{1}{2}R_2 \to R_2 gives \displaystyle (0, 1 \mid \frac{1}{2}, 0), and R_1 - 3R_2 \to R_1 gives \displaystyle (1, 0 \mid -\frac{3}{2}, 1). So
The three operations done to I are
The first operation acts first, so it sits on the right: \displaystyle E_2E_1 = \begin{bmatrix} 0 & 1 \\ \frac{1}{2} & 0 \end{bmatrix}, and \displaystyle E_3(E_2E_1) = \begin{bmatrix} -\frac{3}{2} & 1 \\ \frac{1}{2} & 0 \end{bmatrix}, which is A^{-1}. Check with the 2 \times 2 formula: \det A = 0 \cdot 3 - 2 \cdot 1 = -2, and \displaystyle \frac{1}{-2}\begin{bmatrix} 3 & -2 \\ -1 & 0 \end{bmatrix} is the same matrix.
A swap and fractions in a 3 by 3
Find the inverse of A = \begin{bmatrix} 0 & 2 & 2 \\ 1 & 1 & 0 \\ 1 & 3 & 1 \end{bmatrix}.
SolutionThe corner is 0, so begin with R_1 \leftrightarrow R_2, then R_3 - R_1 \to R_3:
\displaystyle \frac{1}{2}R_2 \to R_2 gives \displaystyle (0, 1, 1 \mid \frac{1}{2}, 0, 0); R_3 - 2R_2 \to R_3 gives (0, 0, -1 \mid -1, -1, 1); -R_3 \to R_3 gives (0, 0, 1 \mid 1, 1, -1). Clearing upward, R_2 - R_3 \to R_2 gives \displaystyle (0, 1, 0 \mid -\frac{1}{2}, -1, 1) and R_1 - R_2 \to R_1 gives \displaystyle (1, 0, 0 \mid \frac{1}{2}, 2, -1).
Check. Row 3 of A, (1, 3, 1), times the columns: \displaystyle \frac{1}{2} - \frac{3}{2} + 1 = 0, 2 - 3 + 1 = 0, -1 + 3 - 1 = 1. Halves are expected: \det A = 2.
A matrix with no inverse
Decide whether A = \begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 7 \\ 3 & 6 & 10 \end{bmatrix} is invertible.
SolutionR_2 - 2R_1 \to R_2 and R_3 - 3R_1 \to R_3, then R_3 - R_2 \to R_3:
The left half has a zero row, so A is not invertible; its rank is 2. Column 2 got no pivot, and indeed it is twice column 1, so \mathbf{x} = (2, -1, 0) gives A\mathbf{x} = \mathbf{0}.
By the ledger argument, row 3 of the right half holds the weights that made the zero row:
Undoing the mix at the print shop
Ketsana’s stock inks are green, umber and red. One spoon of green holds 1 gram each of cyan and yellow pigment; umber holds 1 gram each of cyan, magenta and yellow; red holds 1 gram each of magenta and yellow. Malaythong orders a shade with 5 grams of cyan, 7 of magenta and 9 of yellow; Keomany orders 4, 1 and 3. How many spoons of each stock does each take?
SolutionColumns are the inks, rows the pigments (cyan, magenta, yellow):
In [A \mid I], R_3 - R_1 \to R_3 gives (0, 0, 1 \mid -1, 0, 1); R_2 - R_3 \to R_2 gives (0, 1, 0 \mid 1, 1, -1); R_1 - R_2 \to R_1 gives (1, 0, 0 \mid 0, -1, 1). So
Malaythong: A^{-1}(5, 7, 9) = (2, 3, 4), spoons of green, umber, red. Check. 2(1, 0, 1) + 3(1, 1, 1) + 4(0, 1, 1) = (5, 7, 9).
Keomany: A^{-1}(4, 1, 3) = (2, 2, -1), and a spoon cannot be taken out of a mix, so that shade cannot be made from these stocks. The columns of A^{-1} say why: column 1 is A^{-1}\mathbf{e}_1, the recipe for 1 gram of pure cyan, and it is (0, 1, -1). A shade can be mixed exactly when A^{-1}\mathbf{b} has no negative entry.
When the inverse depends on a number
For which k is A = \begin{bmatrix} 1 & 1 & 1 \\ 1 & 2 & 3 \\ 1 & 4 & k \end{bmatrix} invertible? Find A^{-1} for those k.
SolutionR_2 - R_1 \to R_2, R_3 - R_1 \to R_3, then R_3 - 3R_2 \to R_3:
If k = 7 the left half has a zero row: no inverse. If k \neq 7, write d = k - 7, a pivot one may divide by. \displaystyle \frac{1}{d}R_3 \to R_3 gives \displaystyle (0, 0, 1 \mid \frac{2}{d}, -\frac{3}{d}, \frac{1}{d}); R_2 - 2R_3 \to R_2 gives \displaystyle (0, 1, 0 \mid -1 - \frac{4}{d}, 1 + \frac{6}{d}, -\frac{2}{d}); R_1 - R_3 \to R_1, then R_1 - R_2 \to R_1, give \displaystyle (1, 0, 0 \mid 2 + \frac{2}{d}, -1 - \frac{3}{d}, \frac{1}{d}). Taking out \displaystyle \frac{1}{d}:
Check at k = 8: row 3 of A is (1, 4, 8), and with the columns (4, -5, 2), (-4, 7, -3), (1, -2, 1) it gives 0, 0, 1.
Boundaries
- Square matrices only. A non-square matrix has no two-sided inverse: a tall one always reduces to a zero row, a wide one always has a pivotless column.
- A zero row in the left half is final. The left half stays row equivalent to A, whose reduced form is unique, so no later step removes it.
- Rows only, on both halves. A column operation is multiplication on the right and breaks E[A \mid I] = [EA \mid E]; an operation on one half only loses the ledger.
- Never scale by zero. It cannot be undone.
- Exact numbers. Rounding can turn a pivot that should be 0 into a tiny nonzero one, and a false inverse appears.
Where this goes next
The The invertible matrix theorem gathers the conditions met here with many more. The Kernel names the vectors sent to \mathbf{0}, and When a matrix or transformation can be undone reads A^{-1} as the map undoing a map, so inverting a composition reverses the order. Elementary matrices return in Properties of determinants: row operations, products, transposes. In Coordinates in a basis and change of basis an inverse converts coordinates, and in Least squares: the best approximate solution of Ax = b A^{\mathsf{T}}A is inverted.
Exercises
Finding an inverse
- Find the inverse of \begin{bmatrix} 2 & 1 \\ 7 & 4 \end{bmatrix} by row reduction, and check it with the 2 \times 2 formula.
- Find the inverse of \begin{bmatrix} 1 & 2 & 1 \\ 0 & 1 & 3 \\ 0 & 0 & 1 \end{bmatrix}.
- Find the inverse of \begin{bmatrix} 1 & 0 & 2 \\ 2 & 1 & 3 \\ 0 & 1 & -2 \end{bmatrix}.
- Find the inverse of \begin{bmatrix} 0 & 1 & 1 \\ 2 & 0 & 2 \\ 1 & 1 & 0 \end{bmatrix}.
- Show that \begin{bmatrix} 1 & -1 & 2 \\ 2 & 1 & 1 \\ 1 & 2 & -1 \end{bmatrix} has no inverse, and read from the right half a combination of its rows that is zero.
Elementary matrices
- Write the 3 \times 3 elementary matrix for R_3 + 4R_1 \to R_3, and the one that undoes it.
- Which row operation does E = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix} perform? Find E\begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \end{bmatrix}.
- Reduce A = \begin{bmatrix} 2 & 6 \\ 1 & 4 \end{bmatrix} to I by \displaystyle \frac{1}{2}R_1 \to R_1, R_2 - R_1 \to R_2, R_1 - 3R_2 \to R_1. Write A^{-1} as a product of elementary matrices and multiply it out; then write A as such a product.
The second set of stocks
Ketsana buys new stock inks. One spoon of plum holds 2 grams of cyan and 1 of magenta; umber holds 1 gram each of cyan, magenta and yellow; rose holds 1 gram each of magenta and yellow.
- Write the mixing matrix (columns plum, umber, rose; rows cyan, magenta, yellow) and find its inverse.
- Malaythong orders 7 grams of cyan, 6 of magenta and 4 of yellow. How many spoons of each stock?
- Keomany orders 3 grams of cyan, 3 of magenta and 1 of yellow. Can it be mixed from these stocks?
- Can any single pure pigment be mixed from these stocks? Use the columns of the inverse.
Parameters and patterns
- For which numbers c is \begin{bmatrix} 1 & 2 & c \\ 0 & 1 & 1 \\ 2 & c & 4 \end{bmatrix} invertible?
- Find the inverse of \begin{bmatrix} 1 & 0 & 0 \\ a & 1 & 0 \\ b & c & 1 \end{bmatrix} in terms of a, b and c.
Reasoning
- Refute with an example: “If no entry of a square matrix is 0, the matrix is invertible.”
- Let A and B be n \times n with BA = I. Show that the reduced form of A is I, and then that B = A^{-1}.
- Explain why an invertible upper triangular matrix has an upper triangular inverse.
- Show that if BA = I and AC = I, then B = C. Why does this make the result of the procedure independent of the order of operations?
Answers
- \begin{bmatrix} 4 & -1 \\ -7 & 2 \end{bmatrix}. \displaystyle \frac{1}{2}R_1, then R_2 - 7R_1 gives \displaystyle (0, \frac{1}{2} \mid -\frac{7}{2}, 1), then 2R_2 and \displaystyle R_1 - \frac{1}{2}R_2. The formula agrees: \det = 8 - 7 = 1.
- \begin{bmatrix} 1 & -2 & 5 \\ 0 & 1 & -3 \\ 0 & 0 & 1 \end{bmatrix}. Only upward clearing: R_2 - 3R_3, R_1 - R_3, then R_1 - 2R_2.
- \begin{bmatrix} 5 & -2 & 2 \\ -4 & 2 & -1 \\ -2 & 1 & -1 \end{bmatrix}. R_2 - 2R_1 gives (0, 1, -1 \mid -2, 1, 0); R_3 - R_2 gives (0, 0, -1 \mid 2, -1, 1); then -R_3 and clear upward.
- \displaystyle \begin{bmatrix} -\frac{1}{2} & \frac{1}{4} & \frac{1}{2} \\ \frac{1}{2} & -\frac{1}{4} & \frac{1}{2} \\ \frac{1}{2} & \frac{1}{4} & -\frac{1}{2} \end{bmatrix}. Start with R_1 \leftrightarrow R_3; the determinant is 4, hence the quarters.
- R_2 - 2R_1 and R_3 - R_1 both give (0, 3, -3); then R_3 - R_2 gives a zero row with (1, -1, 1) on the right: (1, -1, 2) - (2, 1, 1) + (1, 2, -1) = (0, 0, 0).
- \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 4 & 0 & 1 \end{bmatrix}, undone by \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ -4 & 0 & 1 \end{bmatrix}, the operation R_3 - 4R_1 \to R_3.
- R_2 \leftrightarrow R_3; the product is \begin{bmatrix} 1 & 2 \\ 5 & 6 \\ 3 & 4 \end{bmatrix}.
- \displaystyle A^{-1} = \begin{bmatrix} 1 & -3 \\ 0 & 1 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ -1 & 1 \end{bmatrix}\begin{bmatrix} \frac{1}{2} & 0 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} 2 & -3 \\ -\frac{1}{2} & 1 \end{bmatrix}. A is the product of the inverses in reverse order: \begin{bmatrix} 2 & 0 \\ 0 & 1 \end{bmatrix}\begin{bmatrix} 1 & 0 \\ 1 & 1 \end{bmatrix}\begin{bmatrix} 1 & 3 \\ 0 & 1 \end{bmatrix}.
- A = \begin{bmatrix} 2 & 1 & 0 \\ 1 & 1 & 1 \\ 0 & 1 & 1 \end{bmatrix}, A^{-1} = \begin{bmatrix} 0 & 1 & -1 \\ 1 & -2 & 2 \\ -1 & 2 & -1 \end{bmatrix}. Start with R_1 \leftrightarrow R_2 for a pivot of 1.
- A^{-1}(7, 6, 4) = (2, 3, 1): 2 spoons of plum, 3 of umber, 1 of rose. Check: (4, 2, 0) + (3, 3, 3) + (0, 1, 1) = (7, 6, 4).
- No. A^{-1}(3, 3, 1) = (2, -1, 2) needs -1 spoon of umber.
- No. The columns of A^{-1}, the recipes for 1 gram of cyan, magenta and yellow alone, are (0, 1, -1), (1, -2, 2) and (-1, 2, -1); each has a negative entry.
- Every \displaystyle c \neq \frac{8}{3}. R_3 - 2R_1 gives (0, c - 4, 4 - 2c), and R_3 - (c - 4)R_2 gives (0, 0, 8 - 3c).
- \begin{bmatrix} 1 & 0 & 0 \\ -a & 1 & 0 \\ ac - b & -c & 1 \end{bmatrix}. R_2 - aR_1 and R_3 - bR_1, then R_3 - cR_2 leaves (-b + ac, -c, 1) on the right of row 3.
- \begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}: R_2 - 2R_1 gives a zero row.
- If A\mathbf{x} = \mathbf{0} then \mathbf{x} = BA\mathbf{x} = \mathbf{0}, so no variable is free and every column has a pivot. Square with n pivots, A reduces to I, so A^{-1} exists, and B = B(AA^{-1}) = (BA)A^{-1} = A^{-1}.
- The diagonal entries are the pivots, none 0. Reduction needs only row scalings and adding multiples of lower rows to higher ones, and each such elementary matrix is upper triangular. A product of upper triangular matrices is upper triangular, so A^{-1} = E_k \cdots E_1 is too.
- B = BI = B(AC) = (BA)C = IC = C, by the associative property. Any route ending in [I \mid E] gives EA = I = AE, and only one matrix does that.