The inverse matrix, explained with pictures
A matrix can stretch, shear, rotate or flip the plane. The inverse matrix is the matrix that undoes it. Change the plane, then change it back.
Short answer. The inverse matrix is the matrix that undoes what a matrix does. If you do A and then A⁻¹, it is the same as doing nothing (the identity matrix). If the determinant is 0, the plane gets squashed flat and cannot be undone, so there is no inverse.
Left column = where î goes, right column = where ĵ goes
The dashed square and the gray circles show where things were before the change. Press "Apply A" to change the plane, then "Undo (A⁻¹)" to put it back. You can change A by dragging the circles at the arrow tips or by typing numbers.
Definitions
The page below uses 2×2 matrices, but the definitions are the same for n×n matrices. is the n×n identity matrix.
- inverse matrix
- If, for an n×n matrix A, there is an n×n matrix B that meets the equation below, A is invertible, and B is the inverse of A, written . If an inverse exists, there is only one.
- singular matrix
- A square matrix with no inverse is a singular matrix (a noninvertible matrix). A square matrix A is invertible if and only if its determinant is not 0.
- inverse of a 2×2 matrix
- If ad − bc ≠ 0, the inverse is given below. If ad − bc = 0, there is no inverse.
- inverse and systems of linear equations
- If A is an invertible n×n matrix, then for every vector b with n entries, has exactly one solution, given below.
1. The inverse is the matrix that undoes
Start with plain numbers. 3 times 1/3 is 1. Multiplying by 1 changes nothing. So 1/3 is "the number that undoes multiplying by 3." It is called the reciprocal of 3.
Matrices work the same way. The matrix that plays the part of 1 is the identity matrix I = 1 0 / 0 1. It sends î to î and ĵ to ĵ, so the plane stays as it is. The inverse of a matrix A, written A⁻¹, is the matrix that gives I when you multiply it with A.
In pictures: after A changes the plane, doing A⁻¹ puts every point back where it started. In the lab, press "Apply A" and then "Undo (A⁻¹)." The numbered points go back to the gray circles (where they started). Only matrices with the same number of rows and columns (square matrices) can have an inverse in this sense.
Try this. ① The A⁻¹ of "Double" is 0.5 0 / 0 0.5. Something made twice as big goes back when you halve it. ② The A⁻¹ of "Rotate 30°" is 0.87 0.5 / −0.5 0.87, which is a 30° turn the other way. ③ The A⁻¹ of "Flip" is −1 0 / 0 1, the same as A. Flip it once more and it is back. ④ The A⁻¹ of "Shear" (1 1 / 0 1) is 1 −1 / 0 1, a lean the other way.
2. The formula for a 2×2 inverse
If the matrix is A = a b / c d, its inverse is:
To see where this formula comes from, step by step in pictures, go to 3. How the formula is built.
- Find the determinant
a×d − b×c. If it is 0, stop here. There is no inverse. - Swap a and d.
- Change the signs of b and c (put a minus in front).
- Divide all four numbers by the determinant.
Why divide by the determinant? A multiplies every area by the determinant (see determinant). If you do only steps 2 and 3 and multiply the result d −b / −c a with A, you get (ad − bc) 0 / 0 (ad − bc), which is "determinant × I." So dividing by the determinant at the end gives exactly I.
3. How the formula is built: the 2×2 inverse
You do not have to memorize the formula above. You can build it. We are looking for the matrix X with A × X = I. Matrix multiplication works on each column of the right matrix separately, so we can split X into its two columns and find them one at a time. The key is one fact from the determinant page: A multiplies every area by its determinant (ad − bc).
Here we use A = 3 1 / 1 1. Its determinant is 3×1 − 1×1 = 2, so you can see areas double. The lab's starting A (2 1 / 1 1) has determinant 1, so areas stay the same and this is hard to see.
Green and blue arrows: where A sends î and ĵ. Purple dots: the columns we look for. Orange circles: where they must land. Shaded parallelogram: the area we measure (orange if negative).
Press "Next" to go one step at a time. In the formula, the orange cells are the ones filled in at this step. The picture applies A as far as that step needs.
The steps above, written only as formulas. Call the four cells of the A⁻¹ we want p, q, r and s, and write each ratio of areas as a ratio of determinants. The last line uses the A of this section.
In formulas, (1, 0) and (0, 1) are written standing up as columns. They are the same vectors.
Areas with a sign. We measure the area of the parallelogram made by two arrows u and v as (u across × v up) − (v across × u up). This is the same sum as the determinant. If you turn counterclockwise to get from u to v, the area is positive. If you turn clockwise, it is negative. That is why the area in step 3 is negative.
At the last step you can see where the moves in section 2 come from (swap a and d, change the signs of b and c, divide by the determinant). Solving equations with ratios of areas like this is called Cramer's rule (Wikipedia: Cramer's rule). The fact that A multiplies every area by its determinant comes from the pictures on the determinant page. We do not prove it again here.
Try this. Type 3 1 / 1 1 into the number boxes of the lab at the top. The A⁻¹ boxes show 0.5 −0.5 / −0.5 1.5, the same as in step 5.
4. Work it out by hand
Let us find the inverse of A = 2 1 / 1 1. This is the A you see when you first open the lab.
- Determinant:
2×1 − 1×1 = 1. It is not 0, so there is an inverse. - Swap a and d:
1 1 / 1 2. - Change the signs of b and c:
1 −1 / −1 2. - Divide by the determinant, 1:
A⁻¹ = 1 −1 / −1 2.
The same work written as formulas:
Check: is A × A⁻¹ equal to I?
To multiply matrices, pair a row of the left matrix with a column of the right matrix. Multiply the matching numbers and add them up.
| Spot | Work | Value |
|---|---|---|
| Top left | 2×1 + 1×(−1) | 1 |
| Top right | 2×(−1) + 1×2 | 0 |
| Bottom left | 1×1 + 1×(−1) | 0 |
| Bottom right | 1×(−1) + 1×2 | 1 |
We got 1 0 / 0 1, the identity matrix. The "Check" line in the lab does this same multiplication for real.
Check with one point
A sends the point (1, 2) to (2×1 + 1×2, 1×1 + 1×2) = (4, 3). A⁻¹ sends (4, 3) back to (1×4 − 1×3, −1×4 + 2×3) = (1, 2). It is back where it started.
Try this. When the determinant is not 1, step 4 matters. "Double" has determinant 4, so its inverse is (1 ÷ 4) × [2 0 / 0 2] = 0.5 0 / 0 0.5. The lab's explanation line shows exactly this work.
5. When there is no inverse
The number 0 has no reciprocal. Nothing times 0 gives 1. For matrices, a matrix whose determinant is 0 has no inverse. Such a matrix is called a singular matrix.
The picture shows why. If the determinant is 0, A presses the whole plane onto a line (or a single point). Then different points land on the same spot. Looking at one of those spots, you cannot tell which point it came from. There is no single way to undo it, so there is no inverse. In the formula, step 4 would mean dividing by 0, which you cannot do.
There is one difference from numbers. With numbers, only 0 has no reciprocal. A matrix can have no inverse even when none of its numbers is 0. "Squash" (1 2 / 0.5 1) has no 0 in it, but its determinant is 0.
Try this. ① Press "Squash." The plane is pressed onto a line. Points 1 and 2 meet at one spot, and points 3 and 4 meet at another. The "Undo" button turns off. ② Type 1 0.9 / 1.1 1 into the number boxes. The determinant is 0.01, almost 0. There is an inverse, but its numbers get very big: 100 −90 / −110 100. To spread out something that is almost flat, you have to stretch it a lot.
6. Properties to know
| Property | Formula | In plain words |
|---|---|---|
| Either order gives I | A × A⁻¹ = A⁻¹ × A = I | Do A first or A⁻¹ first. After both, everything is back in place |
| There is only one | If A × X = I, then X = A⁻¹ | There is exactly one matrix that undoes A |
| Undo the undo | (A⁻¹)⁻¹ = A | The inverse of A⁻¹ is A again |
| Area goes the other way | det(A⁻¹) = 1 ÷ det(A) | If A makes areas 4 times as big, A⁻¹ makes them 1/4 as big |
| Order is reversed | (AB)⁻¹ = B⁻¹A⁻¹ | Socks on, then shoes on. To take them off, shoes come off first |
Socks and shoes
The product AB means do B first, then A. The matrix on the right touches the point first. Say you put on socks (B), then shoes (A) over them. To take them off, you remove the shoes first (A⁻¹), then the socks (B⁻¹). That is why (AB)⁻¹ = B⁻¹A⁻¹. Here too, the A⁻¹ on the right happens first.
Check: (A×B) × (B⁻¹×A⁻¹) = A × (B×B⁻¹) × A⁻¹ = A × A⁻¹ = I.
With numbers: let A be the shear 1 1 / 0 1 and B be "twice as wide" 2 0 / 0 1. Then (AB)⁻¹ and B⁻¹A⁻¹ are both 0.5 −0.5 / 0 1. The other order, A⁻¹B⁻¹, is 0.5 −1 / 0 1, which is different. With matrices, changing the order often changes the answer.
7. Solving equations with the inverse
The equations 2x + y = 5 and x + y = 3 can be written with a matrix as A × (x, y) = (5, 3). A is the 2 1 / 1 1 from section 4. The question is: "A sent some point to (5, 3). Which point was it?"
Undo what A did. Multiply both sides by A⁻¹: (x, y) = A⁻¹ × (5, 3) = (1×5 − 1×3, −1×5 + 2×3) = (2, 1). Check: 2×2 + 1 = 5 and 2 + 1 = 3. Correct.
In short, if Ax = b, then x = A⁻¹b. If the inverse exists, there is exactly one answer.
But computers usually do not find the inverse to solve equations. Solving directly with elimination takes less work and is usually more accurate. Elimination is the next topic: Linear systems and elimination.
Where is it used?
- Going back to the original coordinates. Say you scaled and rotated a picture before drawing it on screen. To find which spot in the original picture a mouse click hit, multiply by the inverse of that change. The browser's
DOMMatrixhas aninverse()method for this. - The camera in graphics. In 3D graphics, moving the camera to the right looks the same as moving the whole world to the left. So programs take the matrix that holds the camera's position and direction, and draw the world moved by its inverse. That matrix is called the view matrix. 3D uses 4×4 matrices.
- Regression in statistics. The formula for the line that best fits a set of points (least squares) has the form
(XᵀX)⁻¹Xᵀy, with an inverse inside. Xᵀ is X with its rows and columns swapped. The formula is written this way, but real programs usually compute it with methods that do not find the inverse directly. - Systems of equations. As in section 7, you can write the answer as
x = A⁻¹b. Just knowing whether the inverse exists tells you whether there is exactly one answer.
Common questions
What is an inverse matrix?
It is a matrix that undoes what another matrix does. If you do A and then A⁻¹, it is the same as doing nothing, which is the identity matrix I. It works like the number 3 and its reciprocal 1/3.
How do you find the inverse of a 2×2 matrix?
Find the determinant ad − bc. Swap a and d. Change the signs of b and c. Then divide all four numbers by the determinant. If the determinant is 0, there is no inverse.
Which matrices have no inverse?
Matrices whose determinant is 0. They press the plane onto a line or a single point, so different points land on the same spot. You cannot tell where each point came from, so you cannot undo it. Such a matrix is called a singular matrix.
Can I write A⁻¹ as 1/A?
No. With matrices, changing the order of a product often changes the answer. So "B divided by A" could mean A⁻¹B or BA⁻¹, and you could not tell which. Instead of dividing, you write which side A⁻¹ goes on.
Do I need the inverse to solve a system of equations?
No. On paper you can write x = A⁻¹b, but computers usually do not find the inverse. They solve the system directly with elimination. It takes less work and is usually more accurate.
Words
| Word used here | Word used in textbooks |
|---|---|
| matrix that undoes | inverse matrix. Written A⁻¹, read "A inverse" |
| matrix that does nothing | identity matrix. Written I |
| number that undoes a number (3 and 1/3) | reciprocal |
| matrix that can be undone | invertible matrix, nonsingular matrix |
| matrix that squashes the plane flat and cannot be undone | singular matrix |
| what area gets multiplied by | determinant. Written det A |
| matrix with a and d swapped and the signs of b and c changed | adjugate matrix. Written adj A |
| matrix with the same number of rows and columns | square matrix |
| matrix with rows and columns swapped | transpose. Written Xᵀ |
| multiplying matrices | matrix multiplication |
| solving equations with ratios of areas | Cramer's rule |