1. A matrix is a transformation

A $2\times2$ matrix sends every vector $\mathbf v=(x,y)$ to $A\mathbf v$. Because the map is linear ($A(\alpha\mathbf u+\beta\mathbf v)=\alpha A\mathbf u+\beta A\mathbf v$) it is completely fixed by where it sends the two basis vectors $\hat{\imath}=(1,0)$ and $\hat{\jmath}=(0,1)$, the unit arrows along the axes. Those images are the columns:

$$\begin{gathered}A=\begin{bmatrix}a&b\\c&d\end{bmatrix}\\ A\hat{\imath}=\begin{bmatrix}a\\c\end{bmatrix}\\ A\hat{\jmath}=\begin{bmatrix}b\\d\end{bmatrix}\\ A\begin{bmatrix}x\\y\end{bmatrix}=x\begin{bmatrix}a\\c\end{bmatrix}+y\begin{bmatrix}b\\d\end{bmatrix}\end{gathered}$$

That is why dragging the green and pink arrows in the lab edits the matrix directly. Grid lines stay straight, parallel and evenly spaced, and the origin stays fixed.

TransformationMatrixdet
Rotation by θ$\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}$1
Scaling$\begin{bmatrix}s_x&0\\0&s_y\end{bmatrix}$$s_xs_y$
Shear (horizontal)$\begin{bmatrix}1&k\\0&1\end{bmatrix}$1
Reflection in the x-axis$\begin{bmatrix}1&0\\0&-1\end{bmatrix}$−1
Projection onto the x-axis$\begin{bmatrix}1&0\\0&0\end{bmatrix}$0

2. The determinant: signed area (or volume) scale factor

$$\det A=ad-bc$$

The unit square (area 1) is mapped to a parallelogram of area $|\det A|$, and every other region is scaled by the same factor. A negative determinant means orientation has flipped (the letter F appears mirrored). $\det A=0$ means space is squashed onto a line or a point, so information is lost and $A$ has no inverse. In 3D, $\det$ is the signed volume of the image of the unit cube, and $\det(AB)=\det A\,\det B$.

3. Inverse

$$A^{-1}=\frac{1}{ad-bc}\begin{bmatrix}d&-b\\-c&a\end{bmatrix},\qquad AA^{-1}=A^{-1}A=I$$

$A^{-1}$ undoes the transformation. It exists exactly when $\det A\ne 0$.

4. Eigenvectors and eigenvalues

An eigenvector is a non-zero vector whose direction is unchanged: $A\mathbf v=\lambda\mathbf v$. It stays on its own span (the line through the origin along it) and is only stretched by the eigenvalue $\lambda$ (flipped if $\lambda<0$). Eigenvalues solve the characteristic equation

$$\begin{gathered}\det(A-\lambda I)=\lambda^2-(\operatorname{tr}A)\lambda+\det A=0\\ \lambda=\frac{\operatorname{tr}A}{2}\pm\sqrt{\frac{(\operatorname{tr}A)^2}{4}-\det A}\end{gathered}$$
  • Discriminant $>0$: two real eigenvalues and two eigen-directions (dashed lines in the lab).
  • Discriminant $=0$: a repeated eigenvalue, with either every direction (a pure scaling) or only one direction (a shear).
  • Discriminant $<0$: a complex pair $\alpha\pm\beta i$. No real direction is preserved. In a suitable (generally non-orthogonal) basis the map is a rotation by $\arg\lambda$ combined with scaling by $|\lambda|$; in ordinary coordinates repeated application spirals points around ellipses rather than circles, unless $A$ is itself a scaled rotation.

Useful checks: $\lambda_1+\lambda_2=\operatorname{tr}A$ and $\lambda_1\lambda_2=\det A$.

5. Composition: order matters

Applying $B$ first and then $A$ is the single matrix $AB$ (read right to left, like function composition $A(B\mathbf v)$). In general $AB\neq BA$. In 2D, rotations about the same origin commute with each other (in 3D they generally do not); a rotation and a shear do not.

6. Homogeneous coordinates

Translation $\mathbf v\mapsto\mathbf v+\mathbf t$ is not linear (it moves the origin), so no $2\times2$ matrix can do it. The trick is to write a 2D point as $(x,y,1)$ and use $3\times3$ matrices:

$$\begin{bmatrix}x'\\y'\\1\end{bmatrix}=\underbrace{\begin{bmatrix}1&0&t_x\\0&1&t_y\\0&0&1\end{bmatrix}}_{T}\underbrace{\begin{bmatrix}\cos\theta&-\sin\theta&0\\\sin\theta&\cos\theta&0\\0&0&1\end{bmatrix}}_{R}\begin{bmatrix}x\\y\\1\end{bmatrix}$$

Now rotations, scalings and translations are all matrix products and can be chained. This is exactly how computer graphics pipelines and robot forward kinematics work: each robot joint contributes one transform, and the gripper pose is the product $T_{02}=T_{01}\,T_{12}$.

7. Linear systems and Gaussian elimination

The system $A\mathbf x=\mathbf b$ is solved by row operations on the augmented matrix $[A\,|\,\mathbf b]$. Each operation (swap two rows, scale a row by a non-zero number, add a multiple of one row to another) leaves the solution set unchanged. Forward elimination produces row-echelon form; back substitution finishes the job.

Geometrically each equation is a line (2D) or a plane (3D), and the solution is their common intersection. The rank of a matrix is the number of independent rows (equivalently, the dimension of the space its outputs fill). A unique solution needs $\operatorname{rank}A=n$ ($\det A\neq0$). If $\operatorname{rank}A<\operatorname{rank}[A\,|\,\mathbf b]$ the system is inconsistent (parallel lines). If both ranks are equal but less than $n$ there are infinitely many solutions.

Example 1: where does a vector go?

$A=\begin{bmatrix}1.5&1\\0.5&1.5\end{bmatrix}$ and $\mathbf v=(-1,\,1.5)$: the lab's starting matrix and test vector.

$A\mathbf v=-1\begin{bmatrix}1.5\\0.5\end{bmatrix}+1.5\begin{bmatrix}1\\1.5\end{bmatrix}=\begin{bmatrix}-1.5+1.5\\-0.5+2.25\end{bmatrix}=\begin{bmatrix}0\\1.75\end{bmatrix}$

$\det A=1.5(1.5)-1(0.5)=1.75$: every area grows by 75 %.

Example 2: eigenvalues of a symmetric matrix

$A=\begin{bmatrix}2&1\\1&2\end{bmatrix}$: $\operatorname{tr}A=4$, $\det A=3$, so $\lambda^2-4\lambda+3=(\lambda-3)(\lambda-1)=0$.

$\lambda_1=3$: $(A-3I)\mathbf v=0\Rightarrow -v_1+v_2=0$, so $\mathbf v_1=(1,1)$. $\lambda_2=1$: $v_1+v_2=0$, so $\mathbf v_2=(1,-1)$.

Check: $3+1=4=\operatorname{tr}A$ and $3\times1=3=\det A$. The eigenvectors are perpendicular, as for every symmetric matrix.

Example 3: a rotation has complex eigenvalues

Rotation by 90°: $A=\begin{bmatrix}0&-1\\1&0\end{bmatrix}$, $\operatorname{tr}=0$, $\det=1$, so $\lambda^2+1=0$ and $\lambda=\pm i$. $|\lambda|=1$ (no stretching) and $\arg\lambda=90°$ (the rotation angle). No real vector keeps its direction.

Example 4: AB versus BA

$A=\begin{bmatrix}0&-1\\1&0\end{bmatrix}$ (rotate 90°), $B=\begin{bmatrix}1&1\\0&1\end{bmatrix}$ (shear).

$AB=\begin{bmatrix}0&-1\\1&1\end{bmatrix}$ (shear first, then rotate) but $BA=\begin{bmatrix}1&-1\\1&0\end{bmatrix}$ (rotate first, then shear). Different matrices, different pictures, yet $\det AB=\det BA=1$.

Example 5: homogeneous transform

Rotate the point $(1,0)$ by 90° and then translate by $(3,1)$:

$$TR=\begin{bmatrix}0&-1&3\\1&0&1\\0&0&1\end{bmatrix},\qquad TR\begin{bmatrix}1\\0\\1\end{bmatrix}=\begin{bmatrix}3\\2\\1\end{bmatrix}$$

Translating first gives $RT\,(1,0,1)^{\mathsf T}=R\,(4,1,1)^{\mathsf T}=(-1,4,1)^{\mathsf T}$: a different place.

Example 6: Gaussian elimination

Solve $2x+y=5,\ x-y=1$.

  1. $R_2\to R_2-\tfrac12R_1$: $\left[\begin{smallmatrix}2&1&|&5\\0&-1.5&|&-1.5\end{smallmatrix}\right]$ (forward elimination complete).
  2. $R_2\to -\tfrac23R_2$: $y=1$.
  3. $R_1\to R_1-R_2$, then $R_1\to\tfrac12R_1$: $x=2$.

Solution $(x,y)=(2,1)$: the point where the two lines cross. Load the first 2 × 2 example in the lab and press Next step.

Example 7: a market problem

At a market, 2 mangoes, 3 avocados and 1 banana cost KES 190; 1 mango, 2 avocados and 3 bananas cost KES 140; 3 mangoes, 1 avocado and 2 bananas cost KES 150. With unknown prices $(m,a,b)$:

$$\begin{bmatrix}2&3&1\\1&2&3\\3&1&2\end{bmatrix}\begin{bmatrix}m\\a\\b\end{bmatrix}=\begin{bmatrix}190\\140\\150\end{bmatrix}\ \Rightarrow\ (m,a,b)=(30,\,40,\,10)\ \text{KES}$$

$\det A=2(4-3)-3(2-9)+1(1-6)=2+21-5=18\neq0$, so the answer is unique. Load "Market prices" in the 3 × 3 examples to see every row operation.

Challenges (checked automatically)

Guided experiments

  1. Determinant through zero. In 2D mode drag ĵ slowly across the line through î. Watch the unit-square area shrink to 0 and the colour change as orientation flips.
  2. Repeated eigenvalue. Load the shear preset. Only one dashed eigen-line remains: the shear is defective.
  3. Circle to ellipse. Choose the Circle shape with a symmetric matrix. The ellipse's axes line up with the eigenvectors; their half-lengths are $|\lambda_1|$ and $|\lambda_2|$.
  4. Rotation commutes with rotation. In Composition set A and B to two different rotations. The two panels end in the same place.
  5. Flat volume. In 3D load the projection preset: the cube collapses into a flat square and det = 0.
  6. Inconsistent planes. Load the 3 × 3 "No solution" example and step through. A row reduces to $[0\ 0\ 0\,|\,c\neq0]$, which reads $0=c$.

Where matrices do the work

Computer graphics. Every vertex in a game is multiplied by model, view and projection matrices (4 × 4, homogeneous) millions of times per frame on the GPU.
Robotics. Forward kinematics chains one homogeneous transform per joint (Denavit–Hartenberg convention). See the Robot Arm Kinematics lab.
Structural engineering. Finite-element models of bridges and towers solve $K\mathbf u=\mathbf f$ with stiffness matrices of millions of rows.
Search and data. PageRank is the dominant eigenvector of a link matrix; principal component analysis uses the eigenvectors of a covariance matrix.
Stability. A system $\dot{\mathbf x}=A\mathbf x$ is stable when every eigenvalue of $A$ has negative real part: used in control, power grids and ecology.
Mapping and GIS. Converting GPS coordinates to a flat map uses affine (homogeneous) transforms; fitting control points uses least squares, a linear system.