Matrix Lab · Syllabus
A level-based interactive linear algebra course: drag vectors, matrices and grids on the canvas and build geometric intuition for abstract concepts. 12 chapters, 56 levels. First 7 levels free; $19.99 one-time unlocks all levels and sandbox mode.
Start the Course →Chapter 1 · Vectors and Coordinates
-
1-1 · Place Your First Vector
A vector is more than two numbers — it is a displacement in space. On the canvas, the horizontal direction is the x-axis and the vertical direction is the y-axis; each grid square is 1 unit.
-
1-2 · Vector Addition: Tip to Tail
Adding vectors means joining two displacements tip to tail. Here a = (1, 2) and b = (2, 0), and their components add separately: a + b = (1+2, 2+0). Subtraction is a special case of addition: b − a = b + (−a).
-
1-3 · Scalar Multiplication: Stretch and Flip
Multiplying a vector by a number (a scalar) stretches it proportionally: 2a points the same way as a with double the length; −a points the opposite way. Here a = (1, 2).
-
1-4 · Length and Unit Vectors
The length of a vector is |v| = √(x² + y²) (the Pythagorean theorem). A vector of length 1 is called a unit vector: it keeps only the direction and drops the length. Adjust v to be the unit vector in the same direction as u = (3, 4).
Chapter 2 · Basis Vectors and Matrix Columns
-
2-1 · Basis Vectors and Linear Combinations
î = (1, 0) and ĵ = (0, 1) are the standard basis vectors. Any vector can be written as a linear combination of them: v = x·î + y·ĵ. The coordinates (x, y) are the coefficients of that combination.
-
2-2 · Matrix Columns = Transformed Basis Vectors
The two columns of a 2×2 matrix are exactly where î and ĵ land after the transformation. Drag the tip of the pink A î and watch the first column of the matrix on the right change in sync — this is the single most important picture for understanding matrices.
-
2-3 · Span: Where Can You Reach?
All the linear combinations of two non-parallel vectors can cover the entire plane — this is called their span. In the figure, u = (2, 1) and w = (1, 2). Try using them to reach the target points.
-
2-4 · Linear Dependence: The Redundant Column
If one column is a multiple of the other, it brings no new direction — the two columns are linearly dependent, the span collapses from the plane down to a line, and the determinant becomes 0.
-
2-5 · Column Space and Rank: How Big a World Can the Columns Span
The span of a matrix’s two columns has a name of its own: the column space. The number of dimensions of the column space is the matrix’s rank. Two non-parallel columns → column space is the whole plane → rank 2; two parallel columns → it collapses to a line → rank 1. The matrix panel on the right shows the rank live.
Chapter 3 · Linear Transformations
-
3-1 · A matrix = a transformation of the whole space
A matrix acts on every point in space: the entire grid deforms along with it. Click "▶ Play transformation" and watch the unit grid morph continuously into its transformed shape.
-
3-2 · Where does the vector go: v → Av
The matrix A maps the vector v to Av (the green dashed arrow). Because the transformation is linear, Av = x·A î + y·A ĵ — the coefficients stay the same; only the basis is swapped out.
-
3-3 · The shape of a transformation: rotate 90°
After a 90° rotation, î lands on (0, 1) and ĵ lands on (−1, 0). So the rotation matrix is [[0, −1], [1, 0]]. Try building it with the preset button or by dragging the column vectors directly.
-
3-4 · Projection: squashing the plane onto a line
A projection drops every vector perpendicularly onto a line. Onto the x-axis: î stays put, ĵ falls to the origin, and the matrix is [[1, 0], [0, 0]]. The whole plane gets flattened — projection loses information, so it is not invertible.
-
3-5 · Rotating by any angle
Rotate by an angle θ: î lands on (cosθ, sinθ) and ĵ lands on (−sinθ, cosθ), so the rotation matrix is [[cosθ, −sinθ], [sinθ, cosθ]]. For θ = 45°, cosθ = sinθ ≈ 0.707.
-
3-6 · Shear: pushing a square into a parallelogram
A shear fixes one basis vector and pushes the other sideways: î stays put, ĵ is pushed to (1, 1), and the matrix is [[1, 1], [0, 1]]. The grid slides apart like a deck of cards — notice that each layer only shifts, so the area does not change.
Chapter 4 · Composing Transformations & Matrix Multiplication
-
4-1 · Composing Transformations = Multiplying Matrices
Apply rotation B, then shear A — this is equivalent to a single matrix A·B. Mind the order: the right one acts first! Matrix multiplication is composition of transformations. Use the toolbar to apply A and B separately, then compare with A·B.
-
4-2 · Order Matters: AB ≠ BA
Rotate-then-shear and shear-then-rotate give completely different results. Press both buttons to see the final grid for each order, and feel why matrix multiplication cannot be swapped.
-
4-3 · Read Matrix Multiplication Column by Column
Column 1 of AB = A times column 1 of B. Let B = [[2, 0], [0, 1]] (stretches x by 2) and A = [[1, 1], [0, 1]] (a shear). Compute AB by hand and verify each of its columns.
-
4-4 · Composing Three Transformations: Associativity
When composing three transformations, (AB)C and A(BC) give the same result — matrix multiplication is associative. Apply them in the order C → B → A (the rightmost acts first) and watch the final matrix.
Chapter 5 · Determinants: Scaling Area
-
5-1 · Determinant = Area Scaling Factor
The unit square (blue) becomes a parallelogram (green) after the transformation, and the factor by which the area scales is det(A). Drag the column vectors so the area becomes 2 times the original.
-
5-2 · Negative Determinant = Flipped Space
When det(A) < 0, space has been flipped (like a mirror image): the left/right-hand relationship between î and ĵ is reversed. Watch how the rotation direction from î to ĵ changes.
-
5-3 · det = 0: Space Gets Flattened
When the two columns are collinear, the whole plane is crushed onto a line and the area becomes 0 — the matrix "loses a dimension." This is a singular matrix.
-
5-4 · det(AB) = det(A) · det(B)
A scales the area by 2, then B scales it by 3, so the composite transformation naturally scales it by 2 × 3 = 6: det(AB) = det(A)·det(B). Verify this most important property of determinants with your own hands.
-
5-5 · det and Inverses: det(A⁻¹) = 1/det(A)
A = [[2, 0], [0, 2]] scales the area by 4, so the A⁻¹ that undoes it must scale the area back by 1/4. Change the matrix into A⁻¹ and verify that det(A⁻¹) = 1/det(A).
Chapter 6 · Inverse Matrices: Undoing Transformations
-
6-1 · Inverse Matrix = Undo the Transformation
If A transforms space one way, A⁻¹ transforms it back: A⁻¹·A = I. Here A stretches the x direction by 2. What matrix would undo it?
-
6-2 · Singular Matrices Have No Inverse
A matrix with det = 0 squashes the plane into a line — information is destroyed and cannot be recovered, so A⁻¹ does not exist. Build a singular matrix yourself, then press "Invert" and see what happens.
-
6-3 · Solving Equations with the Inverse Matrix
Multiply both sides of Av = b by A⁻¹, and you get v = A⁻¹b. First drag v into place using the column picture, then click "Invert" to verify that A⁻¹ really maps b back to v.
-
6-4 · Inverse of a Composition: (BA)⁻¹ = A⁻¹B⁻¹
Undoing a composite transformation must happen in reverse order — like taking off your shoes before your socks. First apply A (stretch) then B (rotation), then undo them with their inverses in the correct order.
Chapter 7 · Change of Basis
-
7-1 · Same Vector, Two Coordinate Systems
The pink and purple arrows form a new basis (the two columns of matrix B), and the green grid is their coordinate grid. v is still the same arrow, but the new basis has its own way of reading it: v = c₁·b₁ + c₂·b₂, and (c₁, c₂) is v's new-basis coordinates (shown live in the top-right of the canvas).
-
7-2 · Coordinate Translator: B and B⁻¹
To translate new-basis coordinates c into standard coordinates, multiply on the left by B (i.e. B·c). Conversely, to translate standard coordinates into new-basis coordinates, multiply on the left by B⁻¹. The matrix B is a translator between the two languages.
-
7-3 · The Matrix in a New Basis: B⁻¹AB
How do you write the same transformation A in the language of a new basis? B⁻¹AB: first translate new-basis coordinates into standard coordinates (B), then apply A, and finally translate back (B⁻¹). Multiply out these three steps yourself.
-
7-4 · A Good Basis Makes the Problem Simple
A = [[2, 1], [0, 1]] looks a bit "tangled" in the standard basis (it includes a shear). But in the basis B = [[1, 1], [0, −1]] made of its two eigendirections, B⁻¹AB becomes a diagonal matrix: each basis direction is scaled independently, with no entanglement. Compare the two representations and feel how much the choice of basis matters.
Chapter 8 · Eigenvectors and Eigenvalues
-
8-1 · Eigenvectors: Directions That Never Turn
Most vectors change direction under A, but eigenvectors are only scaled, never rotated: Av = λv. Drag v (the gold dashed line is its extension) to find the directions that stay collinear with Av.
-
8-2 · Eigenvalues: The Scaling Factor
When they are collinear, Av = λv, and λ is the eigenvalue: |λ| is the stretch factor, and its sign tells you whether the direction flips. This matrix is a reflection — find its two eigendirections.
-
8-3 · Eigenvalues of a Diagonal Matrix
For the diagonal matrix [[2, 0], [0, 3]], the eigenvectors are exactly the two coordinate axes, and the eigenvalues sit right on the diagonal: λ₁ = 2, λ₂ = 3. Their product happens to be det = 6.
-
8-4 · Repeated Transformations Along an Eigendirection
Back to the matrix A = [[2, 1], [0, 1]] from 8-1. Put v back onto the eigendirection (1, 0), then apply A over and over — v always stays on the eigendirection, just stretched by λ each time.
-
8-5 · Eigenbasis: Turning A into a Diagonal Matrix
Take the two eigendirections (1, 0) and (1, −1) from 8-1 and stack them as the columns of a matrix P, then compute P⁻¹AP: in the eigenbasis, A = [[2, 1], [0, 1]] becomes a diagonal matrix, with the eigenvalues 2 and 1 right on the diagonal. This is diagonalization, A = PDP⁻¹ — the change of basis from Chapter 7 and the eigenvectors of Chapter 8 meet right here.
Chapter 9 · Solving Linear Systems
-
9-1 · The Column Picture: Building b
The column picture of Ax = b: find the coefficients x that make a linear combination of A's two columns land exactly on b. Drag x (the gold vector), and the green Ax moves with it — make it hit the target b = (4, 1).
-
9-2 · The Row Picture: Where Two Lines Meet
The row picture of the same system: each row is a line (x + 2y = 4 and x − y = 1), and the solution is where the two lines intersect. Drag the gold point to find it.
-
9-3 · No Solution: Two Parallel Lines
The system x + y = 2 and x + y = 4 graphs as two parallel lines — no intersection, so the system has no solution. In the column picture: b lies outside the span of the two columns (a single line).
-
9-4 · Infinitely Many Solutions: Coinciding Lines
The system x + y = 2 and 2x + 2y = 4 is really the same equation — the two lines coincide completely, and every point on the line is a solution: infinitely many solutions.
-
9-5 · Null Space: The Directions Crushed to the Origin
The matrix A = [[1, 1], [1, 1]] from 9-3 squashes the entire plane onto the line y = x. The vectors that get squashed exactly to the origin (solutions of Av = 0) form the null space of A. Drag v and watch Av (green) to find the direction that gets crushed.
Chapter 10 · Into Three Dimensions
-
10-1 · 3D Space and 3×3 Matrices
Welcome to three dimensions! The three columns of a 3×3 matrix are the landing spots of î, ĵ, and k̂. Drag the empty space to rotate your view and look at these three column vectors from different angles.
-
10-2 · The 3D Determinant = Volume Scaling
The unit cube (blue) is turned by a 3×3 matrix into a parallelepiped (green), and the volume scaling factor = det(A). Drag a column vector tip to make the volume 2 times larger.
-
10-3 · 3D Rotation: 90° Around the z-Axis
When rotating around the z-axis, k̂ stays put while î and ĵ turn 90° in the xy plane. So the matrix's 3rd column is (0, 0, 1), and the first two columns match the 2D rotation: [[0, −1, 0], [1, 0, 0], [0, 0, 1]].
-
10-4 · 3D det = 0: Flattened into a Plane
When the three column vectors are coplanar, the parallelepiped is squashed flat and its volume becomes 0 — 3D space collapses onto a plane (or even a line), and the matrix is singular. Flatten this cube yourself.
Chapter 11 · Dot Products and Duality
-
11-1 · Dot Product: Multiply Components, Then Add
The dot product of two vectors is a number: u·v = uₓvₓ + u_y v_y. Here u = (2, 1), and the top-right corner of the canvas shows u·v live — drag v and watch how it changes.
-
11-2 · Geometric Meaning: Length of the Projection
The geometric meaning of u·v: the length of v's projection onto u, times |u|. The green arrow is the projection of v onto u = (3, 0), and the dashed line is the perpendicular.
-
11-3 · Sign of the Dot Product: Acute, Right, Obtuse
The sign of the dot product reveals the angle: u·v > 0 means acute, = 0 means perpendicular, < 0 means obtuse. Since u·v = |u||v|cosθ, the sign is decided entirely by cosθ.
-
11-4 · Duality: The Dot Product Is a 1×2 Matrix
Fix u = (2, 1). The map v ↦ u·v turns a plane vector into a number — it is a linear transformation from 2D to 1D, whose matrix is the 1×2 matrix [2 1], exactly u laid on its side (the transpose uᵀ). This correspondence between vectors and linear functions is called duality.
-
11-5 · Transpose: Laying Rows Down as Columns
The transpose Aᵀ writes row 1 of A as column 1, row 2 as column 2: the transpose of A = [[2, 1], [0, 3]] is Aᵀ = [[2, 0], [1, 3]]. In 11-4, "the vector lay down into a 1×2 matrix" — that was the vector version of the transpose. Now dial in Aᵀ yourself.
-
11-6 · Dot Product and Angle: Cosine Similarity
u·v = |u||v|cosθ. When both vectors are unit vectors, the dot product is cosθ itself — the smaller the angle, the larger the dot product. u = (1, 0) is fixed; set v to a unit vector at a 60° angle to it.
Chapter 12 · The Cross Product
-
12-1 · The 2D Cross Product = Oriented Area
In 2D, the cross product of two vectors is a number: u×w = uₓw_y − u_y wₓ, which is exactly det([u w]) — the oriented area of the parallelogram. Drag the two columns and revisit the area from Chapter 5, this time watching its sign.
-
12-2 · The 3D Cross Product: A Vector Perpendicular to Both
In 3D, a×b is a vector: it is perpendicular to both a and b, and its direction is given by the right-hand rule (curl your fingers from a toward b; your thumb points the way). Here a = (2, 0, 0) and b = (1, 2, 0), and the green arrow shows a×b computed live.
-
12-3 · The Length of the Cross Product = Parallelogram Area
|a×b| = |a||b|sinθ — exactly the area of the parallelogram spanned by a and b. Drag the first two columns of the matrix (the pink and purple arrows), and the length of the green cross-product vector updates in real time.
-
12-4 · Cross Product and Determinant: The Return of Duality
Dot a×b with a third vector c: (a×b)·c = det([a b c]) — the oriented volume of the parallelepiped. "Dotting with c" is a linear function whose dual vector is exactly a×b: the duality from Chapter 11 is back, now in 3D.
Math for ML New
The sister course of Matrix Lab: drag a line to fit data (least squares), walk gradient descent down the loss curve, and draw decision boundaries to classify. 3 chapters, 8 levels — activation shared with the linear algebra course.
Start Math for ML →Chapter 1 · Fitting a Line to Data
-
1-1 · Meet the Data and the Line
The first step of machine learning: let the machine find a line that describes the data. Drag the two ends of the gold line so it roughly passes through the scatter points. This line is y = kx + b from linear algebra — machine learning calls k and b the "parameters".
-
1-2 · How Error Is Measured
The vertical distance from each point to the line is called a "residual". Square the residuals and average them — that is MSE (mean squared error). Squaring amplifies points far from the line. The metric card on the right shows the current MSE in real time; make it as small as you can.
-
1-3 · The Outlier Effect
This dataset has an outlier (the one at the top right). Because MSE squares the residuals, it pulls the line with disproportionate weight. Fit the line, then answer the question below.
Chapter 2 · Gradient Descent: Rolling Down the Valley
-
2-1 · Loss Is a Mountain
Treat the error as a function of the parameter and you get a mountain of loss: the x-axis is the parameter x, the y-axis is the loss, loss = x². The valley floor is the best parameter. Drag the point on the curve into the valley.
-
2-2 · Walking Down, Step by Step
The machine does not guess randomly — it reads the gradient (here the slope of the parabola, 2x) and takes a step in the opposite direction: x ← x − 0.3·2x. Click "Step downhill" and walk through gradient descent yourself.
-
2-3 · A Learning Rate Too Big Blows Up
The step-size factor is the learning rate (lr). With lr = 0.95 each step overshoots and oscillates across the valley; with lr = 0.1 it moves steadily. Try both buttons, then answer the question below.
Chapter 3 · Decision Boundaries: Splitting Two Classes
-
3-1 · Draw a Line to Split Them
This is a classification problem: green points are one class, red points another. Drag the line as a decision boundary to separate the two classes. That line is the linear classifier w·x + b = 0 — the linear-algebra line equation in disguise.
-
3-2 · There Is No Perfect Line
Real data is noisy: one red point sits inside the green cluster, and no straight line can reach 100%. Accept that, get the accuracy above 85%, then answer the question below.