MFML Interactive/ Unit 1 · Systems of Linear Equations Checks 0/10
Unit 1 · Covers Session 1 · ZC416 MFML · Prof. Saurabh

Systems of Linear Equations

Behind every Instagram feed, GPS route, and next-word prediction sits one humble object: Ax=bA\mathbf{x}=\mathbf{b}. This unit earns you the single most useful mental picture in the course — a matrix is a machine that moves space — and a method that never lies: Gaussian elimination.

≈ 55 min read + play 11 interactive widgets · 2 in 3D 10 inline checks
1

Why are we even talking about lines?

Open Instagram and scroll for ten seconds. The app just decided what to show you — which photo, which order, which ad. Behind that decision is a tower of math, and at the very bottom of the tower sits one humble object: a system of linear equations. Same story for the GPS routing you home, the camera autofocusing on a face, and a language model predicting the next word. Sooner or later, every one of them lands on something of the form Ax=bA\mathbf{x}=\mathbf{b}.

But wait — look out the window. Roads curve. Light bends. The stock market zigzags. Almost nothing in real life is a straight line. So why does an entire branch of math — and the engine room of every ML model — obsess over linear things?

Intuition

Three honest reasons. ① Linear problems can always be solved — not "solved if we're lucky." There's a recipe a computer can follow that either finds the answer or proves none exists. ② Up close, almost everything looks linear. The Earth is round, but your floor is flat. ③ You can see it — lines, planes, hyperplanes. Geometry you can draw on a napkin.

Reason ② is the profound one, and you shouldn't take it on faith. Test it yourself:

Zoom until the world turns straightthe curve is y = sin x, examined near x = 1

window width: 5.00
biggest gap between curve & tangent:

Zoom in and watch the gap die.

The gap shrinks like the square of the window — halve the window, the error drops to a quarter. That's why "pretend it's a line" works so well: the lie is tiny and it dies fast.

This zoom trick is the secret engine of this whole course. Calculus is "zoom in until it's linear." Training a neural network is "zoom in, solve the easy linear problem, take a small step, zoom in again" — a million times over. When we meet gradient descent in Unit 9, it will be exactly this widget, running in a loop.

The price of simplicity: a single straight line can't draw a circle or trace a stock chart. Linear things are simple, and simple things are limited. Machine learning's answer is to stack many linear pieces with a sprinkle of non-linear glue (a ReLU or sigmoid) between them — LEGO bricks: each brick is dumb and rectangular, but a million of them build a castle.

2

What is a vector, really?

The slides say it precisely: linear algebra is the study of vectors and the rules for manipulating them. But a vector is not some mysterious arrow floating in an abstract space. A vector is just an ordered list of numbers — plus the promise that adding two lists, or scaling a list, gives you back the same kind of object. (That promise has a name — closure — and it's the seed of the "vector space" idea that Unit 2 grows into.)

Lists you already use every day: a house in a dataset is a vector (area, bedrooms, age, price)(\text{area},\ \text{bedrooms},\ \text{age},\ \text{price}). A photo is a vector — one number per pixel, hundreds of thousands of them. A word inside a modern language model is a vector, the famous embedding. Even a polynomial can be treated as a vector — its list of coefficients. Even you, in your bank's risk model, are a vector.

Pause & predict

Which of these can legitimately be treated as a vector?

3

A small problem you can solve by hand

Imagine this

You run a workshop making three furniture kits — chairs, tables, cabinets. Each kit consumes wood, labor, machine time and shipping effort. Today you have exactly 9 units of wood, 8 hours of labor, 7 hours of machine time, 11 units of shipping effort. How many of each kit should you make so that every resource is used exactly — nothing wasted, nothing short?

A factory manager solves a version of this every Monday. Translate it, one resource at a time — if you make x1x_1 chairs, x2x_2 tables, x3x_3 cabinets:

x1+2x2+x3=9(all the wood)2x1+x2+x3=8(all the labor)x1+x2+2x3=7(all the machine time)3x1+x2+2x3=11(all the shipping)\begin{aligned} x_1+2x_2+x_3 &= 9 &&\text{(all the wood)}\\ 2x_1+x_2+x_3 &= 8 &&\text{(all the labor)}\\ x_1+x_2+2x_3 &= 7 &&\text{(all the machine time)}\\ 3x_1+x_2+2x_3 &= 11 &&\text{(all the shipping)} \end{aligned}

Before any theory — just play. Find the production plan with your hands:

The production mixerhit every target exactly
0
0
0
4 targets to hit.

Each bar is a resource being consumed by your plan; the dark tick is the target. Notice: one slider moves all four bars — the equations are coupled. That coupling is what makes systems interesting.

Intuition

How would you solve it on paper instead of by trial? You'd play a small game: take two equations, scale one, subtract. A variable disappears. Take equation 2 minus 2× equation 1:

(2x1+x2+x3)2(x1+2x2+x3)=829        3x2x3=10.(2x_1+x_2+x_3)-2(x_1+2x_2+x_3)=8-2\cdot 9 \;\;\Longrightarrow\;\; -3x_2-x_3=-10.

The x1x_1 vanished — that is literally what eliminate means. Repeat until one variable stands alone, then substitute back up. Two moves. Everything fancy in this unit — matrices, Gaussian elimination, echelon form — is just these two moves, made automatic and made to scale.

One more thing worth noticing: that was four equations for three unknowns — an overdetermined system, which usually has no solution at all. The fact that one exists here means the four constraints happen to agree. Later in this unit you'll be able to detect that directly from the matrix, no guesswork. And when an overdetermined system doesn't have a solution — which is the everyday situation in machine learning — linear regression is exactly the art of finding the best approximate solution. That story starts here.

4

The three fates: zero, one, or infinity

Imagine this

A treasure is hidden on a flat island. Two friends each hand you a clue, and each clue happens to describe a straight line: "the treasure is somewhere on this line." Before you read on — what are all the ways this can play out?

There are exactly three, and you can generate all of them with your own hands:

Two clues, one islandeach equation is a line; a solution is a point obeying both

Aha

A linear system can never have exactly two answers. Or seven. Or forty-two. Suppose you somehow found two different solutions u\mathbf{u} and v\mathbf{v}. Then their midpoint is a solution. So is every blend 13u+23v\tfrac13\mathbf{u}+\tfrac23\mathbf{v}. The moment you have two, linearity hands you the whole line through them — infinitely many. Finite counts above one are simply not on the menu: zero, one, or infinity. Nothing else.

The same trichotomy appeared in the slides with three variables, where each equation is a plane in 3D. Add equations ① x1+x2+x3=3x_1+x_2+x_3=3 and ② x1x2+2x3=2x_1-x_2+2x_3=2: you get 2x1+3x3=52x_1+3x_3=5. If equation ③ says 2x1+3x3=12x_1+3x_3=1 — contradiction, no solution. If ③ says 2x1+3x3=52x_1+3x_3=5 — it's the other two in disguise, infinitely many, one for every choice of the free variable x3x_3. And if ③ cuts through independently (say x2+x3=2x_2+x_3=2), the three planes meet at one point (1,1,1)(1,1,1). In nn dimensions the surfaces are called hyperplanes, we stop trying to draw them, and the story doesn't change: zero, one, or infinity. (In Section 13 you'll fly through those three planes in 3D and read each fate off a single number — the rank.)

Pause & predict

Your classmate claims a linear system with exactly two solutions exists. What do you say?

5

Meet the matrix — a spreadsheet with superpowers

An (m,n)(m,n) matrix is a grid of numbers aija_{ij}mm rows, nn columns. If you've opened Excel, you've seen one. A row vector is a (1,n)(1,n) matrix, a column vector an (m,1)(m,1) matrix, and Rm×n\mathbb{R}^{m\times n} is the set of all such real grids. Strip our furniture problem of its variable names and plus signs, and keep only the numbers:

(121211112312)A (the recipe) (x1x2x3)x (unknowns)=(98711)b (targets)\underbrace{\begin{pmatrix}1&2&1\\2&1&1\\1&1&2\\3&1&2\end{pmatrix}}_{A\ \text{(the recipe)}}\ \underbrace{\begin{pmatrix}x_1\\x_2\\x_3\end{pmatrix}}_{\mathbf{x}\ \text{(unknowns)}} = \underbrace{\begin{pmatrix}9\\8\\7\\11\end{pmatrix}}_{\mathbf{b}\ \text{(targets)}}

An entire system collapses into three letters: Ax=bA\mathbf{x}=\mathbf{b}. This is more than shorthand — it's a doorway. The moment we stop seeing AA as "a stack of equations" and start seeing it as a thing that does something to x\mathbf{x}, the whole subject opens up.

Adding two matrices: same shape, add cell by cell. Scaling by λ\lambda: multiply every cell. Multiplying two matrices is the strange one — row times column: for ARm×kA\in\mathbb{R}^{m\times k}, BRk×nB\in\mathbb{R}^{k\times n}, the product C=ABC=AB has cij=l=1kailbljc_{ij}=\sum_{l=1}^{k} a_{il}\,b_{lj}. Trace it with your cursor:

Row × column, cell by cellhover / tap any cell of C = AB

Inner sizes must agree: (m×k)(k×n)m×n(m\times k)(k\times n)\to m\times n. If they don't, the product simply isn't defined — and even when both AB and BA exist, they're generally different.

Intuition

Why this strange rule? Because matrices are secretly functions, and multiplication is secretly composition. Picture two photo filters: BB blurs, AA darkens. "Blur, then darken" is itself one combined filter — that filter is ABAB (read right-to-left: BB acts first). The row-times-column recipe is exactly the arithmetic that makes (AB)x=A(Bx)(AB)\mathbf{x} = A(B\mathbf{x}) come out true. Matrix multiplication isn't an arbitrary convention — it's function composition wearing a numerical disguise.

And why does order matter? Socks then shoes ≠ shoes then socks. Rotate a page then slide it right ≠ slide then rotate. Same two operations, different order, different world: ABBAAB\neq BA in general.

Facts you'll use forever: (AB)C=A(BC)(AB)C=A(BC), A(B+C)=AB+ACA(B+C)=AB+AC, ImA=AIn=AI_mA=AI_n=A, λ(AB)=(λA)B\lambda(AB)=(\lambda A)B, and for transposes — writing rows as columns, bij=ajib_{ij}=a_{ji} — the order-flipping rules (AT)T=A(A^T)^T=A, (A+B)T=AT+BT(A+B)^T=A^T+B^T, (AB)T=BTAT(AB)^T=B^T A^T. A few matrices to greet by name: the identity II (the do-nothing filter), the zero matrix (destroy everything), diagonal matrices (stretch each axis independently), and symmetric matrices A=ATA=A^T — the nicest citizens of linear algebra; Unit 4 is very fond of them.

Why (AB)ᵀ = BᵀAᵀ — the two-line argument from the slides

The (i,j)(i,j) entry of ABAB is (row ii of AA) · (column jj of BB). But row ii of AA is column ii of ATA^T, and column jj of BB is row jj of BTB^T. So the (j,i)(j,i) entry of BTATB^TA^T is that same inner product — i.e. (BTAT)ji=(AB)ij(B^TA^T)_{ji}=(AB)_{ij}, which is precisely the statement BTAT=(AB)TB^TA^T=(AB)^T. Notice the composition story hiding here too: undoing "socks then shoes" requires "shoes off, then socks off" — reversal flips order.

Pause & predict

Without computing anything: (AB)T(AB)^T equals…

6

Pause. Stare at Ax = b through three windows.

This is the most important section of the unit. One tiny system, three ways of seeing it — and switching between them at will is the single most useful skill in linear algebra. Whenever you're stuck, ask: which window would let me see this clearly? Our toy system:

2x1+x2=5x1+3x2=5A=(2113),  b=(55),answer x=(21).\begin{aligned}2x_1+x_2&=5\\ x_1+3x_2&=5\end{aligned}\qquad\Longleftrightarrow\qquad A=\begin{pmatrix}2&1\\1&3\end{pmatrix},\ \ \mathbf{b}=\begin{pmatrix}5\\5\end{pmatrix},\qquad\text{answer } \mathbf{x}=\begin{pmatrix}2\\1\end{pmatrix}.
The same equation, three ways

Each row of AA, paired with its entry of b\mathbf{b}, is one rule the answer must obey. Rule 1: 2x1+x2=52x_1+x_2=5. Rule 2: x1+3x2=5x_1+3x_2=5. Geometrically each rule is a line (a plane in 3D, a hyperplane beyond). Solving = finding the point that obeys every rule at once — here, the crossing at (2,1)(2,1).

This is the schoolbook view — and it scales: ten equations, ten hyperplanes, one intersection.

Now ignore the rows. See the columns: a1=(21)\mathbf{a}_1=\binom{2}{1}, a2=(13)\mathbf{a}_2=\binom{1}{3}. A line of algebra shows Ax=x1a1+x2a2A\mathbf{x}=x_1\mathbf{a}_1+x_2\mathbf{a}_2 — so x\mathbf{x} is a shopping list: how much of each ingredient-column to mix so the pot equals b\mathbf{b}?

0.8
2.4
Mix the columns to hit b.

The set of everything you could ever cook from these columns is the column space of AA. If b\mathbf{b} lives inside it, a recipe exists; if not, no solution — a fact that will run the show in Section 12.

The deepest view. AA is a function: feed it any vector x\mathbf{x}, it outputs AxA\mathbf{x} — it moves all of space. Then Ax=bA\mathbf{x}=\mathbf{b} asks the question backwards: you can see the output b\mathbf{b}; which input x\mathbf{x} produced it?

0%

Watch the violet input x=(2,1)\mathbf{x}=(2,1) get carried onto the target b=(5,5)\mathbf{b}=(5,5) as the grid deforms.

Aha

Picture a vending machine. The chocolate bar b\mathbf{b} is sitting in the tray; your job is to figure out which button code x\mathbf{x} was punched in. Three questions decide everything — can the code be recovered? could multiple codes give the same item? could no code give it? — and all three are properties of the machine itself, not of the particular bar in the tray. Keep this view alive: 3Blue1Brown's Essence of Linear Algebra builds everything on it, and so will we.

Pause & predict

In the column window, "solve Ax=bA\mathbf{x}=\mathbf{b}" translates to…

7

A matrix is a Photoshop filter for space

Here's the picture to burn into your brain. Feed AA the two basis arrows ı^=(10)\hat\imath=\binom{1}{0} and ȷ^=(01)\hat\jmath=\binom{0}{1}. Then Aı^A\hat\imath is literally the first column of AA, and Aȷ^A\hat\jmath is the second column. That's not a coincidence — that's the entire game. Once you know where those two arrows land, linearity fixes everything else: Ax=x1(Aı^)+x2(Aȷ^)A\mathbf{x}=x_1(A\hat\imath)+x_2(A\hat\jmath). Four numbers, two arrows, one whole transformation of the plane.

And the determinant? The unit square (area 1) becomes a parallelogram; detA\det A is the factor by which area got scaled — with a sign that records whether the plane got mirror-flipped. For a 2×22\times2 matrix, detA=a11a22a12a21\det A = a_{11}a_{22}-a_{12}a_{21}. Don't memorize first — watch first:

The space machineevery linear map: lines stay lines, origin stays put, parallels stay parallel
A = type any entries
(−10 … 10)
det A = 1.00 area ×1.00
Space intact.

det > 0: orientation kept. det < 0: the plane got mirrored (watch î and ĵ swap sides). |det| is the area factor: rotation = +1, reflection = −1. And det = 0 is the drama: the parallelogram squashes flat, a whole dimension dies, and the Undo button goes dark — like juicing a fruit, there's no un-juicing it. When that happens, two ghost lines appear: the violet one is the null space — every vector on it gets crushed to the origin — and the aqua one is the column space, the thin line where all outputs now live. Push the entries to ±10 and watch the view zoom out to keep up.

Watch out

When det A=0A=0, three sentences become one fact told in three languages: ① AA is not invertible — no undo exists. ② The columns are linearly dependent — one is a blend of the others, so they bring no new direction. ③ Many inputs share one output — like a filter so aggressive that a hundred different photos come out identical. Get fluent at translating between the three; the exam (and real ML) will phrase it randomly. We'll meet this monster again under the name singular matrixsingular as in: a whole dimension's worth of vectors all collapsing into one point, the origin.

Up a dimension: the determinant is a volume

Nothing about the area story was special to 2D. In 3D, a matrix AR3×3A\in\mathbb{R}^{3\times3} carries the unit cube (volume 1) to a slanted box — a parallelepiped — and detA\det A is its signed volume. In nn dimensions, detA\det A scales hyper-volume: the same idea, just past where drawing stops working. Grab the box below and spin it:

Determinant in 3D — the volume machinedrag the picture to orbit · edit A freely
A =
det A = 1.00 volume ×1.00 rank 3
A full 3-D volume — all three directions alive.

The dashed ghost is the original unit cube. Shear is the sleeper hit: the box leans hard, yet det stays 1 — leaning is not shrinking. And watch the collapses: rank 2 flattens the box to a sheet (volume 0), rank 1 crushes it to a line, rank 0 to a single point. det = 0 and rank < 3 are the same event seen by two different instruments.

Pause & predict

You compute detA=0\det A = 0 for a 2×22\times2 matrix. Which of the following must be true?

8

The undo button — A⁻¹

If AA is "translate to French," A1A^{-1} is "translate back." The matrix that exactly reverses AA satisfies A1A=AA1=IA^{-1}A = AA^{-1} = I — do, then undo, and you're back where you started. If it exists, solving becomes one line: Ax=bx=A1bA\mathbf{x}=\mathbf{b}\Rightarrow \mathbf{x}=A^{-1}\mathbf{b}.

Does every square matrix have one? The slides settle it constructively for 2×22\times 2: pair AA with the candidate B=(a22a12a21a11)B=\begin{pmatrix}a_{22}&-a_{12}\\-a_{21}&a_{11}\end{pmatrix} and multiply — everything cancels except AB=(a11a22a12a21)I2AB=(a_{11}a_{22}-a_{12}a_{21})\,I_2. So

A1=1a11a22a12a21(a22a12a21a11),legal exactly when detA0.A^{-1}=\frac{1}{a_{11}a_{22}-a_{12}a_{21}}\begin{pmatrix}a_{22}&-a_{12}\\-a_{21}&a_{11}\end{pmatrix},\qquad\text{legal exactly when } \det A\neq 0.

The determinant sits downstairs — divide by zero and the formula explodes. That's the algebra shaking hands with the geometry you just played with: the inverse exists iff space wasn't squashed flat. (Non-square matrices don't get a true inverse at all; their story — least squares — comes later in the course.)

Try it yourself

For our toy A=(2113)A=\begin{pmatrix}2&1\\1&3\end{pmatrix}: detA=2311=5\det A = 2\cdot3-1\cdot1=5, so A1=15(3112)A^{-1}=\tfrac15\begin{pmatrix}3&-1\\-1&2\end{pmatrix}. Multiply A1(55)A^{-1}\binom{5}{5} by hand and confirm you land on (21)\binom{2}{1} — the same answer the two crossing lines gave you in Section 6. Three windows, one truth.

Watch out

If A1A^{-1} is so beautiful, why do practitioners avoid computing it? Strike zero: it often doesn't exist at all. x=A1b\mathbf{x}=A^{-1}\mathbf{b} is only even a legal sentence when AA is square and full rank — a singular matrix has no inverse, a rectangular data matrix (the everyday case in ML: 10,000 examples × 50 features) never has one. Elimination keeps working in every one of those worlds; the inverse simply isn't there. And even when A1A^{-1} does exist, three more strikes. It's expensive — about the cost of solving the system, times a painful constant, and in ML AA can be 10,000×10,00010{,}000\times10{,}000. It's fragile — if AA is nearly singular, the inverse is full of huge almost-cancelling entries and floating-point noise blows up silently. It's wasteful — you wanted x\mathbf{x} for one particular b\mathbf{b}, not a master key for every apartment in the building. Industry rule: if you see np.linalg.inv(A) @ b in production, replace it with np.linalg.solve(A, b). Same answer, faster, more stable.

"Fragile" deserves to be felt, not just read. Here is a system whose true answer is always (1,1)(1,1) — and a dial that slides its matrix toward singularity:

The master-key trapwatching x = A⁻¹b fall apart as det → 0
1
0

The system   x+y=2,    x+(1+ε)y=2+ε  \;x+y=2,\;\; x+(1+\varepsilon)y=2+\varepsilon\; has detA=ε\det A=\varepsilon and

A⁻¹ = 2−1−11
det = 1 error amplified ×1.4
Comfortably invertible.

δ plays a tiny measurement error — a sensor wobble in your data. The true answer sits at (1, 1); the computed one is (1−δ/ε, 1+δ/ε). As ε shrinks, the entries of A⁻¹ blow up like 1/ε and your innocent wobble gets multiplied by them. This is det → 0 in slow motion: the lines close like scissors, and the intersection skates away on a hair-trigger. solve suffers too near singularity — but it doesn't manufacture a giant explicit A⁻¹ full of almost-cancelling numbers to do it.

Pause & predict

You need x\mathbf{x} for one system Ax=bA\mathbf{x}=\mathbf{b} in production code. The professional move is…

9

A system with training wheels

Before building the general algorithm, the slides hand us a system so friendly it solves itself — if we look through the column window:

(108401212)(x1x2x3x4)=(428)\begin{pmatrix}1&0&8&-4\\0&1&2&12\end{pmatrix}\begin{pmatrix}x_1\\x_2\\x_3\\x_4\end{pmatrix}=\begin{pmatrix}42\\8\end{pmatrix}

Two equations, four unknowns — underconstrained, so expect infinitely many solutions. But look at the first two columns: (10)\binom{1}{0} and (01)\binom{0}{1}. They can build any target instantly. So read b\mathbf{b} straight off: take 42 of column 1, 8 of column 2, none of the rest —

xp=(42, 8, 0, 0)T— the particular solution.\mathbf{x}_p=(42,\ 8,\ 0,\ 0)^T \quad\text{— the \textbf{particular} solution.}

Any other solutions? Here's the trick that unlocks the whole topic: you can add zero to a solution and it stays a solution — provided you write zero cleverly, as a blend of columns that cancels out. Column 3 is buildable from the first two: 8c1+2c2c3=08\mathbf{c}_1+2\mathbf{c}_2-\mathbf{c}_3=\mathbf{0}. In matrix form:

(108401212)(8210)=(00)\begin{pmatrix}1&0&8&-4\\0&1&2&12\end{pmatrix}\begin{pmatrix}8\\2\\-1\\0\end{pmatrix}=\begin{pmatrix}0\\0\end{pmatrix}

— and likewise for column 4: 4c1+12c2+0c3c4=0-4\mathbf{c}_1+12\mathbf{c}_2+0\mathbf{c}_3-\mathbf{c}_4=\mathbf{0}. Any multiple λ1(8,2,1,0)T\lambda_1(8,2,-1,0)^T or λ2(4,12,0,1)T\lambda_2(-4,12,0,-1)^T is an invisible ingredient: add it to xp\mathbf{x}_p and the machine still outputs exactly b\mathbf{b}. The complete answer:

{xR4: x=(42800)one valid answer+ λ1(8210)wiggle+ λ2(41201)wiggle,  λ1,λ2R}\Big\{\,\mathbf{x}\in\mathbb{R}^4:\ \mathbf{x}=\underbrace{\begin{pmatrix}42\\8\\0\\0\end{pmatrix}}_{\text{one valid answer}}+\ \lambda_1\underbrace{\begin{pmatrix}8\\2\\-1\\0\end{pmatrix}}_{\text{wiggle}}+\ \lambda_2\underbrace{\begin{pmatrix}-4\\12\\0\\-1\end{pmatrix}}_{\text{wiggle}},\ \ \lambda_1,\lambda_2\in\mathbb{R}\,\Big\}
Imagine this

You walk into a sandwich shop. House rule: every sandwich must contain bread and a protein — that's the constraint, the "Ax=bA\mathbf{x}=\mathbf{b}" part. Beyond that, add any toppings you like. The particular solution is the pre-made base sandwich; the toppings are the wiggle directions. Every legal sandwich = base + your topping combination. In math clothes: the wiggle directions solve Ax=0A\mathbf{x}=\mathbf{0}, their span is called the null space of AA, and

full solution set of Ax=bA\mathbf{x}=\mathbf{b} = any one solution + null space of AA.

You will meet this formula again in linear regression, in optimization, and inside neural networks.

Two honest questions before moving on. Why isn't the particular solution unique? Because any point of the solution set can play the "anchor" role — the pre-made sandwich could just as well be a different sandwich from the menu. Why aren't the wiggle vectors unique? Any two independent blends of them span the same null space. What is unique is the solution set itself — the flat sheet they describe. But wait — those "invisible ingredients" just quietly became the most important object in this unit. Before we build the big algorithm, they deserve their own spotlight.

10

The null space — the machine's blind spot

Imagine this

A flashlight throws your hand's shadow onto a wall. The shadow-maker is a machine: 3D hand in, 2D shadow out. Now slide your hand straight along the beam, toward the flashlight. The shadow doesn't move. Not a pixel. That beam direction is invisible to the machine — motion along it produces zero change in the output. And because of that one invisible direction, any shadow you see could have been cast from infinitely many hand positions, all lined up along the beam.

Every matrix has a blind spot like that beam (sometimes it's just the trivial one). It has a name and a definition worth engraving:

N(A)  =  {xnRn  :  Axn=0}N(A)\;=\;\{\,\mathbf{x}_n \in\mathbb{R}^n \;:\; A\mathbf{x}_n=\mathbf{0}\,\}

— the null space: every input the machine sends to zero. (The subscript is a habit worth copying: xn\mathbf{x}_n for "null solution," the inputs that answer the homogeneous question Ax=0A\mathbf{x}=\mathbf{0}.) It's never empty: A0=0A\mathbf{0}=\mathbf{0} always, so the origin is in every null space. The interesting question is whether anything else is — and here is exactly why you should care:

Aha

The null space is why solutions come in families. Suppose xp\mathbf{x}_p solves your problem: Axp=bA\mathbf{x}_p=\mathbf{b}. Take any null vector xn\mathbf{x}_n and add it. Linearity does the rest:

A(xp+λxn)  =  Axp+λAxn=  0  =  b+λ0  =  bfor every λ.A(\mathbf{x}_p+\lambda\,\mathbf{x}_n)\;=\;A\mathbf{x}_p+\lambda\,\underbrace{A\mathbf{x}_n}_{=\;\mathbf{0}}\;=\;\mathbf{b}+\lambda\,\mathbf{0}\;=\;\mathbf{b}\qquad\text{for every }\lambda.

The machine cannot tell xp\mathbf{x}_p and xp+λxn\mathbf{x}_p+\lambda\mathbf{x}_n apart — they're perfect aliases, hand positions along the beam. And the converse seals it: if u\mathbf{u} and v\mathbf{v} both solve Ax=bA\mathbf{x}=\mathbf{b}, then A(uv)=bb=0A(\mathbf{u}-\mathbf{v})=\mathbf{b}-\mathbf{b}=\mathbf{0} — any two solutions differ by a null vector. Nothing lives outside the family. Together, the two directions give the complete anatomy of every solution set:

solutions of Ax=bA\mathbf{x}=\mathbf{b} == xp\mathbf{x}_p ++ all of N(A)N(A) — one anchor, plus the whole blind spot.

Watch the whole story run live. The system below is singular on purpose — A=(1224)A=\begin{pmatrix}1&2\\2&4\end{pmatrix} (rank 1, second row a copy of the first), b=(48)\mathbf{b}=\binom{4}{8}, null direction xn=(21)\mathbf{x}_n=\binom{-2}{1} (check: Axn=(2+24+4)=0A\mathbf{x}_n = \binom{-2+2}{-4+4}=\mathbf{0}). Slide λ\lambda and keep one eye on each panel:

The blind-spot machinethe input walks the solution line — the output never feels it
INPUT SPACE — where x lives
OUTPUT SPACE — where Ax lands
0.6

✓ output frozen at b

Left: the violet dashed line through the origin is N(A)N(A) itself — a bona-fide space (contains 0, closed under adding and scaling: the closure promise of Section 2). The solid line through xp\mathbf{x}_p is the solution set — the same line, picked up and parked at xp\mathbf{x}_p. Parallel, but not through the origin, so the solution set of Ax=bA\mathbf{x}=\mathbf{b} (with b0\mathbf{b}\neq\mathbf{0}) is not a subspace — it's the null space wearing an anchor. Right: as you slide λ\lambda, the input moves but AxA\mathbf{x} stays glued to b\mathbf{b}, because the λxn\lambda\mathbf{x}_n part is swallowed whole: A(λxn)=0A(\lambda\mathbf{x}_n)=\mathbf{0}. Notice also that every possible output lives on the aqua line — the column space — which is why this rank-1 machine can only ever be solved for targets on that line.

Watch out — this is everywhere in ML

Put two perfectly correlated columns in your data matrix — say, temperature in °C and the same temperature in °F — and you have just manufactured a null space: some combination of those features is invisible to the model. Consequence: infinitely many weight vectors produce identical predictions, your regression "can't decide," and its coefficients can swing wildly without changing the fit. That is a null space attacking in the wild. Ridge regularization is, quite literally, the policy "among all aliases, pick the shortest x\mathbf{x}" — you'll meet it later in the course, and you'll recognize it.

How big is the blind spot? Each independent null direction is one dimension of invisibility — a line, a plane, or more. The exact count will fall out of elimination in Sections 11–12: one free variable per missing pivot, dimN(A)=nrank(A)\dim N(A)=n-\operatorname{rank}(A). And when the blind spot is just {0}\{\mathbf{0}\}? Then aliases don't exist, and solutions — when they exist — are unique. You already know that case by its other names: full rank, det0\det\neq 0, invertible.

Pause & predict

x0\mathbf{x}_0 solves Ax=bA\mathbf{x}=\mathbf{b} (with b0\mathbf{b}\neq\mathbf{0}), and xn0\mathbf{x}_n\neq\mathbf{0} lies in N(A)N(A). Which of these is guaranteed to be another solution?

11

Gaussian elimination — the polite-maker

Hand-elimination worked for chairs and tables, but a million-variable regression needs a procedure with no moods and no choices: same kind of step every time, guaranteed to finish, and a verdict — which of the three fates — at the end. That's what an algorithm is. Here it is.

First, glue AA and b\mathbf{b} into one grid — the augmented matrix [Ab][A\,|\,\mathbf{b}]. Then use exactly three legal moves, each one an honest re-statement of the equations: ① swap two rows (re-order the equations); ② scale a row by λ0\lambda\neq 0 (multiply both sides); ③ add a multiple of one row to another (add equal things to equal things). Each move is reversible, so the solution set never changes. We are not solving a different problem — we're rewriting the same problem until the answer becomes obvious. The target shape: pivots marching down-and-right in a staircase, zeros below — row-echelon form (REF).

The elimination machinewatch the staircase appear
Step 0/0

Formally, a matrix is in row-echelon form when all-zero rows sit at the bottom, and each row's first non-zero entry — its pivot — lies strictly to the right of the pivot above, with only zeros beneath it. Variables owning a pivot column are basic (bound); the rest are free. And notice what the last row of the big example did for us: it distilled the entire system's fate into one sentence, "0=a+10 = a+1" — consistent only when a=1a=-1. Elimination doesn't just solve systems; it diagnoses them.

Pause & predict

Move ② lets you scale a row by any λ0\lambda \neq 0. Why exactly is λ=0\lambda = 0 forbidden?

12

RREF — hospital corners, and two magic tricks

REF is making your bed: sheets tucked, sleepable. Reduced row-echelon form is hospital corners: keep going until every pivot equals 1 and is the only non-zero entry in its column — sweep upward too. Pivot columns become canonical basis vectors, and the answers sit on the right of the bar, ready to read. Unlike REF (which depends on your route), RREF is unique — it's the matrix's fingerprint.

Trick 1: solving Ax=0A\mathbf{x}=\mathbf{0} by inspection. Take this RREF from the slides:

A=(130030010900014)A=\begin{pmatrix}1&3&0&0&3\\0&0&1&0&9\\0&0&0&1&-4\end{pmatrix}

The pivot columns (1, 3, 4) are "strong enough" to build the non-pivot columns (2, 5). Column 2 = 3×column 1, so 3·c₁ − 1·c₂ = 0 gives the solution (3,1,0,0,0)T(3,-1,0,0,0)^T. Column 5 = 3c₁ + 9c₃ − 4c₄, giving (3,0,9,4,1)T(3,0,9,-4,-1)^T. Spot the pattern — copy the non-pivot column's recipe, then put a −1 in that column's own slot. Every free column donates one null-space direction, and the general solution is their span.

Now the full dish — an infinite-solutions system, cooked end to end. Same matrix, but with a target on the right:

(130032001091000141)\left(\begin{array}{ccccc|c}1&3&0&0&3&2\\0&0&1&0&9&1\\0&0&0&1&-4&-1\end{array}\right)

Because the pivot columns are canonical basis vectors, the particular solution is read straight off the bar: put each right-hand entry into its pivot variable's slot, zeros for the free variables — xp=(2,0,1,1,0)T\mathbf{x}_p=(2,0,1,-1,0)^T. Bolt on the two null-space directions we just found, and the entire infinite family is:

x=(20110)one answer+  λ1(31000)null dir.+  λ2(30941)null dir.,λ1,λ2R.\mathbf{x}=\underbrace{\begin{pmatrix}2\\0\\1\\-1\\0\end{pmatrix}}_{\text{one answer}}+\;\lambda_1\underbrace{\begin{pmatrix}3\\-1\\0\\0\\0\end{pmatrix}}_{\text{null dir.}}+\;\lambda_2\underbrace{\begin{pmatrix}3\\0\\9\\-4\\-1\end{pmatrix}}_{\text{null dir.}},\qquad\lambda_1,\lambda_2\in\mathbb{R}.
Aha

The null space is not a bag of leftovers — it's a space. Check the closure promise from Section 2: if Au=0A\mathbf{u}=\mathbf{0} and Av=0A\mathbf{v}=\mathbf{0}, then A(u+v)=0A(\mathbf{u}+\mathbf{v})=\mathbf{0} and A(λu)=0A(\lambda\mathbf{u})=\mathbf{0}. Add two invisible ingredients, or scale one — still invisible. The null space passes the vector-space entrance exam, and its size is bookkept by a beautiful ledger: each free column donates exactly one direction, so

dim(null space)=nrank(A)\dim(\text{null space}) = n - \operatorname{rank}(A)  (here 53=25-3=2) — the rank–nullity theorem in street clothes.

Every pivot is a rule that pins a variable down; every missing pivot is a freedom left over. Information used + freedom remaining = number of unknowns. In Unit 2 (Vector Spaces) the null space and column space graduate into first-class citizens — with bases, dimensions, and the full geometry. You've already met them; there you'll learn their language.

Trick 2: the inverse, for free. If AA is invertible, its RREF is II itself. Now stack [AI][A\,|\,I] and row-reduce the left half to II: the right half silently becomes A1A^{-1}. Why? Solving Ax=eiA\mathbf{x}=\mathbf{e}_i for each basis vector recovers column ii of A1A^{-1} — and the augmented block runs all nn of those systems at once: [AI][IA1][A\,|\,I]\to[I\,|\,A^{-1}]. Elimination "knows" how to invert — even though (Section 8!) you'll rarely ask it to.

13

Rank — one number that settles everything

Intuition

Three friends in a group chat: whenever one speaks, the other two repeat it. Three people, one opinion — effectively a one-person chat. Rank counts the genuinely different voices in a matrix: the number of pivots that survive elimination — the number of truly independent directions its columns carry.

One digit can change everything:

B=(123456789)  rank 2,C=(1234567810)  rank 3.B=\begin{pmatrix}1&2&3\\4&5&6\\7&8&9\end{pmatrix}\ \ \text{rank }2,\qquad C=\begin{pmatrix}1&2&3\\4&5&6\\7&8&\mathbf{10}\end{pmatrix}\ \ \text{rank }3.

In BB, row₃ − 2·row₂ + row₁ = 0 — one row is hiding inside the other two, an agreeing friend. Change the 9 to a 10 and the dependency snaps: three real voices. Headline fact: a square n×nn\times n matrix is invertible     \iff rank =n=n     \iff det0\det\neq 0     \iff columns independent. One fact, now four languages.

Here's the profound part. Think of a matrix as a message. Rank counts the words that aren't repeats — the genuinely non-redundant information it carries. And you can count from two different sides. The row rank asks: how many of the rows are independent rules (rules that aren't blends of other rules)? The column rank asks: how many of the columns are independent ingredients (directions the recipe can actually reach)? These are different questions about different objects — rows live in Rn\mathbb{R}^n, columns in Rm\mathbb{R}^m — and yet:

Aha

Row rank = column rank. Always. Every matrix, every shape, no exceptions — which is why we get away with saying just "rank." It's one of linear algebra's quiet miracles: the number of independent rules a matrix imposes equals the number of independent directions it can produce. (Elimination shows why: each pivot simultaneously certifies one independent row and one independent column — the staircase counts both at once.) Two ceilings follow instantly: rank can't exceed the number of rows, and can't exceed the number of columns, so rank(A)min(m,n)\operatorname{rank}(A)\le\min(m,n). A matrix at that ceiling is called full rank — zero redundancy, every word in the message new.

And the collapse dictionary is now complete: det=0\det=0     \iff rank below the ceiling     \iff area/volume crushed to 0     \iff singular. Drop by one rank in 3D and the cube flattens to a sheet; by two, to a line — you watched exactly this in the volume machine of Section 7. Rank is how many dimensions survive the transformation.

And rank answers the existence question completely — the three lines the whole unit was building toward:

Existence & uniqueness, in three lines

At least one solution     rank(A)=rank([Ab])\iff \operatorname{rank}(A)=\operatorname{rank}([A|\mathbf{b}]) — i.e. b\mathbf{b} lies in the column space; the recipe can be cooked.

Exactly one     \iff ① holds and rank(A)=n\operatorname{rank}(A)=n, the number of unknowns — no free variables, no wiggle room.

Infinitely many     \iff ① holds and rank(A)<n\operatorname{rank}(A)<n — free variables exist, the null space is alive.

Watch all three lines come true in 3D. Same first two planes every time; only the third equation changes — and the rank chips tell each fate before your eyes do:

Three planes, three fates — through the rank lensdrag to orbit · each equation is a plane in 3D
rank(A) = 3 rank([A|b]) = 3 n = 3

Pause & predict

Elimination on a 3-unknown system leaves rank(A)=rank([Ab])=2\operatorname{rank}(A)=\operatorname{rank}([A|\mathbf{b}])=2. What is the solution set?

Pause & predict

AR5×7A\in\mathbb{R}^{5\times 7} with rank(A)=5\operatorname{rank}(A)=5. For a given b\mathbf{b}, how many solutions can Ax=bA\mathbf{x}=\mathbf{b} have?

14

The whole story, in five lines

① Linear systems matter because the world is locally linear, and ML is stacks of linear pieces with non-linear glue. ② Ax=bA\mathbf{x}=\mathbf{b} is three pictures at once — row rules, column recipe, machine — keep all three windows open. ③ x=A1b\mathbf{x}=A^{-1}\mathbf{b} is beautiful theory and poor practice: solve, don't inv. ④ Gaussian elimination → staircase → read off solutions, rank, inverse, and the system's fate. ⑤ Everything else this semester — LU, Cholesky, QR, even SVD — is a smarter flavor of the same elimination move.

The one thing to remember

One image: a matrix is a machine that moves space; solving Ax=bA\mathbf{x}=\mathbf{b} asks which input the machine turned into that output. One method: elimination on [Ab][A|\mathbf{b}] until the staircase appears. One number: rank — the matrix's real dimension, and the judge of all three fates.

What's coming — every later method is elimination in disguise
MethodIn one sentenceWhere
LUElimination, recorded — factor once, solve many b's cheaply.Units 2–3
CholeskyElimination exploiting symmetry — half the work.Unit 4
QR / least squaresElimination by rotations — the right move when no exact solution exists; the math behind regression.Units 3, 7
Eigen / SVDThe deepest factorization: any matrix = rotation · stretch · rotation. Route to PCA.Units 4–5, 12–13
Next up

Unit 2 · Vector Spaces

We zoom out: which sets of vectors are independent? What spans a plane? What's a basis? The universe where all these objects live — and the matrix-as-machine picture keeps paying dividends. Open Unit 2 →