Skip to content

The inverse matrix

Watch a matrix move the grid and its inverse move it back, find the inverse two ways, and see when no undo exists.

Helps to know first
This topic

First, the picture

A matrix moves every point of the plane. Can another matrix move them all back? Watch the grid warp, then play back home.

Undoing a matrix

The grid goes where the matrix sends it, then the inverse brings it back.

The square grid and the unit arrows, before the matrix acts.

a_11 a_22 − a_12 a_21
3
0.00 / 10.50 s
Describe this picture

One panel with a faint square grid, the two unit arrows and the unit square shaded. First the grid glides to the place the matrix A=[2−111]\mathbf{A}=\begin{bmatrix}2&-1\\1&1\end{bmatrix} sends it, with the unit arrows riding out to the columns (2,1)(2,1) and (−1,1)(-1,1). Then it plays back, under the inverse, until it is the square grid again, and dashed arrows show where the two unit arrows went, with a ring on each tip. When the clip has finished, either tip can be dragged, or moved with the arrow keys in steps of half a unit, and the panel shows the grid under the matrix as it is changed. As one column is pulled towards the line of the other, the grid squeezes towards a single line, and a readout of the number a11a22−a12a21a_{11}a_{22}-a_{12}a_{21} falls towards 0. On the line itself the grid is flat; press Play, and the playback has nothing to restore.

Undo

In A matrix moves the plane, the matrix A\mathbf{A} above sent the point (3,2)(3,2) to (4,5)(4,5). The undo must send (4,5)(4,5) back to (3,2)(3,2), and do the same for every other point. A matrix that does this is the inverse of A\mathbf{A}, written A−1\mathbf{A}^{-1}:

A−1A=I,AA−1=I.\mathbf{A}^{-1}\mathbf{A}=\mathbf{I},\qquad \mathbf{A}\mathbf{A}^{-1}=\mathbf{I}.

Here I\mathbf{I} is the identity matrix of Matrix multiplication, the map that leaves every point where it is. Doing A\mathbf{A} and then A−1\mathbf{A}^{-1} leaves every point where it started. So does doing them in the other order.

For this matrix,

A−1=13[11−12].\mathbf{A}^{-1}=\frac13\begin{bmatrix}1&1\\-1&2\end{bmatrix}.

Check it on the point: A−1(4,5)=13 (4+5, −4+10)=(3,2)\mathbf{A}^{-1}(4,5)=\tfrac13\,(4+5,\ -4+10)=(3,2). That is also the answer to the system 2x−y=42x-y=4, x+y=5x+y=5 of Two pictures of a linear system. Once you know A−1\mathbf{A}^{-1}, the solution of Ax=b\mathbf{A}\mathbf{x}=\mathbf{b} is x=A−1b\mathbf{x}=\mathbf{A}^{-1}\mathbf{b}.

Notice what the inverse is not. It is not the matrix of reciprocals, 1/21/2, −1-1, 11 and 11. The undo has to reverse the whole map, not each number on its own.

Finding it by elimination

Where does A−1\mathbf{A}^{-1} come from? Its first column is where e1=(1,0)\mathbf{e}_1=(1,0) lands under the undo. That is the x\mathbf{x} that A\mathbf{A} sends to e1\mathbf{e}_1, so it solves Ax=e1\mathbf{A}\mathbf{x}=\mathbf{e}_1. The second column solves Ax=e2\mathbf{A}\mathbf{x}=\mathbf{e}_2.

So solve both systems at once. Write A\mathbf{A} with I\mathbf{I} beside it, and run the elimination of Elimination on the whole wide table. This time keep going: clear above each pivot as well as below, then divide each row by its pivot. When the left half has become I\mathbf{I}, the right half is A−1\mathbf{A}^{-1}. This is called Gauss–Jordan elimination.

[2−1101101]→[2−11001.5−0.51]→[20232301.5−0.51]→[10131301−1323].\begin{aligned} &\left[\begin{array}{cc|cc}2&-1&1&0\\1&1&0&1\end{array}\right] \to \left[\begin{array}{cc|cc}2&-1&1&0\\0&1.5&-0.5&1\end{array}\right]\\ \to{}&\left[\begin{array}{cc|cc}2&0&\tfrac23&\tfrac23\\0&1.5&-0.5&1\end{array}\right] \to \left[\begin{array}{cc|cc}1&0&\tfrac13&\tfrac13\\0&1&-\tfrac13&\tfrac23\end{array}\right]. \end{aligned}

The steps are: take 12\tfrac12 of row 1 from row 2; add 23\tfrac23 of row 2 to row 1; divide row 1 by 2 and row 2 by 1.5.

The 2 × 2 formula

For a 2×22\times2 matrix there is a short cut. Swap the two numbers on the diagonal, change the sign of the other two, and divide everything by one number:

[a11a12a21a22]−1=1a11a22−a12a21[a22−a12−a21a11].\begin{bmatrix}a_{11}&a_{12}\\a_{21}&a_{22}\end{bmatrix}^{-1} =\frac{1}{a_{11}a_{22}-a_{12}a_{21}}\begin{bmatrix}a_{22}&-a_{12}\\-a_{21}&a_{11}\end{bmatrix}.

For our A\mathbf{A}, the number is 2⋅1−(−1)⋅1=32\cdot1-(-1)\cdot1=3, and the formula gives the 13[11−12]\tfrac13\begin{bmatrix}1&1\\-1&2\end{bmatrix} above. Check one entry of A−1A\mathbf{A}^{-1}\mathbf{A}: row 1 of A−1\mathbf{A}^{-1} times column 1 of A\mathbf{A} is 13⋅2+13⋅1=1\tfrac13\cdot2+\tfrac13\cdot1=1. Row 1 times column 2 is 13⋅(−1)+13⋅1=0\tfrac13\cdot(-1)+\tfrac13\cdot1=0.

The number a11a22−a12a21a_{11}a_{22}-a_{12}a_{21} is the determinant of the matrix, written det⁡A\det\mathbf{A}. Here it is 3, which is the area of the parallelogram the unit square became in the first picture. The page The determinant as area explains why.

When there is no undo

Now drag a column, after the clip, towards the line of the other column. The grid squeezes, and when the two columns line up it is flat: the whole plane has landed on one line.

Take [1224]\begin{bmatrix}1&2\\2&4\end{bmatrix}, whose columns (1,2)(1,2) and (2,4)(2,4) lie on one line. It sends (2,−1)(2,-1) to 2 (1,2)−1 (2,4)=(0,0)2\,(1,2)-1\,(2,4)=(0,0). It sends (0,0)(0,0) to (0,0)(0,0) as well. Two different points land on the same spot, and no undo can send that spot back to both of them. So this matrix has no inverse. The formula agrees: its determinant is 1⋅4−2⋅2=01\cdot4-2\cdot2=0, and the formula would divide by zero.

The same reasoning works for any square matrix. If Ax=0\mathbf{A}\mathbf{x}=\mathbf{0} for some x\mathbf{x} that is not 0\mathbf{0}, then x\mathbf{x} and 0\mathbf{0} land together, and A\mathbf{A} has no inverse. So not every square matrix has one. Those that do are called invertible.

Undo in reverse order

In the morning you put on socks, then shoes. To undo it, you take off the shoes first, then the socks. Matrices work the same way.

Socks and shoes

Two moves, then their undoing, last move first.

Two moves, then their undoing. Watch the order of the undoing.

tip of e_1
(1, 0)
tip of e_2
(0, 1)
0.00 / 20.00 s
Describe this picture

The square grid with a small letter F drawn on it. It turns a quarter turn under Arot\mathbf{A}_\text{rot}, then shears under Ashear\mathbf{A}_\text{shear}. Then it comes back: first the shear is undone, then the turn, and the grid and the letter are home again. A caption names each step as it plays. The picture has no control.

Take the turn and the shear of Matrix multiplication: Arot=[0−110]\mathbf{A}_\text{rot}=\begin{bmatrix}0&-1\\1&0\end{bmatrix} turns by 90°, which is π/2\pi/2 radians, and Ashear=[1101]\mathbf{A}_\text{shear}=\begin{bmatrix}1&1\\0&1\end{bmatrix} shears. Turning first and then shearing is AshearArot=[1−110]\mathbf{A}_\text{shear}\mathbf{A}_\text{rot}=\begin{bmatrix}1&-1\\1&0\end{bmatrix}, since the first map is written on the right. To undo it, undo the shear first, then the turn:

(AshearArot)−1=Arot−1Ashear−1=[01−10][1−101]=[01−11].(\mathbf{A}_\text{shear}\mathbf{A}_\text{rot})^{-1}=\mathbf{A}_\text{rot}^{-1}\mathbf{A}_\text{shear}^{-1} =\begin{bmatrix}0&1\\-1&0\end{bmatrix}\begin{bmatrix}1&-1\\0&1\end{bmatrix} =\begin{bmatrix}0&1\\-1&1\end{bmatrix}.

Here Arot−1\mathbf{A}_\text{rot}^{-1} turns back by 90° and Ashear−1\mathbf{A}_\text{shear}^{-1} shears back. The other order, Ashear−1Arot−1=[11−10]\mathbf{A}_\text{shear}^{-1}\mathbf{A}_\text{rot}^{-1}=\begin{bmatrix}1&1\\-1&0\end{bmatrix}, is a different matrix, and it does not undo AshearArot\mathbf{A}_\text{shear}\mathbf{A}_\text{rot}. In general,

(AB)−1=B−1A−1.(\mathbf{A}\mathbf{B})^{-1}=\mathbf{B}^{-1}\mathbf{A}^{-1}.

One more rule. The transpose A⊤\mathbf{A}^\top of a matrix swaps its rows and columns, as Transposes and permutations explains. The inverse of the transpose is the transpose of the inverse: (A⊤)−1=(A−1)⊤(\mathbf{A}^\top)^{-1}=(\mathbf{A}^{-1})^\top. For the turn, the inverse happens to be the transpose itself: Arot−1=[01−10]=Arot⊤\mathbf{A}_\text{rot}^{-1}=\begin{bmatrix}0&1\\-1&0\end{bmatrix}=\mathbf{A}_\text{rot}^\top.

Solve, don’t invert

The formula x=A−1b\mathbf{x}=\mathbf{A}^{-1}\mathbf{b} is good for thinking, but computer programs rarely use it. Finding A−1\mathbf{A}^{-1} for an n×nn\times n matrix takes about n3n^3 multiply-and-subtract steps. Solving Ax=b\mathbf{A}\mathbf{x}=\mathbf{b} by elimination takes about n3/3n^3/3. Elimination is also less disturbed by rounding errors. So a program that needs A−1b\mathbf{A}^{-1}\mathbf{b} solves the system instead, and keeps the steps of elimination for the next b\mathbf{b}, as LU factorisation shows.

Worked example

  1. The inverse. A=[2−111]\mathbf{A}=\begin{bmatrix}2&-1\\1&1\end{bmatrix} has det⁡A=3\det\mathbf{A}=3 and A−1=13[11−12]\mathbf{A}^{-1}=\tfrac13\begin{bmatrix}1&1\\-1&2\end{bmatrix}.
  2. Solving with it. A−1(4,5)=(9/3, 6/3)=(3,2)\mathbf{A}^{-1}(4,5)=(9/3,\ 6/3)=(3,2).
  3. Another one. [1234]\begin{bmatrix}1&2\\3&4\end{bmatrix} has determinant 1⋅4−2⋅3=−21\cdot4-2\cdot3=-2, so its inverse is −12[4−2−31]=[−211.5−0.5]-\tfrac12\begin{bmatrix}4&-2\\-3&1\end{bmatrix}=\begin{bmatrix}-2&1\\1.5&-0.5\end{bmatrix}.
  4. No inverse. [1224]\begin{bmatrix}1&2\\2&4\end{bmatrix} has determinant 0 and sends (2,−1)(2,-1) to 0\mathbf{0}.
  5. The quarter turn. Its inverse is the quarter turn the other way, 90° clockwise, which is its transpose.
  6. A test. If Ax=0\mathbf{A}\mathbf{x}=\mathbf{0} has a solution x≠0\mathbf{x}\neq\mathbf{0}, can A\mathbf{A} be invertible? No: A−1\mathbf{A}^{-1} would send 0\mathbf{0} to both x\mathbf{x} and 0\mathbf{0}.
  7. Predict. As one column nears the line of the other, what happens to the playback? The grid squeezes, and the undo has to stretch it back more and more, without limit.

Where you’ll meet this

The stereo crossfeed of A matrix moves the plane mixed the channels with [0.70.30.30.7]\begin{bmatrix}0.7&0.3\\0.3&0.7\end{bmatrix}. Its determinant is 0.49−0.09=0.400.49-0.09=0.40, and its inverse is [1.75−0.75−0.751.75]\begin{bmatrix}1.75&-0.75\\-0.75&1.75\end{bmatrix}, which unmixes them. Notice the cost: a difference between the channels, (1,−1)(1,-1), comes out as (2.5,−2.5)(2.5,-2.5). Any noise in the mixed sound that differs between the channels is made 2.5 times larger. The page Conditioning measures this effect.

A game finds the object under the mouse pointer by running the camera’s matrix backwards, from the screen into the scene. That is an inverse.

In signal processing · inverses in filters

Filters often rest on a small system or an inverse. In Resampling by any factor, the cubic through four samples comes from solving one 4×44\times4 system once. In RLS and the Kalman filter, an inverse is never recomputed from scratch: when one small piece is added to a matrix, its inverse changes by one small piece too. That rule is called the matrix inversion lemma.

Reference card

QuantityFormulaNotes
InverseA−1A=AA−1=I\mathbf{A}^{-1}\mathbf{A}=\mathbf{A}\mathbf{A}^{-1}=\mathbf{I}the undo
Solutionx=A−1b\mathbf{x}=\mathbf{A}^{-1}\mathbf{b}compute by elimination instead
Gauss–Jordan[ A∣I ]→[ I∣A−1 ][\,\mathbf{A}\mid\mathbf{I}\,]\to[\,\mathbf{I}\mid\mathbf{A}^{-1}\,]clear above and below each pivot
2 × 21a11a22−a12a21[a22−a12−a21a11]\dfrac{1}{a_{11}a_{22}-a_{12}a_{21}}\begin{bmatrix}a_{22}&-a_{12}\\-a_{21}&a_{11}\end{bmatrix}swap, change signs, divide
Determinantdet⁡A=a11a22−a12a21\det\mathbf{A}=a_{11}a_{22}-a_{12}a_{21}0 means no inverse
No inverseAx=0\mathbf{A}\mathbf{x}=\mathbf{0} with x≠0\mathbf{x}\neq\mathbf{0}the map flattens
Product(AB)−1=B−1A−1(\mathbf{A}\mathbf{B})^{-1}=\mathbf{B}^{-1}\mathbf{A}^{-1}reverse order
Transpose(A⊤)−1=(A−1)⊤(\mathbf{A}^\top)^{-1}=(\mathbf{A}^{-1})^\top
Costinverse ≈n3\approx n^3, solve ≈n3/3\approx n^3/3solve, don’t invert

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look