Chapter 2

Linear Combinations & Span

The Question

You learned in Chapter 1 that you can scale a vector and add two vectors together. Now put both operations together: scale each vector by some amount, then add the results. That's called a linear combination.

Here's the question that should nag at you: if you have two vectors, what's the full set of points in space you can reach by scaling and adding them?

Not just one combination. All combinations. Every possible pair of scalars. What shape does that set trace out?

The answer is called the span of those vectors, and it tells you everything about what your vectors can do.

Building Combinations

Let's start with two vectors: v1=[21]\vec{v}_1 = \begin{bmatrix} 2 \\ 1 \end{bmatrix} in blue and v2=[12]\vec{v}_2 = \begin{bmatrix} 1 \\ 2 \end{bmatrix} in green. A linear combination looks like c1v1+c2v2c_1 \vec{v}_1 + c_2 \vec{v}_2 for any scalars c1c_1 and c2c_2.

Pick a few specific values of c1c_1 and c2c_2 and plot where you land.

v₁ = (2, 1) v₂ = (1, 2) 1v₁ + 1v₂ −1v₁ + 1v₂ 1v₁ − 0.5v₂ 0.5v₁ + 1.5v₂

Each orange dot is a linear combination c1v1+c2v2c_1 \vec{v}_1 + c_2 \vec{v}_2. The dashed lines show each vector's contribution. Scale each vector by any amount, then add.

Those six dots are just six specific combinations. But you can choose any real numbers for c1c_1 and c2c_2. Infinitely many choices, infinitely many points. Where do they all land?

When Vectors Are Parallel

Before answering that, let's look at a simpler case. What if your two vectors point in the same direction?

Take v1=[21]\vec{v}_1 = \begin{bmatrix} 2 \\ 1 \end{bmatrix} and v2=[42]\vec{v}_2 = \begin{bmatrix} 4 \\ 2 \end{bmatrix}. Notice that v2=2v1\vec{v}_2 = 2\vec{v}_1 -- they're parallel.

v₁ = (2, 1) v₂ = (4, 2) span = this line

When both vectors point in the same direction, every combination lands on a single line through the origin. Scaling v2\vec{v}_2 just gives you a differently scaled version of v1\vec{v}_1. The span is one-dimensional.

Any combination c1v1+c2v2c_1 \vec{v}_1 + c_2 \vec{v}_2 simplifies to c1v1+c2(2v1)=(c1+2c2)v1c_1 \vec{v}_1 + c_2 (2\vec{v}_1) = (c_1 + 2c_2)\vec{v}_1. That's just a single scalar times v1\vec{v}_1. You're stuck on one line no matter what you do. The second vector gives you no new reach.

The Full Span of Two Non-Parallel Vectors

Now back to the interesting case. When v1\vec{v}_1 and v2\vec{v}_2 point in different directions, something powerful happens. You can reach any point in the entire 2D plane.

Think about it: pick any target point. You need to solve c1v1+c2v2=targetc_1 \vec{v}_1 + c_2 \vec{v}_2 = \text{target} for c1c_1 and c2c_2. Because the vectors aren't parallel, they form two independent "knobs" you can dial -- one pushes you along v1\vec{v}_1's direction, the other along v2\vec{v}_2's. Between the two, you can steer to any destination.

v₁ v₂ span(v₁, v₂) = entire plane

Two non-parallel vectors span the entire 2D plane. The light orange shading represents every reachable point. You can reach any position by dialing the right pair of scalars.

This is the key insight. Two non-parallel vectors in 2D give you full coverage. One vector gives you a line. Two non-parallel vectors give you the whole plane. Adding more vectors to the mix won't expand your reach any further -- you already have everywhere.

The Redundant Vector

So what happens when you throw in a third vector? If the first two already span the whole plane, the third one must land somewhere in that plane. It's already reachable. It adds nothing.

Let's say v3=[33]\vec{v}_3 = \begin{bmatrix} 3 \\ 3 \end{bmatrix}. Can we write v3\vec{v}_3 as a combination of v1\vec{v}_1 and v2\vec{v}_2? Yes: v3=1v1+1v2=[21]+[12]=[33]\vec{v}_3 = 1\vec{v}_1 + 1\vec{v}_2 = \begin{bmatrix} 2 \\ 1 \end{bmatrix} + \begin{bmatrix} 1 \\ 2 \end{bmatrix} = \begin{bmatrix} 3 \\ 3 \end{bmatrix}.

v₁ v₂ +v₂ +v₁ v₃ = (3, 3) = v₁ + v₂

v3\vec{v}_3 is already reachable from v1\vec{v}_1 and v2\vec{v}_2. The dashed lines show the parallelogram: go along v1\vec{v}_1 then v2\vec{v}_2, or v2\vec{v}_2 then v1\vec{v}_1 -- either way you arrive at v3\vec{v}_3. The third vector is redundant -- it doesn't expand the span.

This is called linear dependence. The set {v1,v2,v3}\{\vec{v}_1, \vec{v}_2, \vec{v}_3\} is linearly dependent because one of them is a combination of the others. It's a passenger, not a driver.

The Formal Bit

Time to put precise language on these ideas.

Linear Combination

A linear combination of vectors v1,v2,,vn\vec{v}_1, \vec{v}_2, \ldots, \vec{v}_n is any expression of the form:

c1v1+c2v2++cnvnc_1\vec{v}_1 + c_2\vec{v}_2 + \cdots + c_n\vec{v}_n

where c1,c2,,cnc_1, c_2, \ldots, c_n are real numbers (called scalars or coefficients). You scale each vector, then add them up.

Span

The span of a set of vectors is the collection of all linear combinations you can form:

span(v1,v2)={c1v1+c2v2c1,c2R}\text{span}(\vec{v}_1, \vec{v}_2) = \{c_1\vec{v}_1 + c_2\vec{v}_2 \mid c_1, c_2 \in \mathbb{R}\}

In plain English: span is everywhere you can reach.

Linear Dependence and Independence

A set of vectors is linearly dependent if at least one vector in the set can be written as a linear combination of the others. Equivalently, there exist scalars c1,c2,,cnc_1, c_2, \ldots, c_n, not all zero, such that:

c1v1+c2v2++cnvn=0c_1\vec{v}_1 + c_2\vec{v}_2 + \cdots + c_n\vec{v}_n = \vec{0}

A set is linearly independent if no vector is redundant. Each one expands the reach. Removing any one of them shrinks the span.

The visual test: if a vector already lives inside the span of the others, it's dependent. If it points "out of" the current span into a new dimension, it's independent.

Worked Example: RGB Color Mixing

Here's a concrete application every programmer knows. Think of colors as vectors in 3D space, where the three axes are Red, Green, and Blue intensity (each from 0 to 1).

Define three color vectors:

R=[100],G=[010],B=[001]\vec{R} = \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix}, \quad \vec{G} = \begin{bmatrix} 0 \\ 1 \\ 0 \end{bmatrix}, \quad \vec{B} = \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}

What does the span of just Red and Green look like? It's every combination c1R+c2Gc_1 \vec{R} + c_2 \vec{G} -- a flat plane in 3D color space. You get:

Lots of colors, but no blues, purples, or anything with a blue component. You're stuck on a plane.

Add Blue. Now span(R,G,B)\text{span}(\vec{R}, \vec{G}, \vec{B}) is all of 3D color space. Every displayable color is a combination of these three. Blue is linearly independent of Red and Green -- it points in a direction you couldn't reach before.

Now define Yellow: Y=[110]=1R+1G\vec{Y} = \begin{bmatrix} 1 \\ 1 \\ 0 \end{bmatrix} = 1\vec{R} + 1\vec{G}.

Does adding Yellow as a fourth "basis color" let you mix any new colors? No. Yellow is already in the span of Red and Green. It's linearly dependent. span(R,G,B,Y)=span(R,G,B)\text{span}(\vec{R}, \vec{G}, \vec{B}, \vec{Y}) = \text{span}(\vec{R}, \vec{G}, \vec{B}) -- the same set. Adding a redundant vector changes nothing.

This is exactly why monitors use three primary colors: three linearly independent vectors span 3D color space. A fourth primary would be redundant.

// In code: any color is a linear combination of RGB
const R = [1, 0, 0];
const G = [0, 1, 0];
const B = [0, 0, 1];

// Yellow = R + G — already in span(R, G)
const yellow = R.map((v, i) => 1 * v + 1 * G[i] + 0 * B[i]);
// [1, 1, 0]

// Purple needs Blue — not in span(R, G) alone
const purple = R.map((v, i) => 0.5 * v + 0 * G[i] + 0.5 * B[i]);
// [0.5, 0, 0.5]

Key Takeaway: Span is the set of all places you can reach by scaling and adding. Linearly dependent vectors are redundant passengers -- they don't expand your reach.

What's Next

We know what combinations of vectors look like and how to tell whether a vector set is redundant. But what if we had a machine that takes every vector in space and moves it somewhere new -- systematically? Stretching, rotating, squishing the whole plane at once, while keeping grid lines straight and evenly spaced? That's a linear transformation, and it's the subject of Chapter 3.