Linear Algebra, Live
Strang §2.5 · The 2 by 2 inverse

The 2 by 2 inverse: swap, flip signs, divide by ad − bc

Slide 1 showed what an inverse does: it undoes A. Now we find it. For a 2 by 2 matrix there is a short recipe with three moves. Swap the two numbers on the diagonal, put a minus sign on the other two, and divide everything by one number, ad − bc. That number is called the determinant. Think of checking the fuel gauge before a drive: one glance tells you whether the trip can start. Here the glance is ad − bc. If it is not 0, the recipe gives A⁻¹. If it is 0, the recipe would divide by zero, and A has no inverse at all.

Lesson 3 · slide 22 × 2 inverse
abcd⁻¹ = 1/(ad − bc) · d−b−ca
Key ideas
  1. A⁻¹ = 1/(ad − bc) times d−b−ca: swap a and d, flip the signs of b and c, divide by ad − bc.
  2. The number ad − bc is the determinant of A, written det A. For now it means one thing: it says whether a 2 by 2 inverse exists.
  3. A times d−b−ca is (ad − bc)I, so dividing by ad − bc leaves I.
  4. If ad − bc = 0 there is no inverse: the columns lie on one line.
  5. Always check the answer by multiplying: AA⁻¹ should be I.

The recipe

abcd⁻¹ = 1/(ad − bc) · d−b−ca

Swap a and d. Flip the signs of b and c. Divide everything by ad − bc. Here are the three moves on A = 1234, where ad − bc = 1·4 − 2·3 = −2:

swap the diagonal: 4231  →  flip the other signs: 4−2−31  →  divide by −2: −211.5−0.5
The circles mark the entries each move changes. One swap, two sign flips, one division, and the inverse is done.

Why it works

Multiply A by the swapped-and-flipped matrix, before dividing:

abcdd−b−ca = ad − bc−ab + bacd − dc−cb + da = ad − bc00ad − bc
= (ad − bc) I

The off-diagonal entries cancel. Both diagonal entries are ad − bc. So the product is ad − bc times I. Divide by ad − bc and you get I. With numbers, for A = 1234:

12344−2−31 = 4 − 6−2 + 212 − 12−6 + 4 = −200−2 = −2·I
Watch the two corners off the diagonal come out 0. Both diagonal numbers are −2, which is ad − bc. Dividing by −2 turns the product into I.

The determinant: one number that says yes or no

The number ad − bc is called the determinant of A, written det A. In this lesson it has one job: it tells you whether a 2 by 2 matrix has an inverse. If ad − bc ≠ 0, the recipe works. If ad − bc = 0, the recipe would divide by zero, and there is no inverse.

2153: 2·3 − 1·5 = 1  →  inverse exists    2412: 2·2 − 4·1 = 0  →  no inverse

What does ad − bc = 0 look like? Then ad = bc, and the columns ac and bd lie on one line: one is a multiple of the other. For 2412, column 2 = 2·column 1. That is the case from slide 1, where one column is a multiple of the other: two different inputs give the same output, so nothing can undo A.

The rows tell the same story. Pick any right side, say 4 and 1. As equations, 2x + 4y = 4 and x + 2y = 1 have lines with the same slope. They never cross, so this system has no solution at all:

The two equations 2x + 4y = 4 and x + 2y = 1, drawn as lines. They are parallel and never meet. When ad − bc = 0, the lines are parallel or the same line, and there is never exactly one answer.

The determinant has much more to say. Lesson 6 shows what it measures in pictures. For now, remember it as the yes-or-no number for a 2 by 2 inverse.

A worked example

A = 2153   det A = 2·3 − 1·5 = 1
A⁻¹ = 1/1 · 3−1−52
Check: AA⁻¹ = 6 − 5−2 + 215 − 15−5 + 6 = 1001 ✓
A times the answer, one row and one column at a time. The product is I, so the answer is right.

Now use it. To solve 2x + y = 1 and 5x + 3y = 2, multiply b = 12 by A⁻¹:

x = A⁻¹b = 3·1 − 1·2−5·1 + 2·2 = 1−1
Check: 2·1 + (−1) = 1 ✓   5·1 + 3·(−1) = 2 ✓

Common mistakes

  • Swapping b and c. Only the diagonal entries, a and d, trade places.
  • Flipping the signs of a and d. Only b and c change sign.
  • Forgetting to divide by det A. The worked example hides this, since det A = 1. The recipe demo at the top, A = 1234 with det A = −2, does not hide it: there you must divide by −2.

A bigger example: a 3 × 3 built from a 2 × 2

The recipe is only for 2 by 2. But it still helps when the top-left 2 by 2 corner of a 3 by 3 matrix has only zeros beside it and below it, so it never mixes with the third row and column:

B = 210530004    B⁻¹ = 3−10−52000¼
Row 1 of BB⁻¹: 2·3 + 1·(−5)2·(−1) + 1·20 = 100
Row 2: 5·3 + 3·(−5)5·(−1) + 3·20 = 010   Row 3: 004·¼ = 001 ✓

The top-left corner is the A from the worked example, so its inverse goes in the same corner, and the 4 is undone by ¼. For a general 3 by 3, or a 1000 by 1000, there is no short recipe worth using: the inverse comes from elimination, on slide 4.

Next: We can now undo one matrix. What if A and B are done one after the other? Slide 3 finds the inverse of a product AB, and the order turns out to flip.

Examples

Example 1 · Determinant 1

A = 2312, det A = 4 − 3 = 1.

Show solutionHide solution
A⁻¹ = 2−3−12

Example 2 · Determinant −2

A = 1234, det A = 4 − 6 = −2.

Show solutionHide solution
A⁻¹ = −½ · 4−2−31 = −211.5−0.5

Example 3 · No inverse

A = 2412, det A = 4 − 4 = 0.

Show solutionHide solution
The formula would divide by 0. Column 2 = 2·column 1, and A has no inverse

Example 4

Invert 4231.

Show solutionHide solution

det = 4 − 6 = −2. Inverse = −½·1−2−34 = −0.511.5−2.

Example 5

For which t is t14t invertible?

Show solutionHide solution

det = t² − 4. Invertible for every t except t = 2 and t = −2.

Exercise In A_inv, replace the entries [[1., 0.], [0., 1.]] with [[d, -b], [-c, a]]. The division by det is already in the code. Edit the code and press Run.
slide_2.py Loading Python…
1
Output · Ctrl+Enter runs
Press Run to execute this slide's code. Ctrl+Enter works too.

Enjoying lesson 3? Get the full course: all 8 lessons through the SVD and PCA, your progress saved lesson by lesson, every solution and 5 extra problems per lesson. $20 once, yours for life.

Questions and comments

Stuck on something, or found a mistake? Ask here and I'll answer. You sign in with GitHub.

The full course

From Ax = b to PCA, by running it

Lessons 1 to 3 are free. Finish all eight and you will be able to:

You get: all 8 lessons with Python labs · every worked example and solution · 5 extra problems per lesson · your progress tracked · answers to your questions · every future update.

$20 once · lifetime access
Continue to checkout →

Already a member? Log in to the course