Linear Algebra for Machine Learning

Inverse Matrices

Inverse matrices as the transformations that undo other transformations.

Lesson
5

Goal

Understand inverse matrices as undoing maps. If a matrix sends a vector somewhere, the inverse sends it back.

Motivation

The idea of “undo” appears everywhere in math and programming.

Inverse matrices are the linear algebra version of that idea.

Prerequisites

Notation / Symbol Table

SymbolMeaning
A^{-1}The inverse of matrix A, if it exists.
IThe identity matrix.
A x = bA linear system that may be solved using an inverse when one exists.
xAn unknown vector to solve for.
bA known output vector.

Core Ideas

The inverse undoes the transformation

The inverse matrix A^{-1} is defined by:

A1(Ax)=x.A^{-1}(A x) = x.

Equivalently:

A1A=I.A^{-1}A = I.

That is the entire definition in one line.

The identity matrix does nothing

The identity matrix is the linear algebra version of 1.

It leaves every vector unchanged:

Ix=x.Ix = x.

So if a matrix and its inverse are multiplied together, the result must be the identity.

Not every matrix has an inverse

If a transformation collapses space, information is lost.

Once two different inputs end up at the same output, no inverse can separate them again.

That is why singular matrices, the ones with det(A) = 0, do not have inverses.

Solving a system is really an undoing problem

If:

Ax=b,A x = b,

and A^{-1} exists, then:

x=A1b.x = A^{-1} b.

This is one reason inverse matrices matter so much.

In practice, numerical software often solves the system without explicitly forming the inverse, because that is usually faster and more stable.

Worked Example

Let:

A=[2002].A = \begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix}.

This matrix doubles every vector.

To undo that, the inverse must halve every vector:

A1=[120012].A^{-1} = \begin{bmatrix} \tfrac{1}{2} & 0 \\ 0 & \tfrac{1}{2} \end{bmatrix}.

Check the result:

A1A=[120012][2002]=[1001]=I.A^{-1}A = \begin{bmatrix} \tfrac{1}{2} & 0 \\ 0 & \tfrac{1}{2} \end{bmatrix} \begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = I.

Now consider:

B=[1224].B = \begin{bmatrix} 1 & 2 \\ 2 & 4 \end{bmatrix}.

This matrix collapses the plane onto a line, so det(B) = 0.

That means there is no inverse.

The geometric reason is simple:

once the transformation has destroyed a dimension, there is no unique way to recover it.

Why This Shows Up In ML

Inverse matrices appear in many places around machine learning and numerical computing:

The important practical lesson is that “having an inverse” is not the same as “always computing it directly.”

Exercises

  1. What is I applied to the vector (7, -2)?

  2. Find the inverse of

[3003].\begin{bmatrix} 3 & 0 \\ 0 & 3 \end{bmatrix}.
  1. Decide whether
[1236]\begin{bmatrix} 1 & 2 \\ 3 & 6 \end{bmatrix}

has an inverse, and explain why.

  1. If A rotates vectors by 90^\circ counterclockwise, what should A^{-1} do?

  2. Explain why determinant zero guarantees that no inverse exists.

Implementation Exercise

Write a TypeScript helper that computes the inverse of a 2 x 2 matrix when it exists:

type Matrix2x2 = [[number, number], [number, number]];
type Vector2 = [number, number];

export function inverse2x2(matrix: Matrix2x2): Matrix2x2 | null

Then verify that multiply2x2(matrix, inverse) gives the identity matrix for a few invertible examples, and returns null for a collapsed matrix.

Reflection Questions