Skip to the lesson
FixTheRobot Explore Robotics / Linear Algebra / M2 Matrices and Linear Transformations / M2-T7

Linear Algebra · Theory · M2

M2-T7 — Inverse Matrices

The inverse undoes a transformation. It exists exactly when nothing was squashed, and in practice you should almost never compute it.

  • Lesson 7 of 7
  • Module 2: Matrices and Linear Transformations
  • Matrices
  • About 9 minutes to read

To convert a robot measurement back from the world frame to the sensor frame you undo the transformation. This lesson builds the undoing matrix, shows when it exists and how it behaves for a product, and explains the engineering advice to “solve, do not invert”.

Learning objectives

After this lesson, you should be able to:

  • Define the inverse matrix and state when it exists in terms of the determinant.
  • Compute and verify the inverse of a 2 × 2 matrix, and use it to solve a small system.
  • Derive (AB)⁻¹ = B⁻¹A⁻¹ and explain the reversal of order.
  • Explain why numerical software solves A x = b rather than computing A⁻¹ explicitly.

Introduction and motivation

Frames are connected by transformations, and you often need to go in the opposite direction: from the world frame back to the sensor, from a desired hand motion back to joint motion, from an observation back to the state that caused it. Going backwards is the job of the inverse. It exists only when the forward map lost no information, and numerically it is the first thing to approach with caution.

The intuition

If a matrix sends x to y, its inverse sends y back to x. Doing a transformation and then its inverse changes nothing: the pair multiplies to the identity matrix I.

When can an inverse exist? Only if every output came from exactly one input. A rotation or a stretch has this property: you can always undo it. A matrix that squashes the plane onto a line does not: many inputs land on the same output, and the information about which one it was is gone. The determinant is zero exactly in that case.

An inverse undoes a transformationA point x is sent to y by a matrix A. The inverse matrix A inverse sends y back to x. If the matrix squashes the plane, two different points land on the same output and no inverse can exist.xinput A y = A xoutput A⁻¹ A⁻¹ A = A A⁻¹ = I exists only if det A ≠ 0 (A B)⁻¹ = B⁻¹ A⁻¹ undo the last step first A singular A merges inputs, so there is nothing to undo.
The inverse sends the output back to the input. It exists exactly when the matrix does not collapse space.

Interactive figure. The unit square and an F-shaped outline are transformed by a two by two matrix. A toggle also shows the original F transformed by the inverse matrix. When the determinant is zero the figure reports that no inverse exists. This figure needs JavaScript to be interactive.

Turn on the “undo” option. The dashed shape is the original F pushed through M⁻¹, the transformation that cancels M. Then drag the handles until the determinant is zero and watch the inverse disappear.

Geometric and physical interpretation

Geometric view. The inverse of a transformation is the transformation that returns every point to where it started. A rotation by θ is undone by a rotation by −θ; a stretch by 2 is undone by a stretch by ½; a shear by k by a shear by −k. The determinant of the inverse is the reciprocal: if areas were multiplied by 5, undoing it divides them by 5. Physical view. Converting a world-frame measurement back into the sensor frame is applying the inverse of the sensor-to-world transform. For a rigid-body transform this inverse has a special, cheap form that you will derive in Module 7.

The mathematics

A⁻¹
the inverse of the square matrix A.
I
the identity matrix.
det A
the determinant: A⁻¹ exists exactly when det A ≠ 0.

Definition

A⁻¹ A = A A⁻¹ = I

What it means. Applying A and then A⁻¹ (or the other way round) does nothing. A matrix with such an inverse is called invertible or non-singular.

The 2 × 2 formula

[ a  b ]⁻¹        1       [  d  −b ]
[ c  d ]    =  -------   [ −c   a ]          (ad − bc ≠ 0)
               ad − bc

What it means. Swap the diagonal entries, flip the sign of the off-diagonal ones, and divide by the determinant. The division is why a zero determinant means no inverse.

Products and solving

(A B)⁻¹ = B⁻¹ A⁻¹          A x = b   ⇒   x = A⁻¹ b

What it means. To undo “B then A” you undo A first, then B. If A is invertible, the unique solution of A x = b is A⁻¹b, although software does not compute it that way.

An inverse undoes a transformation and exists exactly when det ≠ 0. For a product, invert each factor and reverse the order.

Step-by-step derivation: the 2 × 2 formula and the reversal of order

The 2 × 2 formula. Let A = [[a, b], [c, d]] and N = [[d, −b], [−c, a]]. Multiply:

A N = [ a·d + b·(−c)    a·(−b) + b·a ]  =  [ ad − bc      0     ]  =  (ad − bc) I
    [ c·d + d·(−c)    c·(−b) + d·a ]     [   0       ad − bc ]

What it means. The off-diagonal entries cancel and both diagonal entries equal ad − bc. So A N is the identity times the number ad − bc.

Dividing by ad − bc (possible only if it is not zero) gives A · (N/(ad − bc)) = I, so A⁻¹ = N/(ad − bc). If ad − bc = 0, then AN = 0 with N ≠ 0, so no inverse can exist: multiplying AN = 0 by a supposed A⁻¹ would give N = 0.

Reversal of order. We claim (AB)(B⁻¹A⁻¹) = I:

  1. (AB)(B⁻¹A⁻¹) = A (B B⁻¹) A⁻¹ by associativity.
  2. B B⁻¹ = I, so this is A I A⁻¹ = A A⁻¹.
  3. A A⁻¹ = I. So B⁻¹A⁻¹ is a right inverse of AB; for square matrices it is also a left inverse, hence (AB)⁻¹ = B⁻¹A⁻¹.

This matches common sense: to unwrap a parcel that was wrapped in paper (B) and then a box (A), you remove the box first and then the paper.

A worked example: invert, verify and solve

Let A = [[2, 1], [1, 3]].

  1. Determinant. det A = 2·3 − 1·1 = 5 ≠ 0, so A is invertible.
  2. Inverse. A⁻¹ = (1/5) [[3, −1], [−1, 2]] = [[0.6, −0.2], [−0.2, 0.4]].
  3. Verify. A A⁻¹: row 1 · column 1 = 2·0.6 + 1·(−0.2) = 1; row 1 · column 2 = 2·(−0.2) + 1·0.4 = 0; row 2 · column 1 = 1·0.6 + 3·(−0.2) = 0; row 2 · column 2 = 1·(−0.2) + 3·0.4 = 1. This is I.
  4. Solve. For A x = (3, 5): x = A⁻¹ (3, 5) = (0.6·3 − 0.2·5, −0.2·3 + 0.4·5) = (0.8, 1.4). Check: 2·0.8 + 1.4 = 3 and 0.8 + 3·1.4 = 5. ✓
  5. No inverse. [[1, 2], [2, 4]] has determinant 0 and the swap-negate matrix times it is the zero matrix, so no inverse exists.
  6. Rotation. The inverse of R(30°) is R(−30°), which equals its transpose: [[cos 30°, sin 30°], [−sin 30°, cos 30°]].

Robotics application

Back-transforming measurements. A transform W takes sensor coordinates to world coordinates; to express a world point in the sensor frame, apply W⁻¹. For a rigid-body transform the inverse is cheap and exact (a transpose and a short formula), see poses and frames and Module 7.

Mixed wheel and body quantities. The differential-drive matrix of the previous lessons can be inverted to find the wheel speeds that produce a commanded forward and turn velocity, provided its determinant (here proportional to r²/L) is not zero, which holds for any real robot with non-zero wheel radius and track width.

Inverse kinematics. In Module 8 you will ask: which joint velocities produce this hand velocity? That is the inverse of the Jacobian. It exists only when the Jacobian is square and its determinant is not zero, and it is where the engineering warnings of this lesson turn into physical problems: a nearly singular arm demands huge joint speeds.

Calibration and observability. Whether a sensor model can be inverted to recover a state is exactly an invertibility question, treated in Module 3 and in the estimation lessons of the UAV track.

Engineering implications and limitations

Practical rules

  • Solve, do not invert. To compute A⁻¹b use a solver (LU or QR). It is faster and noticeably more accurate than forming A⁻¹ and multiplying; Module 3 and Module 5 explain why.
  • Reuse the factorisation. If you solve against many right-hand sides with the same matrix, factor once and reuse it: that gets the benefit people hope to get from a stored inverse.
  • Test conditioning, not the determinant. A matrix whose columns are nearly parallel is invertible on paper but amplifies errors enormously. Check the condition number (Module 6).
  • Use the structure. Rotations invert by transposing, diagonal matrices by inverting each diagonal entry, rigid transforms by the cheap formula of Module 7. Do not call a general inverse on these.
  • Handle failure explicitly. A singular matrix should raise a clear error or switch to a safe fallback (for instance a pseudoinverse), not return infinities.

Limits

Only square matrices have an inverse in this sense. For rectangular and singular matrices the nearest substitute is the pseudoinverse (Module 6), which gives the best answer when an exact one does not exist.

Common misconceptions

“A⁻¹ means 1/A, entry by entry.”

The inverse is not the entrywise reciprocal. For [[2, 1], [1, 3]] the entrywise reciprocal is [[0.5, 1], [1, 0.33]], which is not the inverse [[0.6, −0.2], [−0.2, 0.4]].

“(AB)⁻¹ = A⁻¹B⁻¹.”

The order reverses: (AB)⁻¹ = B⁻¹A⁻¹. The wrong form has the right shape and runs without error.

“The best way to solve A x = b is to compute A⁻¹ and multiply.”

It is slower and less accurate than solving directly, and it hides the conditioning of the problem. Professional code solves systems.

“If the determinant is not exactly zero, the inverse is fine.”

A tiny non-zero determinant (relative to the scale) means the inverse exists but magnifies every error. Invertible is a yes/no question; well-conditioned is a how-much question.

Engineering takeaways

  1. The inverse A⁻¹ undoes A: A⁻¹A = AA⁻¹ = I. It exists exactly when det A ≠ 0.
  2. For 2 × 2: A⁻¹ = (1/(ad − bc)) [[d, −b], [−c, a]].
  3. The inverse of a product reverses the order: (AB)⁻¹ = B⁻¹A⁻¹.
  4. Rotations invert by transposing; diagonal matrices by inverting each entry; use structure when it exists.
  5. In software, solve A x = b with a factorisation instead of forming A⁻¹, and judge invertibility by conditioning.

References and further reading

Primary papers and authoritative documentation.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

Invert A = [[4, 7], [2, 6]] and verify the result by multiplying.

Explanation

det A = 4·6 − 7·2 = 10, so A⁻¹ = (1/10) [[6, −7], [−2, 4]] = [[0.6, −0.7], [−0.2, 0.4]]. Check row 1 · column 1: 4·0.6 + 7·(−0.2) = 2.4 − 1.4 = 1; row 1 · column 2: 4·(−0.7) + 7·0.4 = −2.8 + 2.8 = 0; row 2 · column 1: 2·0.6 + 6·(−0.2) = 0; row 2 · column 2: 2·(−0.7) + 6·0.4 = 1. The product is I.

Question 2

A sensor transform is S (sensor to body) followed by B (body to world). What is the matrix that takes a world point back to the sensor frame, and why does the order of the inverses reverse?

Explanation

The forward map is xworld = B S xsensor, so the product is BS and its inverse is (BS)⁻¹ = S⁻¹ B⁻¹. To go back you must undo the last step first (B, body to world) and then the first step (S): the inverses appear in reverse order, exactly as the wrapping-paper example suggests.

Question 3

A robot Jacobian has determinant 10⁻¹² in units where its entries are of order 1. The determinant is not exactly zero. Why is it still dangerous to invert, and what quantity would you monitor instead?

Explanation

With entries of order 1, a determinant of 10⁻¹² means the columns are nearly parallel: the matrix is almost singular. Its inverse has entries of order 10¹², so any measurement error or rounding is multiplied by that factor and the resulting joint speeds would be astronomical. Monitor the condition number (ratio of largest to smallest singular value) or the smallest singular value, and fall back to a damped solution near singularity.

What’s next

Module 2 gave you matrices as transformations. Module 3 turns to the reverse question: given the output, which inputs produce it? That is the study of linear systems.

Practice this lesson

Matrix Transformation Playground

Move a robot outline with matrices: build the matrix that maps one shape onto another, and catch the order-of-composition and singular-matrix traps.

Next lesson

M3-T1 — Systems of Linear Equations

Write a set of constraints as A x = b, picture it as lines and planes meeting, and say how many solutions to expect.

Nothing below is required to finish this lesson.