◈ quant roadmapPart 0 · Ch 06/45
Quantitative Finance — the Mathematics of Markets · chapter 06

06Vectors & Matrices

Chapter 5 closed on a grid it could not handle. Every number in that chapter was a scalar, one price or one rate at a time, and the machinery worked beautifully for exactly one asset. Nobody holds one asset. A year of daily returns for forty stocks is 10,080 numbers arranged in rows and columns, and no amount of careful scalar algebra will make that tractable. So here we build the two objects that will carry the rest of the course. A vector is an ordered list of numbers, and a matrix is what transforms one. I want to give away the punchline now, because the punchline is the reason to walk the road. A matrix is not a box of numbers with a strange multiplication rule attached. It is a function that moves all of space at once, and its four little entries are nothing more than a record of where two arrows landed. Once you see that, the whole vocabulary that usually has to be memorised collapses into one question. Did the transformation keep space full, or did it crush space flat? Everything else in this chapter, and the reason a regression on two nearly identical stocks explodes, is that one question asked in different words.

Here is where this chapter sits. Chapter 5 gave us e^{rT}, e^{−rT} and additive log returns, and every one of them tracks a single stream of money. Now the objects get wider. Click any downstream node and watch the road run back to this page.

THE COURSE SPINE · Part 0 → the Act · tap a blue chapter ↓ Part 0 Ch 5 one number ◆ YOU ARE HERE Ch 6 Vectors & Matrices Ch 7 · eigen / SVD Ch 18 · covariance Ch 20 · OLS Ch 24 · PCA Ch 30 · Markowitz tap a blue chapter → each downstream tool is a question you can only ask once this chapter exists.
−.014 one number 1 number scale up: 252 days × 40 = 10,080 numbers
Ch 5's whole world: 1 number
SCALAR is the Ch-5 world. Flip to VECTOR and watch the count climb.
What you're looking at — why Chapter 5 had to stop where it did
Ch 6 is the hinge — every gold road leads back here
the objects it gives you (vectors, matrices) and every later tool that reuses them
the foundation already built: Part 0 → Ch 5, one scalar at a time
Ch 5's tools (erT, additive log returns) each move one number. 252 days × 40 stocks = 10,080. The gap isn't difficulty — it's width: we need objects that hold many numbers, and rules to transform them.
Fig. 1. The whole course on one spine, with Chapter 6 lit gold. Tap any downstream blue chapter — eigen/SVD, the covariance matrix, OLS, PCA, Markowitz — and a gold road traces back to here, naming the exact thing it borrows. Then flip the SCALAR / VECTOR switch: Ch 5's lone number fans into a 5-day column, then a 5×4 grid, and the counter climbs 1 → 5 → 20 → 10,080 (252 days × 40 stocks). That is the wall Ch 5 hit, stated as a number — the gap isn't difficulty, it's width.

Let's start with the smallest object that holds more than one number.

01One list, two pictures

Take two numbers and write them in a fixed order: (3, 2). Chapter 1 already gave you one way to read that. It is a point on the plane, three steps right and two steps up, and you can put your finger on it. Draw an arrow from the origin out to that point and you have the second reading, which is the same thing wearing a different coat. The arrow has a direction and a length, and both of those are fully determined by the two numbers.

Add a third number and nothing breaks. (3, 2, 5) is a point in the room you are sitting in: three steps along the floor, two steps across it, five steps up. You can still picture it, just about.

Now the second picture, and it comes from the last chapter. A stock's Monday log return is one number, and Tuesday's is another. Stack a whole trading year in order and you are holding 252 numbers in a fixed sequence. That is exactly the same kind of object: an ordered list. So a year of Apple is a single point in 252-dimensional space, and I want to be blunt about what that sentence does and does not ask of you.

One list, two pictures — and the dial that kills the drawing
the picture v₀ v₁ drag the dot → the bars move the data strip — same list, as bars drag a bar → the dot moves the SAME two operations run entry by entry — watch them survive scale by 1.5 add a second list w
The same list of numbers, two windows. A dimension dial stretches the list — watch the left drawing die at four while the ledger below never blinks.
n = 2 · a dot on the plane
What you're looking at — one object, drawn two ways, then pushed past where it can be drawn
the list v — a dot & arrow on the left, the bars on the right: the same numbers
a second list w, the thing we add
the answer — the arithmetic, entry by entry
where the picture dies (4+ dims) — the maths does not
Fig. 2. Drag the blue dot on the plane and the bars on the right follow — or drag a bar and the dot moves: one list of numbers, read as a point in space and as a column of data. Now turn the dimension dial. At 2 it is a dot on a plane; at 3 the plane tilts into a room; at 5 the picture greys out with an honest "no picture available"; at 252 the strip becomes a real year of daily log returns and the left panel stays dark. The whole time, the ledger below runs the same two operations — scale by 1.5, add a second list — entry by entry. You lose the drawing at four dimensions. You lose nothing else: the arithmetic that worked on two numbers works letter for letter on 252.

It does not ask you to see it. Nobody can picture 252 dimensions, including the people who work in them every day, and the honest thing is to say so out loud. What it asks is much smaller. Every operation we are about to define works entry by entry, so whatever worked on the two-number list works letter for letter on the 252-number one. Drag the dimension dial in that panel and watch the drawing give up while the arithmetic strip beside it keeps running. That gap between what you can draw and what you can compute is the whole trick, and it never causes trouble again.

Now the definition, with both pictures in hand. A vector is an ordered list of numbers, and its dimension is how long the list is. Order matters, because (3, 2) and (2, 3) are different points, and each slot means a specific thing: a coordinate, or a Tuesday.

02Scale it, add it, mix it

There are only two things you can do to a list of numbers, and both are obvious once written down. You can scale it, which means multiply every entry by the same number. You can add two lists of the same length, which means add them entry by entry. That is the complete toolkit.

The only two moves — stretch one arrow, or lay a second one tip to tail
O u v c·u the entry table slot 1 slot 2 u 2 1 × c ×2 ×2 c·u 4 2 each slot × the same c
c=2 · doubled, direction pinned
What you're looking at — the two, and only two, moves on a list of numbers
u = the arrow under study; its slots are the numbers in the table
v = the second arrow; ADD slides it tip-to-tail onto u's head
gold = the result — the stretched c·u, or the landed sum u+v
red = the break: a 3-slot v has no partner for its extra slot
Fig. 3. Every piece of vector arithmetic is one of exactly two moves — and the plane and the table are the same move said two ways. Scale each slot: drag c and the gold ghost c·u stretches (c=2 doubles), flips through the origin (c=−1), or collapses to a point (c=0), never leaving its pinned line — because multiplying each entry by the same c is exactly what “stretch the arrow” means. Add slot by slot: press ADD and v slides tip-to-tail onto u's head to land the gold sum u+v; press commute and v-then-u completes the parallelogram the other way onto the identical point — laying arrows tip-to-tail is adding the slots. The break-it chip offers a 3-slot v and the addition refuses: entry-by-entry needs the same number of entries. That is the whole of it — scale every slot, or add slot to slot. There is no third move.

Each move has a picture on the plane, and the pictures are worth holding. Scaling by 2 stretches the arrow to double its length without turning it at all. Scaling by −1 flips it to point the opposite way. Adding two vectors lays the second arrow's tail on the first arrow's head, and the sum is the arrow from the origin to where you finish. Toggle the panel between the arrow view and the entry view and the two stay locked together, because they are the same arithmetic.

Now do both at once, on something real. You put 60% of your money into Apple and 40% into Google. Apple's week of returns is one vector, Google's is another, and your portfolio's week is 0.6 times the first plus 0.4 times the second. Scale each one, then add them up.

Build a portfolio with a slider — scale each return stream by its weight, then add
0.60×AAPL 0.40×GOOG = BLEND + MSFT ✓ = AAPL exactly
Apple 60% · Google 40%
0.92 0.16 0.90 0.68 −0.82
What you’re looking at — a portfolio, before it has that name
Apple’s 5‑day return vector, each bar shrunk to its weight (dashed outline = the full, unweighted bar).
Google’s return vector, shrunk the same way — push the weight negative and it flips to lean against the blend.
the blend = the blue piece stacked on the violet piece, day by day. Scale each vector, then add — that move is a linear combination, and every matrix in this chapter is it in a costume.
Fig. 4. Two return streams, a weight slider, and a third row that assembles as the sum of the two scaled bars. Drag the mix: at 60/40 the blend reads 0.92, 0.16, 0.90, 0.68, −0.82; push it to 100/0 and the blend snaps exactly onto Apple (the “a mix of one thing IS that thing” lamp lights); flip on allow shorts to send a weight negative and watch the blend lean against Google. Switch on a third asset and nothing about the move changes — scale each vector by its weight, then add. That is a linear combination, the single operation this whole chapter reuses.

Drag the weight slider and watch the blended stream form. At 60/40, Monday's two returns of +1.2% and +0.5% become 0.6(1.2) + 0.4(0.5) = 0.92%, and the whole week comes out as 0.92, 0.16, 0.90, 0.68, −0.82. Slide the weight to 100/0 and the blend snaps onto Apple's own line, which is the sanity check you should demand of any mixing rule.

That move has a name, and I am naming it late on purpose so it arrives as a label for something you already did. Scale each vector by a weight, then add the results, and you have formed a linear combination. Write it once:

c₁v₁ + c₂v₂ + … + cₙvₙ

Flag this one hard, because it is the operation the entire chapter is built on. Every matrix, every column space, every rank and every least-squares fit ahead of us is a linear combination in a costume. A portfolio is one. When you meet the same move inside matrix multiplication in a few pages, it will feel like recognition rather than a new rule.

03★ What "linear" actually means

If mixing is the operation we care about, the next question is which functions respect it. Chapter 1 defined a function as a map from a domain to a codomain, taking single numbers in and giving single numbers out. Now the inputs and outputs are vectors. A function takes a point of the plane and sends it somewhere else on the plane.

And here we have to fight a word. School burns in "linear means the straight line y = mx + b", and that meaning will actively mislead you for the rest of this chapter. A shear that slants the whole plane sideways is linear. A curve-free map that shifts everything two units right is not. So forget the graph and look at what happens to space itself.

The grid test — a shear is linear, a bend is not
THE GRID TEST lines stay straight parallel & evenly spaced origin stays fixed morph the plane to run the test
pick a map, then drag APPLY to morph the plane
shear: slide x sideways, more with height
Predict: can a straight line come out bent and still count as linear?
a shear looks slanted — is it still linear?
What you're looking at — is the plane still a grid after the map?
blue = a house riding the plane, so you can see where every point lands
green lamp = the map passes that test
red lamp = it fails — origin drifted, or a line came out bent
gold = affine: a linear map with a shift bolted on (the intercept, Ch 20)
Fig. 5. Pick a candidate map, then drag APPLY to morph the plane from rest. Three lamps run the test of linearity: lines stay straight, they stay parallel and evenly spaced, and the origin stays fixed. Rotate, stretch and shear light all three green — a shear slants the whole plane and is still perfectly linear, because the grid is still a grid. Shift passes the first two but drifts the origin, so it is only affine (linear plus a shift — the intercept you meet in Ch 20), marked by the red pin. Bend is predict-then-reveal: commit first, then watch the gridlines curve and the straight-line lamp die. Toggle the magnifier and drag it to check that spacing really stays even. That is the whole idea — “linear” is a statement about what happens to space, not about the shape of a graph.

Watch the grid, because the grid is the test. Apply the transformation and three things must survive. Straight lines stay straight. Parallel lines stay parallel, and the spacing between them stays even. The origin does not move. Run the rotation and all three hold. Run the shear and all three still hold, even though the picture looks slanted and wrong to the eye. Then hit the bend and predict before you look: the gridlines curve, so the first condition dies, and the map is not linear.

A quick honesty note on the origin. A map that shifts everything by a fixed amount preserves straightness and parallelism perfectly, and it still fails, because it moves the origin. That kind of map has its own name, affine, and it is a linear map with a shift bolted on afterwards. We will meet it again as the intercept in Chapter 20's regression.

Now write the visual test as arithmetic, because arithmetic is what we can compute with. If mixing is the operation and the grid stays a grid, mixing before the map and mixing after it must agree. In symbols, for any vectors u and v and any number c:

T(u + v) = T(u) + T(v) and T(cv) = c·T(v)

Mix first, or map first — two roads to the same dot. Break linearity and they split.
① MIX  →  ② MAP u v ① MAP  →  ② MIX u v T(u) T(v) = locked Same u and v feed both roads. Press ▶ to run them.
what to combine
the map T
press ▶ to run both roads
drag the u / v tips — on either side, they move together
What you're looking at — one answer, computed two ways, then set side by side.
u, v — the same two inputs on both roads
mix first: add, then map → the gold dot T(u+v)
map first: map, then add → the blue dot T(u)+T(v)
a straight map locks them; a bending one pulls them apart — that gap is non-linearity
Fig. 6. Two cold equations — T(u+v) = T(u)+T(v) and T(cv) = cT(v) — say only this: it makes no difference whether you combine your vectors before the map or after. Run both roads: mix-then-map lands the gold dot, map-then-mix lands the blue one, and with a straight map they snap together — same answer, printed twice. Flip to the bending map and drag u outward: the dots tear apart, and the growing gap is linearity failing in front of you.

Take both roads in that panel and watch them land on the same dot. Road one adds u and v first, then pushes the single sum through the transformation. Road two pushes u and v through separately, then adds the two outputs. The endpoints coincide exactly, and when you switch the panel to the bending map they visibly separate. Those two cold equations are not a definition to memorise. They are the grid staying a grid, written down.

A map that passes is called a linear transformation. Hold that phrase loosely for one more page, because we are about to discover something surprising about how little information one of them actually contains.

04★★ A matrix is where the basis lands

This is the rung the whole chapter turns on, and almost every course sprints past it. Most people meet matrices as a box of numbers with a bizarre multiplication rule to memorise, and nothing about that box ever means anything. We are going to close that gap now, and we are going to close it by making you do the computation before any rule exists.

Two vectors get special names because everything is built out of them. Write e₁ = (1, 0) and e₂ = (0, 1), the one-step-right arrow and the one-step-up arrow. Together they are the standard basis. Notice that every vector on the plane is already a mix of those two, and you have been writing it that way your whole life: (3, 2) = 3e₁ + 2e₂. Three steps right, two steps up.

Now the setup. I am going to tell you two facts about a linear transformation and nothing else. e₁ lands on (2, 1). e₂ lands on (−1, 1). That is all you get, and the panel will draw those two arrows and nothing else. Where does (3, 2) go? Commit to an answer, or sit in not knowing for a moment, because both are useful.

You are handed only where two arrows land. Guess where a third point goes — then watch it become forced.
input space output space (3,2) T the map e1→(2,1) e2→(-1,1) (3,2) → ? ← drag me
You are given only where e1 and e2 land. Drag the gold cross to guess where (3,2) goes — then lock it. No rule yet.
Drag the gold cross to guess
What you're looking at — two arrows decide the fate of every point
e1→(2,1) — where the first basis arrow lands
e2→(-1,1) — where the second lands
your guess, and the forced answer (4,5)
Because (3,2)=3e1+2e2 and T respects mixes, the answer is 3(2,1)+2(-1,1). The two arrows, stacked as columns, are the matrix.
Fig. 7. You are handed only where the two basis arrows land — e1→(2,1) and e2→(-1,1) — and nothing else. Guess where (3,2) goes and lock it in. Then reveal: (3,2) is just 3 e1 + 2 e2, and a linear map keeps mixes intact, so the answer is forced to be 3(2,1) + 2(-1,1) = (4,5) — you did matrix×vector with your own hands before any rule existed. Slide the two arrows into a box and they are literally its columns; then free-drag the point and watch every landing stay forced. That is why a matrix is never an arbitrary grid of numbers: two arrows decide the fate of infinitely many points.

You can answer it, and the answer is forced. Here is the reasoning in one line. The input is 3e₁ + 2e₂, the transformation respects mixes, so the output must be 3 times where e₁ went plus 2 times where e₂ went. That is 3(2, 1) + 2(−1, 1), which is (6 − 2, 3 + 2) = (4, 5). Nothing was looked up, because the two arrows you were handed decided it entirely.

Sit with how strong that is. There are infinitely many points on the plane, and a linear transformation has to say where every one of them goes. Knowing two arrows fixes all of it. So a linear transformation of the plane contains exactly four numbers of information, and not one drop more.

Write those four numbers down and you have built a matrix. Put where e₁ went in the first column, and where e₂ went in the second:

A = [ 2  −1 ;  1   1 ], first column (2, 1), second column (−1, 1)

That is the keystone of this chapter, and it deserves a flat sentence. The columns of a matrix are the landing spots of the basis vectors. The box was never arbitrary. It is a lookup table with two entries, and reading a matrix means reading where the arrows went.

Drag the two landings — the matrix is the steering wheel
e₁ e₂ e₁ → e₂ → M = 1.00 0.00 0.00 1.00 det = ad − bc = 1.00 orientation: kept columns = the two landings. nothing else is stored.
Grab a / tip and drag — all of space follows. Or snap to a named case:
identity — the grid at rest
What you're looking at — the four numbers ARE the two arrows
blue arrow = where e₁ = (1,0) lands → that's column 1, the numbers (a, b)
green arrow = where e₂ = (0,1) lands → column 2, (c, d)
the F just rides the grid — it isn't stored, it's carried
det < 0 flips orientation: the F reads mirror-backwards
Fig. 8. The matrix with its mystique stripped: you aren't adjusting a picture of the matrix — you're adjusting the matrix. Four numbers, two arrows, and the whole plane has nowhere else to go. Which is why reading a matrix just means reading where the arrows went.

Now steer it. Drag either landing arrow in that panel and the entire grid deforms to follow, live, because those four numbers are the transformation and nothing else is stored anywhere. Park the first column on (1, 0) and the second on (0, 1) and the grid snaps back to rest, which is the identity matrix. Push the first column down below the axis and the whole plane flips over. You are not adjusting a picture of the matrix. You are adjusting the matrix.

Which gives us multiplication for free, as a description of something we already did.

A x, two ways over one example — columns are the meaning, rows are the bookkeeping
A = [ 2 −1 ; 1 1 ]   x = ( 3, 2 )   A x = ( 4, 5 ) x₁ = 3 x₂ = 2 ( 2, −1 ) ( 1,  1 ) 2·3 6 −1·2 −2 1·3 3 1·2 2 Columns lane col 1 = ( 2, 1 ) × weight 3 → ( 6, 3 )
Beat 1 / 6 · columns lane
step through, then drag the regroup dial →
Column 1, scaled by weight 3
What you're looking at — one pile of four products, sorted two ways
columns lane: weight each column, add the arrows — the meaning
rows lane: dot each row with x, one output apiece — the recipe
the four tiles never change — only which bins gather them
Fig. 9. One example, A x with A = [2, −1; 1, 1] and x = (3, 2), worked two ways over the same four products. Step through the columns lane (beats 1–3): weight column 1 by 3, column 2 by 2, lay them tip‑to‑tail and land at (4, 5) — here A x is a weighted mix of the matrix's own columns. Then the rows lane (beats 4–5): sweep each row across x and total 4, then 5. Beat 6 drops both lanes into one tray; drag the regroup dial and the four tiles slide between two bins — grouped by input (columns) or by output (rows) — giving the identical 4 and 5 either way. That is the whole trick: the familiar row‑by‑row recipe is not a different rule, it is the same four products added in a different order — and only the columns reading keeps the meaning in view.

To compute Ax, take the entries of x as weights and form that linear combination of A's columns. With x = (3, 2) that is 3(2, 1) + 2(−1, 1) = (4, 5). The same arithmetic you just did by hand. That is the meaning of matrix-vector multiplication, and it is the definition worth carrying.

You have probably also been taught a recipe: dot each row with the vector. Step the panel's second road and watch where it comes from. Row one is (2, −1), so row one gives 2(3) + (−1)(2) = 4. Row two is (1, 1), so row two gives 1(3) + 1(2) = 5. Same answer, (4, 5), and it is not a coincidence. The four products 2·3, −1·2, 1·3 and 1·2 appear in both roads. The columns road groups them by input, and the rows road groups them by output coordinate. It is one total, added up in two different orders.

Lead with the columns and the recipe stays a bookkeeping convenience. Lead with the recipe and the meaning is gone, which is exactly how most of us lost it the first time.

05Do one, then the other

If a matrix is a transformation, then two matrices are two transformations, and the obvious thing to do is run them one after the other. Rotate the plane a quarter turn, then flip it upside down. That pair of moves is itself a transformation, and it is linear, because doing two grid-preserving things in a row preserves the grid.

Before we write any rule, do it in the wrong order and see what happens.

Rotate-then-flip vs flip-then-rotate — the same flag, two orders, two different landing spots
① rotate, then flip ② flip, then rotate at the finish at the finish (0, −1) (0, 1) tip: grab the gold flag and drag it anywhere FR 0 −1 −1 0 RF 0 1 1 0 red = the entries where the two orders disagree
different ends — order matters
The same gold flag sent down two orders lands in two different places — that is why FR ≠ RF: the product has to record the order.
the blue shape — one start state, identical on both sides
the gold flag at (1, 0) — the corner we track (drag it)
route ① rotate then flip → (0, −1)
route ② flip then rotate → (0, 1)
Fig. 10. Matrix multiplication is composition: AB means do B, then do A. Rotate-then-flip and flip-then-rotate use the same two moves in the other order, and they genuinely leave the flag somewhere else — so FR ≠ RF. Non-commutativity is a fact about where shapes land before it is a rule of algebra: like socks-then-shoes versus shoes-then-socks, the product has to carry the order.

Take the point (1, 0), which is a flag planted on the positive x-axis. Rotate a quarter turn counter-clockwise and it swings up to (0, 1). Now flip vertically, which negates the y-coordinate, and it drops to (0, −1). Reset and swap the order, then flip first: (1, 0) does not move at all, since it sits on the mirror line. Then rotate, and it swings up to (0, 1). Two different destinations from the same start, and you can see both on the panel at once.

So order matters in the world. That means it has to matter in the arithmetic that records the world, and the notorious fact that AB ≠ BA stops being arbitrary cruelty. It is the plainest observation in the chapter, written in symbols.

Now define the product, and define it by what we want it to do. Applying B then A to a vector x means computing A(Bx), which we already know how to do twice. We want a single matrix that does the whole job in one step, and we name that matrix AB:

(AB)x = A(Bx) — apply B first, then A

That is also why AB reads right to left, which trips up everybody once. The matrix nearest the vector touches it first.

Assembly line — build AB by sending each column of B through A
B drag the dots to edit A — where e₁, e₂ land AB (0,1) (-1,0) a₁ a₂ · · · · col1  col2
Click a SEND button — push that column of B through A and watch it land as a column of AB.
A column of AB is where AB sends a basis vector.
row×column drill confirms each slot — press Check.
shape (2×2)(2×2): inner 2 = 2 — each B-column is a legal input to A.
What you're looking at — the row×column rule, derived, not decreed
a column of B — a vector you push through A
a₁, a₂ — where A sends e₁, e₂ (its own columns)
a column of AB = x·a₁ + y·a₂, where AB sends that basis vector
Check by rows: the memorised drill lands on the very same number
Fig. 11. The columns of a matrix are where the basis vectors land — so the columns of AB are where AB sends e₁ and e₂. Press SEND col 1: B's first column (0,1) rides into A and comes out as 0·a₁ + 1·a₂ = (−1,1), dropping into the first slot; SEND col 2 gives −1·a₁ = (−2,−1). Push both and AB is built. Now hit Check by rows and the memorised row×column drill sweeps all four entries — each flashes green on the same number the sending already found. Nobody invented that rule: it falls out column by column, which is also why the inner dimensions have to match — every column of B must be a legal input to A. Drag any arrow to rebuild the product live.

Building AB is now a job you can do with only the keystone. The columns of any matrix are where the basis vectors land, so the columns of AB are where AB sends e₁ and e₂. Send each of B's columns through A and collect the answers. With A our old [2 −1; 1 1] and B the quarter-turn [0 −1; 1 0], B's columns are (0, 1) and (−1, 0). Push the first through A: 0(2,1) + 1(−1,1) = (−1, 1). Push the second: −1(2,1) + 0(−1,1) = (−2, −1). Stack those as columns and AB = [−1 −2; 1 −1].

Check that against the row-times-column drill and it agrees entry for entry, because it is the same sum regrouped. The rule was never invented. It is composition, worked out.

06Everywhere you can reach

Here is the question that turns this chapter from mechanics into insight. Every output of A is some mix of A's columns, with the input supplying the weights. So what is the set of all outputs? It is the set of all mixes of the columns, and that set has a name.

The span of a collection of vectors is every linear combination you can build from them. The span of a matrix's columns is called its column space, and it is precisely the set of vectors b for which Ax = b has a solution. If b is in there, some weighting reaches it. If it is not, no weighting ever will.

The span painter — sweep the weights, paint every reachable output, then watch a dimension die.
c₁ c₂ drag ⟲ b a dimension just died — no mix escapes the line
reachable: whole plane (dim 2)
tap in the plane (target mode) to test a point b
What you're looking at — every output is a weighted mix x₁c₁ + x₂c₂, so the reachable set IS the span of the columns.
c₁ = (2, 1), the fixed column
c₂, drag its tip — the column you break
the output dot and the paint it leaves = the reachable set
collinear c₂ → the span collapses to one line: Ax = b has no answer off it
Fig. 12. Every output of A = [c₁ c₂] is a weighted mix x₁c₁ + x₂c₂, so the set of ALL reachable outputs is the span of the columns. Sweep the weights and the output dot paints that reachable set; two independent columns fill the whole plane. Now drag c₂ onto the line through c₁ (or hit the snap chip for exactly −2·c₁): the angle dies to 0°, the paint clears to a single line, and no weighting — however hard you push the sliders — can leave it. That collapse is a singular matrix: a dimension died, and it is exactly the set of b for which Ax = b has any answer at all.

Sweep the two weight sliders and paint. With columns at (2, 1) and (−1, 1), the painted region fills the entire plane, and there is no point you cannot reach. Now drag the second column slowly around until it lies along the first, at (−4, −2), which is just −2 times the first column. Watch what happens to the paint.

The whole plane snaps down to a single line. Both sliders still move, and they still do something, but everything they produce lands on that one line through the origin. That is not a glitch. No weighted mix of two arrows lying on the same line can ever leave that line. You just watched a dimension die, and you caused it.

Two cases, two words. Columns pointing genuinely different ways are independent. Columns lying along one line are dependent or collinear, because one is just a scaled copy of the other and it contributes nothing new.

07Rank, counted honestly

The reachable set you just painted was sometimes a plane and sometimes a line. Those are different dimensions, and measuring that dimension is all that rank is.

You will usually be taught rank as "the number of pivots left after you row-reduce the matrix". Correct procedure, terrible definition. It tells you how to compute the number without ever telling you what the number is. So here is the meaning, with no algorithm in it. The rank of a matrix is the dimension of its column space, the count of genuinely independent directions its columns give you.

Three matrices, three ranks — the count you can see, before any row-reduction
Hover a card — rank is how many real directions its columns give you.
three ranks you can see: 2, 1, 0
Hover / tap a card to read what its count means. Then Sort.
What you're looking at — three matrices, and how many real directions their columns give you.
column 1, drawn as an arrow
column 2 (in B it lands on column 1's line)
the reachable set — everything the columns can build
the rank: the count of surviving directions
Fig. 13. Rank is the dimension of the column space — how many genuinely independent directions the columns hand you — read straight off the picture you just painted. A's two arrows spread apart and fill the plane (rank 2); in B the second column is −2× the first, so it lands on the same line and casts no new vote (rank 1); the zero matrix reaches only the origin (rank 0). Flip on the 3×2 ghost: even in 3-D, two columns span at most a plane — rank can never exceed the smaller dimension. That is rank without a single row operation: pivot-counting merely computes this number — it was never what the number means.

Three matrices sit side by side in that map, and you can read all three by eye. The first has columns (2, 1) and (−1, 1), pointing different ways, so it reaches the whole plane and its rank is 2. The second has columns (2, 1) and (−4, −2), which lie on one line, so it reaches only that line and its rank is 1. The second column added no new direction, so it did not raise the count. The third matrix is all zeros, it reaches only the origin, and its rank is 0.

A matrix with the most rank it could possibly have is full rank. One that falls short is rank-deficient. Both words do heavy work in a moment, and now they mean something you can see.

08★ Collapse, and an area that reads zero

Something strange happened in the span panel and we walked past it. When the rank dropped to 1, the transformation stopped merely moving points around the plane. It started destroying a dimension, taking the entire two-dimensional plane and squashing it onto a one-dimensional line.

Sit with that for a second, because the gut expects a transformation to shuffle space, not to flatten it. Every point still goes somewhere. The strange part is that a whole sheet of points all arrive at the same line.

We need a number that detects this, and there is one hiding in plain sight. Watch what a transformation does to area.

The area that hits zero — the determinant, and what “singular” means
col 1 (2, 1) col 2 (−1, 1) tip: drag col 2 onto col 1’s line to flatten area = the determinant +3.000 |area| 3.000 kept rank 2 space is full the whole plane folded onto one line — singular = rank-deficient
Predict: as col 2 slides onto the line through col 1, the area…
pick a prediction — then Flatten unlocks
area = 3.000 · space full
The determinant IS the area of the unit square after the map. Fold the plane onto a line and that area is exactly zero — that one number is what “singular” reports.
col 1 — where the map sends the x-basis
col 2 — where it sends the y-basis
the gold area = det = how much space stretched
the crowd of points, crushed onto the line at det = 0
Fig. 14. A matrix is a transformation of space, and its determinant is the one number that says how much area the unit square gained or lost under it. Drag the two columns — where the map sends the basis arrows — and the gold area tracks live; switch on the three tiles to see it split into equal 1.00 pieces that sum to 3.000. Now fold the second column onto the line through the first: the parallelogram thins to a bare segment, the crowd of points is crushed onto that line, and the area reads 0.000. That collapse is exactly what singular means — rank drops from 2 to 1, space goes from full to flat, and because a whole plane was squashed onto a line there is no way to un-squash it. Every collinearity blow-up in regression is this same fold wearing a statistical costume.

Start with the unit square, the little box with corners at (0,0), (1,0), (1,1) and (0,1), whose area is exactly 1. Apply the transformation and the square becomes a parallelogram spanned by the two columns. With columns (2, 1) and (−1, 1), that parallelogram has area 3, so this map triples the area of anything you feed it. That factor has a name: it is the determinant.

Now drag the second column toward the first, and predict what the area readout will do as they line up. Watch it thin. The parallelogram gets narrower and narrower, and the instant the second column lands anywhere on the line through the first, the area is exactly 0. Not small. Zero. The parallelogram has no width left, because the whole plane has just folded onto one line.

So the determinant reading zero is not a piece of trivia about a formula. It is the arithmetic signature of collapse. A matrix whose determinant is zero is called singular, and singular, rank-deficient and collapses-space are three names for the event you just triggered with your mouse.

One honesty note on scope. You have probably seen det = ad − bc for a 2×2 matrix, and it is the same number the panel prints. I am deliberately not deriving that formula here, because the meaning is what carries into Chapter 7 and the algebra is a detail you can look up. In three dimensions the determinant scales volume instead of area, and everything said here holds word for word.

09Undo, or don't

Now the question that all of this was built for: given a transformation, can you undo it? If I run every point of the plane through A and hand you the result, is there another transformation that puts every point back exactly where it started?

Most people think this is a question about whether a formula for the inverse exists. It is not. It is a question about information, and the cleanest way to see that is to try to undo a collapse.

A singular map folds the plane onto a line — two inputs pile onto one output, so the reverse question has no honest answer
A→ INPUT plane — drag anywhere in 2D OUTPUT plane — where it lands every output is stuck on this line P₁ P₂ (4, 2) (2, 0) ↑ grab the blue dot and drag it around 2·(2,1) + 0·(−4,−2) = (4, 2) rank 1: the two columns are the same arrow — (−4,−2) is just −2·(2,1)
2D in → 1D out: folded flat
Being handed the output tells you strictly less than you started with: two different inputs became one landing point, and no formula un-mixes them.
the input — any point in the 2D plane (drag it)
where it lands — trapped on one line, the whole output
collapse: infinitely many inputs → the same output, no undo
independent columns: fills 2D, one-to-one, reversible
Fig. 15. The matrix with columns (2,1) and (−4,−2) is singular: its second column is just −2× the first, so the two columns point the same way and the whole plane gets pressed onto one line. Drag the input anywhere — the output never leaves that line. Fire both pins and watch (2,0) and (0,−1) land on the same spot (4,2); the collapse beam shows the whole infinite family that shares it. Now demand the undo: handed only (4,2), every guess is stamped cannot be determined — not because we lack a formula, but because the information was destroyed. Flip to independent columns and the collapse vanishes: one input, one output, undo resolves to exactly one point. That is the difference between hard to invert (a near-collapse that a computer struggles with — the covariance of two almost-identical assets) and impossible to invert (a true collapse, where no machine can recover what is gone).

Take the singular matrix with columns (2, 1) and (−4, −2), the collinear pair from the span panel. Feed it the input (2, 0) and the output is 2(2,1) + 0(−4,−2) = (4, 2). Now feed it a completely different input, (0, −1). The output is 0(2,1) + (−1)(−4,−2) = (4, 2). The same landing spot, from two genuinely different starting points.

So here is the demand. I hand you the output (4, 2) and ask which input produced it. There is no honest answer. It could have been (2, 0), or (0, −1), or any of the infinitely many points on the line joining them. The transformation did not merely scramble the information about where you started. It threw it away, and no cleverness recovers what is gone.

That is the real content of the word invertible. A transformation can be undone exactly when it never merged two inputs into one output, and it merges inputs only when it collapses space. Nothing lost, everything recoverable.

One event, five names — the lamps that flip together
x y unit square |det| 1.17 69° c₁ c₂ drag the tips ● ●   or sweep the angle →
INVERTIBLEundo→one input
FULL RANKrank 2
DET ≠ 0det 1.17
NON-SINGULAR1-to-1
INDEP. COLS∠ 69°
det = 1.17 — space stays full; all five instruments agree.
log — every row is five booleans0
all five green · space stays full
What you're looking at — five interview words that are one geometric event
c₁ — where the matrix sends the first basis arrow
c₂ — where it sends the second
the parallelogram they span — its area is |det|
the five lamps live or die together — never split
Drag the two tips together and the plane crushes to a line: det → 0, rank drops 2 → 1, the undo test resolves to a whole line of inputs instead of one — no inverse. That single collapse is every collinearity failure in a regression wearing a statistical costume.
Fig. 16. A 2×2 matrix is two column arrows — c₁ and c₂ — that say where the transformation sends the two basis vectors; the gold parallelogram they span is the image of the unit square, and its area is |det|. Drag a tip toward the other (or sweep the angle to 0°) and watch all five lamps — invertible, full rank, det ≠ 0, non-singular, independent columns — dim in lockstep and go dark at the same instant: they were never five properties to memorise, but five instruments pointed at one event — did space stay full, or did it get crushed flat? Hunt for a setting where they disagree; you won't find one. At a whisker off collapse the honest near-miss shows: lamps technically green while det reads 0.02 and the strip warns practically fragile — the exact state a collinearity failure lives in.

Which lets us do the most useful piece of tidying in the chapter. Drag the columns in that panel and watch five lamps flip at the same instant, all of them wired to the same event. The matrix is invertible. It has full rank. Its determinant is not zero. It is non-singular. Its columns are independent. Slide the columns onto one line and all five go dark together.

Those are not five facts to memorise. They are five ways of saying that space stayed full, and the five words are exactly the ones that get thrown around in interviews and papers as though they were separate ideas. They are one picture, and you now own the picture.

10When you cannot reach b

Everything so far assumed that Ax = b has an answer. In real data it almost never does, and this last section is where the chapter pays for itself.

Here is the setup, and it is the shape of every regression you will ever run. You have a year of a stock's returns, so 252 numbers, and you want to explain them with two knobs: a market exposure and a baseline. That is 252 equations and 2 unknowns, which is called an overdetermined system. Far more demands than freedom.

Two knobs sweep out a flat 2-D sheet; a year of real returns is a point in 252-D space that almost never lands on it — so Ax = b has no exact solution, and that's normal
3 equations, 2 unknowns — the honest picture c₁ c₂ shadow miss 0 b ↑ drag b, or lift it with the slider the real shape — rows climb, columns stay 2 A x b · = 3×2 2 3 demands: 3 · freedoms: 2 the sheet fills 2 of 3 directions 66.7% every row's miss — they can't all be 0 at once:
Raise the rows. The columns never move off 2 — so the reachable sheet stays 2-D while b lives in ever-higher space.
b floats off the sheet — no fit
The question was never "can I hit b" — it is "how close can I get." Two knobs make points on a 2-D sheet; a year of returns is a point in 252-D space. Missing is the default.
the sheet = every b the 2 columns can build (span of c₁, c₂)
b = the actual returns you want to explain — floating off the sheet
the miss (residual) — one line on the left, all 252 as bars on the right
reachable only in the measure-zero instant b sits exactly on the sheet
Fig. 17. Fitting a model means solving Ax = b: the matrix A holds your predictors (here 2 columns — two knobs), x is the two weights you get to choose, and b is what actually happened (a year of returns — 252 numbers). Every choice of x builds A x = a point on the column space, the flat 2-D sheet the two columns can reach. On the left, in an honest 3-row stand-in, drag b or lift it: it is reachable only in the vanishing instant it lands exactly on the sheet — every other position leaves a miss. Raise the rows to 252 and the picture greys out (nobody can draw 252 dimensions) but the arithmetic on the right is untouched: 2 freedoms, 252 demands, a sheet that fills a shrinking 2 of m directions, and 252 misses that can never all be zero. That is why a regression never fits perfectly — and why that is not a failure. The question was never “can I hit b”; it is “how close can I get”, and the closest reachable point is b's shadow on the sheet — the projection we chase next.

What can your two knobs actually produce? Every output of A is a mix of its two columns, so the reachable set is a flat two-dimensional sheet sitting inside a 252-dimensional space. The vector b of actual returns is a point somewhere in that huge space. The chance it happens to land exactly on your thin sheet is essentially zero.

So Ax = b has no solution, and that is normal rather than a failure. It says your two knobs cannot reproduce a year of reality exactly, which was never a reasonable hope. The panel draws this in three dimensions because three is what you can see. The honesty note from the start of the chapter still holds: at 252 the picture is unavailable and the arithmetic is identical.

If you cannot hit b, aim for the closest point you can hit. That means the point of the sheet nearest to b, and "nearest" turns out to have a completely concrete answer.

Least-squares = dropping a perpendicular — then make the two columns twins and watch the weights detonate
the column-space plane (every reachable point) b = (2, 3, 4) candidate slant
4.123
distance ‖b − candidate‖ · never below 4.000
lowest so far: 4.123 at (2.0, 4.0)
off the foot → longer than 4.000
What you're looking at — least-squares is the shadow, and collinearity is what wrecks it
the perpendicular drop — the single shortest reach, distance 4.000
any other candidate is a slanted hypotenuse → always longer
the two columns; slide ε and they collapse onto one line (near-singular)
so the weights to hit the same point explode and nearly cancel
Fig. 18. Part 1: b sits above the column-space plane; the only reachable points live on the plane. Slide the candidate and every connector is a right triangle — the perpendicular drop (4.000) is one leg, the in-plane offset the other, so the slant is always a longer hypotenuse. Search the whole plane and nothing beats 4.000: that foot is exactly what least-squares computes. Part 2: tilt ε and the two columns fold onto one line — the space nearly collapses (tiny det, tiny angle), so the weights needed to reach the same point (2, 3) blow up to two near-cancelling giants. Jitter b and they lurch and flip sign while the fitted point never moves: a rank problem wearing a statistics costume.

Drag b around above the sheet and watch the nearest point track it. The connecting segment is always perpendicular to the sheet, and that is geometry rather than convention. To reach a plane from a point outside it by the shortest path, you go straight at it. Any slanted path is the hypotenuse of a right triangle whose short leg is that perpendicular, so it is longer. With the sheet at z = 0 and b = (2, 3, 4), the nearest point is (2, 3, 0) at distance 4. Try the neighbour (2, 4, 0) and the distance is √17 ≈ 4.123, which is worse, as every other candidate will be.

That perpendicular drop is called an orthogonal projection, and choosing the reachable point closest to b is exactly what least squares does. This is the setup only, and Chapter 20 is where it becomes the normal equations and the fitted coefficients. I would rather flag that plainly than pretend we finished the job here.

But there is one thing we can finish, and it is the promise made in the chapter's first paragraph. Flip the panel's second switch and tilt the two columns nearly collinear.

Watch two readouts move in completely different ways. The fitted point on the sheet barely stirs, because the sheet is still nearly the same sheet. The coefficients, meanwhile, go berserk. At a column separation of ε = 0.1 the weights needed to reach that point are (−28, 30). Tighten to ε = 0.01 and they are (−298, 300). Two enormous numbers, cancelling each other almost perfectly, to produce a modest answer.

That is collinearity, and it is the failure the keystone promised. Regress a stock on two nearly identical inputs and your data matrix has two nearly identical columns. Its column space is nearly a line, its determinant is nearly zero, and it is nearly singular. Nearly non-invertible means the coefficients are nearly undefined, which is why they swing wildly, flip sign on a tiny change in the data, and mean nothing at all. Your fit still looks fine, and every individual coefficient is garbage. That is not a bug in the regression software. It is a rank-deficiency you can now diagnose in one sentence.

The whole chapter in one carry-out map — a matrix moves all of space, and the only question is: did it stay full, or get crushed flat?
a matrix = a function on ALL of space columns = where the basis lands ▸ (3,2)→(4,5) did it keep space FULL — or crush it FLAT? FULL ✓ kept full FLAT ✗ crushed flat det — not derived normal eqns · β̂ → Ch 20 every word above is one of those two answers tap any node on the map to replay it with the chapter's own numbers ▸ or open the door to Ch 7
tap a node on the map ↖
the chapter, as one carry-out map
One sentence to carry out: a matrix moves all of space, and the only question that matters is whether it kept space full or crushed it flat — every term below is one of those two answers said differently.
keystone — the matrix as a function; columns = basis landings
FULL — independent · full rank · det≠0 · non-singular · invertible
FLAT — dependent · rank-deficient · det=0 · singular · no undo
the replay number for the node you tapped · red pins = deferred
Fig. 19. The whole chapter as one image you can carry out the door. The keystone says it once: a matrix is a function that moves all of space, and its columns are simply where the basis lands. Everything the chapter earned then hangs off a single question — did the map keep space FULL or crush it FLAT — and every term is one of those two answers said differently: independent · full rank · det≠0 · non-singular · invertible on one side, dependent · rank-deficient · det=0 · singular · no undo on the other. Tap any node to replay it with the chapter's own numbers — area 3.000 → 0.000, two inputs both landing on (4,2), weights (−28,30) → (−298,300). Flip on coverage to see that all of it is now re-derivable, while two red pins mark what was deliberately parked — the determinant formula's derivation and the normal equations owed to Chapter 20. Then open the door: a shear turns every arrow but one, and that fixed direction — an eigenvector — is exactly where Chapter 7 begins.

So here is the chapter as one picture. A vector is an ordered list, read as a point or as a bundle of data. A matrix is a function that moves all of space at once, and its columns are simply where the basis arrows landed. Multiplying is mixing those columns, and multiplying two matrices is doing one transformation after another. Everything after that was one question. Did space stay full, or did it get crushed flat? Full means independent columns, full rank, nonzero determinant, invertible, undo-able. Flat means the information is gone.

And that sets up the next question exactly. A transformation grabs most directions and turns them, which is what makes the picture confusing to hold. But look at the shear in the grid panel again and you will notice that some directions do not turn at all. They only get stretched. Those special directions are where a matrix becomes simple, and they are called eigenvectors. They are Chapter 7, and they are the language of PCA, of numerical stability, and of generating correlated random noise.

iolinked.com
Written by Ajai Raj