INDEX: LINEAR-ALGEBRA-FOR-ML / MATH-LA-10READING_TIME: 15 mins

4.1 Matrices as Linear Transformations

So far, we have viewed a matrix as a static spreadsheet of numbers representing data coefficients. But in geometry and deep learning, a matrix is a dynamic action!

A matrix acts like a function that takes a vector, bends/stretches the space, and outputs a new vector. We call this action a Linear Transformation.


1. What makes a transformation "Linear"?

A transformation is linear if it satisfies two strict rules:

  1. The origin must stay fixed: The point (0,0)(0, 0) must never move.
  2. Grid lines must remain straight and parallel: Grid lines cannot curve, bend, or squeeze together unevenly.

This means that any straight line in our original coordinate system must remain a straight line after the transformation.


2. The Secret: Track the Basis Vectors

It seems incredibly complicated to track where millions of points in space land after a transformation. But there is a shortcut!

Because space is uniform and grid lines remain straight and parallel, we only need to track the standard basis vectors:

  • i^=[10]\hat{i} = \begin{bmatrix} 1 \\ 0 \end{bmatrix} (the unit step along the X axis).
  • j^=[01]\hat{j} = \begin{bmatrix} 0 \\ 1 \end{bmatrix} (the unit step along the Y axis).

If we know where i^\hat{i} and j^\hat{j} land, we can calculate where any other vector in the entire space lands!


3. How a Matrix Encodes a Transformation

A 2×22 \times 2 matrix is actually just a compact package storing the landing spots of i^\hat{i} and j^\hat{j}:

M=[abcd]M = \begin{bmatrix} \color{blue}{a} & \color{green}{b} \\ \color{blue}{c} & \color{green}{d} \end{bmatrix}

  • Column 1 ([ac]\begin{bmatrix} \color{blue}{a} \\ \color{blue}{c} \end{bmatrix}): The coordinate where i^\hat{i} lands (i^\hat{i}').
  • Column 2 ([bd]\begin{bmatrix} \color{green}{b} \\ \color{green}{d} \end{bmatrix}): The coordinate where j^\hat{j} lands (j^\hat{j}').

Multiplying a Vector

When we multiply a vector v=[xy]\mathbf{v} = \begin{bmatrix} x \\ y \end{bmatrix} by matrix MM, we are simply scaling the transformed basis vectors:

Mv=x[ac]+y[bd]M\mathbf{v} = x \begin{bmatrix} a \\ c \end{bmatrix} + y \begin{bmatrix} b \\ d \end{bmatrix}

  • Example: If we want to find where vector v=[23]\mathbf{v} = \begin{bmatrix} 2 \\ 3 \end{bmatrix} lands under transformation M=[1.50.50.51.5]M = \begin{bmatrix} 1.5 & 0.5 \\ 0.5 & 1.5 \end{bmatrix}: Mv=2[1.50.5]+3[0.51.5]=[31]+[1.54.5]=[4.55.5]M\mathbf{v} = 2 \begin{bmatrix} 1.5 \\ 0.5 \end{bmatrix} + 3 \begin{bmatrix} 0.5 \\ 1.5 \end{bmatrix} = \begin{bmatrix} 3 \\ 1 \end{bmatrix} + \begin{bmatrix} 1.5 \\ 4.5 \end{bmatrix} = \begin{bmatrix} 4.5 \\ 5.5 \end{bmatrix}

4. Interactive Transformation Workspace

Use the sliders to modify matrix entries a,b,c,a, b, c, and dd. Observe how columns of the matrix map directly to the landing coordinates of the blue basis arrow (i^\hat{i}') and green basis arrow (j^\hat{j}').

Try the Shear preset: Notice how the grid tilts, sliding the top of the grid to the right while keeping the bottom line fixed.

Interactive 2D Linear Transformation Visualizer

-4-4-2-22244î' [1.5, 0.5]ĵ' [0.5, 1.5]
Quick Presets
Matrix Entries: M = [[a, b], [c, d]]
a (î_x): 1.5
b (ĵ_x): 0.5
c (î_y): 0.5
d (ĵ_y): 1.5
Determinant Analysis
det(M) = ad - bc
det(M) = (1.50 × 1.50) - (0.50 × 0.50)
det(M) = 2.00
✅ Non-Singular: Area of the unit square scales by a factor of 2.00. Space is not collapsed, so the transformation is **fully invertible**!

5. Check Your Understanding

Quiz / Test Your Knowledge

A matrix transformation has column 1 as [0, 1]^T and column 2 as [-1, 0]^T. If you apply this transformation to the standard grid, what geometric effect does it produce?