Lesson 2 of 20 · about 15 min
Linear combinations and span
Every color on your screen is made by mixing just three lights. That mixing, "some of this arrow plus some of that one", is a linear combination, and it's the most important move in linear algebra. You'll steer two arrows to reach any target, spray hundreds of random mixes to see what they can cover, and find the one way two arrows can get stuck on a line.
🧭 What you need first: Vectors: arrows and lists
Look very closely at a phone screen (a magnifying glass helps) and you’ll see that each pixel is made of tiny red, green and blue lights. There are no yellow lights and no purple lights. Yellow is red plus green; purple is red plus blue; white is all three at full strength.
In vector language: a color is a list of three brightnesses, and every color the screen can show is
for some amounts , , . Scale some vectors, add them up: that’s a linear combination. A whole rainbow of colors comes from mixing just three.
This lesson asks two questions about any set of arrows. How do I mix them to reach a given target? And which targets can I reach at all?
Another way: a city with two kinds of streets
Picture a city whose streets run in only two directions, but not north–south and east–west; they’re slanted. You can still get to any address: some blocks along the first kind of street, then some along the second. The two street directions are your two vectors, and “how many blocks of each” are the weights.
Mix two arrows
Here v = (1, 1) and w = (1, −1) are fixed. Slide a and b to land on the star. Before you slide, guess: can these two arrows reach every point on the grid?
🎯 1/3: Find a and b so that a × v + b × w lands on the ★ at (3, 1).
Slide a and b. Walk a × v (blue), then b × w (orange). The purple arrow is where you land.
1 × (1, 1) + 1 × (1, −1) = (2, 0)
Each target had exactly one pair of weights that worked. Now let the arrows move. Spray random mixes and watch what they cover.
If v and w point in exactly the same direction (or exactly opposite directions), what will hundreds of random mixes a·v + b·w cover?
🎯 1/2: Press Spray. Then drag w until its span collapses to a line (both arrows still nonzero).
Drag v and w, then spray hundreds of random combinations a × v + b × w. Where can they reach?
v = (2, 1), w = (1, 2)
Span: the whole plane
The real words
-
A Linear combination of vectors is
for any numbers , called weights or coefficients.
-
The Span of those vectors is the set of all their linear combinations. In the plane:
- two vectors that aren’t on the same line span the whole plane;
- two vectors on the same line (one a multiple of the other) span only that line;
- the zero vector alone spans just the origin.
-
There’s a quick test for “same line”: and lie on one line exactly when . (That number will come back as the determinant in lesson 9.)
-
The standard basis vectors and (“i hat”, “j hat”) are the simplest pair that spans the plane. The components of a vector are its weights in this mix:
-
In 3D, two vectors (not on one line) span a plane through the origin, and you need a third vector sticking out of that plane to span all of space. That’s why screens need three colors of light, not two.
Search for the weights
Later in the course you’ll solve for the weights directly. For now, let the computer search.
Write combo(a, v, b, w) returning a·v + b·w for 2D vectors. Then find_combo(v, w, target): try every a and b from −10 to 10 in steps of 0.5 and return the first (a, b) with combo(a, v, b, w) == target, or None if nothing works.
Can we get there?
Searching is slow, and it can’t prove “no”. The span picture answers instantly. If and span the plane, every target is reachable. If they only span a line, the target must lie on that line.
Write same_line(v, w): True when v[0]*w[1] − v[1]*w[0] == 0. Then reachable(v, w, target) for 2D vectors: True if some a·v + b·w equals target. Cases: if v and w aren't on one line, always True. Otherwise, if both are zero, only the target (0, 0) is reachable; else the target must be on the line of the nonzero one (use same_line).
What is the span of v = (2, −1) and w = (−4, 2)?
Got it?
Finish the lesson to color it in on your map and collect its concept cards.
Did this lesson click?