A Primer on Linear Algebra

“It is by logic that we prove, but by intuition that we discover.” - Henri Poincaré

Linear algebra appears in subjects ranging from machine learning to network design. Knowing how to multiply matrices is useful, but it helps to understand what those calculations mean. A matrix changes a vector, and the way it changes depends on the vector’s direction. Understanding that relationship gives us a way to break complicated calculations into simpler pieces and see why eigenvectors and eigenvalues are useful.

My aim is to build that understanding through pictures and small examples. We’ll start with arrows on a plane and follow one matrix through most of the primer, introducing each idea as we need it. Along the way, we’ll see how to measure alignment, split a vector into perpendicular pieces, and find directions that make a measurement smallest or largest. This also lays the groundwork for Understanding Networks Through Spectral Graph Theory, where we’ll use these ideas to study connections and bottlenecks in a network.

1. Vectors and coordinates

An arrow describes a movement

Suppose we walk three units right and one unit up. The vector x = (3, 1) is a record of that trip. Start at the origin, and you can draw it as an arrow ending at the point (3, 1).

We can draw the same movement starting anywhere. As long as the arrow still goes three right and one up, it’s still (3, 1). A vector’s entries describe changes in coordinates, not a fixed starting point.

Order matters: (1, 3) means one right and three up, which is a different trip. In the ordinary coordinate pictures, the first entry is always the horizontal movement and the second is the vertical one.

Make the arrow longer or shorter

Multiply both entries by two and we get 2x = (6, 2): the same direction, twice as far. Multiply by ½ and it’s half as long.

A negative multiplier also flips the arrow around: −x goes three units left and one unit down. A number we multiply a vector by is called a scalar, and we apply the same number to every entry.

Doubling a vector keeps its directionOn ordinary Cartesian coordinates, x=(3,1) and 2x=(6,2) start at the origin and point in the same direction. Equal axis scales show that 2x has twice the length of x. Dashed guides identify the coordinates of both endpoints. Same direction, twice the length 0 3 6 1 2 x1​ x2​ x = (3, 1) 2x = (6, 2)
Doubling both coordinates doubles the length. Same axes, same scale, same direction. Just more arrow.

Follow one arrow, then another

We can also reach (3, 1) in two steps: first move by (1, −1), then by (2, 2). Adding the vectors records the whole journey:

(1, −1) + (2, 2) = (3, 1)
Adding two arrows tip to tailOrdinary coordinates. The blue arrow (1, -1) starts at the origin. The orange arrow (2, 2) starts at the blue arrow's tip and ends at (3, 1). The teal arrow x = (3, 1) runs from the origin straight to that endpoint. A faint copy of the two arrows in the other order, (2, 2) first and then (1, -1), reaches the same point. To the right, the sum is written out entry by entry: 1 + 2 = 3 and -1 + 2 = 1. Follow one arrow, then the next Ordinary coordinates; the sum goes straight from start to finish 0 1 2 3 1 x1​ x2​ (1, −1) then (2, 2) x = (3, 1) the other order lands in the same place Add matching entries (1, −1) + (2, 2) = (3, 1) first entries: 1 + 2 = 3 second entries: −1 + 2 = 1 Scaling first is allowed too: 2a + b means two copies of a, then one copy of b. Order doesn't matter: both routes end at (3, 1).
Tip to tail. Draw the second arrow starting where the first one ends. The sum runs straight from the very start to the very end, and it lands in the same place whichever arrow you take first. Entry by entry, you just add the matching numbers.

Keep this split in mind. The two pieces are perpendicular, and we’ll return to them throughout the primer.

The second piece, (2, 2), is twice the arrow (1, 1). So we can write the same sum as:

x = 1(1, −1) + 2(1, 1) = (3, 1)

Scaling vectors and then adding them is called a linear combination. The multipliers 1 and 2 are its coefficients: one copy of the first arrow and two copies of the second.

2. How a matrix transforms a vector

Build a matrix from two rules

How do we turn one vector into another? Call the input entries x₁ and x₂. Each output entry gets its own rule:

  • First output: double x₁, then add x₂.
  • Second output: add x₁ to twice x₂.

A matrix records the multipliers in these rules, with one row for each output. We’ll call our matrix M and use it throughout the primer:

M =

The notation Mx means “the output you get by feeding x to M”:

Mx = (2x₁ + x₂,  x₁ + 2x₂)
Comic: the arrow machineA box labeled M has an IN funnel on top and an OUT chute on the side. Panel 1: B drops the arrow (3, 1) into the funnel and says: I put in (3, 1)... A, catching what comes out of the chute, says: ...and out comes (7, 5). Panel 2: B asks: What if I put in two arrows, tip to tail? A says: Same as putting them in one at a time and adding what comes out. Panel 3: B asks: What if I put in nothing? A says: You get nothing. It's a very fair machine. M IN OUT (3, 1) (7, 5) I put in (3, 1)... ...and out comes (7, 5). M IN OUT What if I put in two arrows, tip to tail? Same as putting them in one at a time and adding what comes out. M IN OUT What if I put in nothing? You get nothing. It's a very fair machine.
Comic: the arrow machineA box labeled M has an IN funnel on top and an OUT chute on the side. Panel 1: B drops the arrow (3, 1) into the funnel and says: I put in (3, 1)... A, catching what comes out of the chute, says: ...and out comes (7, 5). Panel 2: B asks: What if I put in two arrows, tip to tail? A says: Same as putting them in one at a time and adding what comes out. Panel 3: B asks: What if I put in nothing? A says: You get nothing. It's a very fair machine. M IN OUT (3, 1) (7, 5) I put in (3, 1)... ...and out comes (7, 5). M IN OUT What if I put in two arrows, tip to tail? Same as putting them in one at a time and adding what comes out. M IN OUT What if I put in nothing? You get nothing. It's a very fair machine.
Two rules make M linear. Scaling an input scales its output, and adding inputs adds their outputs.

Read the rows to find the output

For our input (3, 1), the first row gives 2 × 3 + 1 × 1 = 7. The second gives 1 × 3 + 2 × 1 = 5. So the output is Mx = (7, 5).

Applying M changes this arrow's length and directionFor M with rows (2,1) and (1,2), the vector x=(3,1) maps to Mx=(7,5). Both arrows are drawn from the origin on the same Cartesian coordinate plane with equal axis scales. Their different directions show that no single scalar multiplies x into Mx. For this input, M changes length and direction 0 3 7 1 5 x1​ x2​ x = (3, 1) Mx = (7, 5)
M changes this arrow's length and its direction. No single scalar could do this: 3 became 7 while 1 became 5, and those aren't the same multiplier.

Keep the matrix fixed and change the input

M follows two rules for every input:

  • Scaling: multiplying an input by a number multiplies its output by the same number.
  • Adding: adding two inputs and then applying M gives the same result as applying M to each input separately and adding the outputs.

These rules make M linear. They let us find an output by transforming simpler pieces and adding the results.

The picture shows both rules. On the left, doubling (3, 1) doubles its output (7, 5). On the right, we split the input into (3, 0) and (0, 1); their outputs add up to (7, 5).

Two rules that make M linearTwo panels in ordinary coordinates. Left: the input x = (3, 1) has output (7, 5); the doubled input 2x = (6, 2) has output (14, 10), exactly twice (7, 5). Right: the input (3, 1) is split into a = (3, 0) and b = (0, 1). Their outputs Ma = (6, 3) and Mb = (1, 2), placed tip to tail, add to Mx = (7, 5). Pieces in, pieces out Ordinary coordinates; both panels use the same M Double the input The output doubles too. 0 3 6 7 14 1 2 5 10 x 2x Mx = (7, 5) M(2x) = (14, 10) = 2Mx Split the input Each piece goes through on its own. 0 3 6 7 1 3 5 a = (3, 0) b = (0, 1) x = a + b Ma = (6, 3) Mb = (1, 2) Ma + Mb = (7, 5) = Mx Scale the input and the output scales. Add inputs and the outputs add.
Two rules that make M linearTwo panels in ordinary coordinates. Left: the input x = (3, 1) has output (7, 5); the doubled input 2x = (6, 2) has output (14, 10), exactly twice (7, 5). Right: the input (3, 1) is split into a = (3, 0) and b = (0, 1). Their outputs Ma = (6, 3) and Mb = (1, 2), placed tip to tail, add to Mx = (7, 5). Pieces in, pieces out Ordinary coordinates; both panels use the same M Double the input The output doubles too. 0 3 6 7 14 1 2 5 10 x 2x Mx = (7, 5) M(2x) = (14, 10) = 2Mx Split the input Each piece goes through on its own. 0 3 6 7 1 3 5 a = (3, 0) b = (0, 1) x = a + b Ma = (6, 3) Mb = (1, 2) Ma + Mb = (7, 5) = Mx Scale the input and the output scales. Add inputs and the outputs add.
Pieces in, pieces out. Left: multiplying the input by a factor multiplies its output by the same factor. Right: adding inputs adds their outputs, M(a + b) = Ma + Mb. Here a = (3, 0) and b = (0, 1); their outputs (6, 3) and (1, 2) add to (7, 5).

The scaling rule also means that zero in gives zero out: M leaves the origin in place.

Read the columns to see where the unit steps go

What happens to a single horizontal step, e₁ = (1, 0)? M sends it to (2, 1), which is the first column of the matrix. A single vertical step, e₂ = (0, 1), goes to (1, 2), the second column.

Matrix columns are the transformed coordinate unit vectorsTwo coordinate planes use the same scale. Before applying M, the blue unit vector e1=(1,0) points right and the orange unit vector e2=(0,1) points up. After applying M with rows (2,1) and (1,2), they land at Me1=(2,1) and Me2=(1,2). These endpoints are the first and second columns of M, respectively. The columns tell us where the unit steps go One unit along each axis After applying M 0 1 2 1 2 x1​ x2​ 0 1 2 1 2 x1​ x2​ e1​ = (1, 0) e2​ = (0, 1) Me1​ = (2, 1) Me2​ = (1, 2) First column: where e1​ lands. Second column: where e2​ lands.
Each column is where one unit step lands. Follow the blue horizontal step and the orange vertical step from input to output. Both panels use the same scale.

Our input (3, 1) is three horizontal unit steps plus one vertical unit step. Since M is linear, its output is three copies of the first column plus one copy of the second:

Mx = 3(2, 1) + (1, 2) = (7, 5)

Rows are for computing the output one coordinate at a time. Columns show how the transformed unit steps build the output. Same answer, two ways of looking at it.

3. The dot product

We need a way to check whether two arrows are perpendicular. Later, the same calculation will measure how much of one arrow lies along another.

A test for right angles

Take the arrows a = (2, 1) and b = (1, −2). Multiply matching entries, then add. The result is a single number called their dot product:

a · b = 2 × 1 + 1 × (−2) = 0

The two products, 2 and −2, cancel. A zero dot product tells us that these arrows are perpendicular.

For any two vectors with entries (a₁, a₂) and (b₁, b₂), the same calculation is:

a · b = a₁b₁ + a₂b₂

The sign tells you about the angle

For two nonzero vectors, a positive dot product means the angle between them is less than 90°. A negative one means it’s more than 90°. Exactly zero means exactly 90°.

The dot product distinguishes three kinds of alignmentThe reference vector a=(2,1) is blue in every panel. With b=(1,1), the dot product is 3 and the angle is acute. With b=(1,-2), the dot product is zero and the vectors are perpendicular. With b=(-2,1), the dot product is -3 and the angle is obtuse. What does the sign tell us about the angle? Same reference in every panel: a = (2, 1) b = (1, 1) a b a · b = 3 Less than 90° b = (1, −2) a b a · b = 0 Right angle: 90° b = (−2, 1) a b a · b = −3 More than 90°
Watch the angle as the second arrow moves. The first arrow stays put in all three panels. The middle pair is perpendicular, and its dot product is zero.

Two nonzero vectors are perpendicular exactly when their dot product is zero. We’ll use this test to find a perpendicular remainder in Chapter 5. Vectors with a zero dot product are called orthogonal.

Comic: we're orthogonalPanel 1: Two stick figures stand apart, and between them two arrows meet at a right angle. B says: I think we're orthogonal. A asks: What does that mean? Panel 2: B explains: Our dot product is zero. Neither of us has any component along the other. A says: Oh. Panel 3: A, hand on chin, says: Is it my length? I can normalize. B says: That won't change the angle. I think we're orthogonal. What does that mean? Our dot product is zero. Neither of us has any component along the other. Oh. Is it my length? I can normalize. That won't change the angle.
Comic: we're orthogonalPanel 1: Two stick figures stand apart, and between them two arrows meet at a right angle. B says: I think we're orthogonal. A asks: What does that mean? Panel 2: B explains: Our dot product is zero. Neither of us has any component along the other. A says: Oh. Panel 3: A, hand on chin, says: Is it my length? I can normalize. B says: That won't change the angle. I think we're orthogonal. What does that mean? Our dot product is zero. Neither of us has any component along the other. Oh. Is it my length? I can normalize. That won't change the angle.
Perpendicular arrows have a dot product of zero. Resizing them leaves the right angle unchanged.

Our earlier pair passes the test: (1, −1) and (2, 2) give 1 × 2 + (−1) × 2 = 0. The arithmetic confirms the right angle without trusting anybody’s drawing skills. With more entries, the rule is the same: multiply matching entries and add.

The number also depends on length

Double either arrow and the dot product doubles, even though the angle stays the same. So the dot product depends on both the angle and the lengths of the arrows.

We can simplify things by making the reference arrow one unit long. The dot product then tells us how much of the other arrow lies along that direction. A positive value means that part points with the reference arrow; a negative value means it points against it. First, we’ll build this unit arrow, then see why the measurement works.

Optional: the same calculation in matrix notation

In matrix notation, a vector’s entries are usually stacked in a column. The transpose, written aᵀ, turns that column into a row. Multiplying the row aᵀ by the column b multiplies matching entries and adds them, just as we did above.

So aᵀb and a · b are two ways to write the same dot product.

4. Length and unit vectors

Length versus squared length

To make an arrow one unit long, we first need to know its length. Squared length is just the length multiplied by itself.

For a separate example, take an arrow of length 3. Its squared length is 3 × 3 = 9. If we double every coordinate:

Measurement Length-3 arrow After doubling
Length 3 6
Squared length 3 × 3 = 9 6 × 6 = 36

The length doubles, but the squared length becomes four times as large. To get the length back, take the square root: √9 = 3.

Optional: squared growth in a pizza example
Comic: the pizza problemPanel 1: At a pizza counter holding two 12-inch pizzas and one 18-inch pizza, C asks: Two 12-inch pizzas, or one 18-inch? B points at the big one: The 18. It's more pizza than both 12s together. Panel 2: C says: No way. B says: 18 squared is 324. 12 squared plus 12 squared is 288. Area grows with the square of the size. 12 in 12 in 18 in Two 12-inch pizzas, or one 18-inch? The 18. It's more pizza than both 12s together. No way. 182​ = 324. 122​ + 122​ = 288. Area grows with the square of the size.
Comic: the pizza problemPanel 1: At a pizza counter holding two 12-inch pizzas and one 18-inch pizza, C asks: Two 12-inch pizzas, or one 18-inch? B points at the big one: The 18. It's more pizza than both 12s together. Panel 2: C says: No way. B says: 18 squared is 324. 12 squared plus 12 squared is 288. Area grows with the square of the size. 12 in 12 in 18 in Two 12-inch pizzas, or one 18-inch? The 18. It's more pizza than both 12s together. No way. 182​ = 324. 122​ + 122​ = 288. Area grows with the square of the size.
Doubling a pizza's diameter quadruples its area. Doubling an arrow quadruples its squared length.

Find length from the coordinates

For our arrow (3, 1), the horizontal and vertical steps make a right triangle, so Pythagoras gives squared length 3² + 1² = 10. Its length is √10, about 3.16.

Dotting x with itself adds up those same squared coordinates. We write the length of x as ‖x‖, with double bars. It’s also called the Euclidean norm:

‖x‖² = x · x = x₁² + x₂²

Make a one-unit measuring step

To measure along a direction, we want a standard step. An arrow of length exactly one does the job. It’s called a unit vector.

Our x has length √10, so dividing every coordinate by √10 makes its length one. Both entries shrink by the same factor, so the direction doesn’t change. Call the new arrow x̂, read “x-hat”:

x̂ = x/‖x‖ = (3, 1)/√10
Normalize x to make an arrow one unit longIn ordinary coordinates, the blue vector x=(3,1) and its shorter teal version x-hat point in exactly the same direction. The unit circle marks a distance of one from the origin. Dividing x by its length, square root ten, puts the tip of x-hat on that circle. Both axes use the same scale. Same direction, one unit long Ordinary coordinates x1​ x2​ 3 1 x = (3, 1) x̂ Circle radius = 1 Original arrow: x Original length: √10 x̂ = x / √10 New length: 1 The direction stays the same. Divide every coordinate by the arrow’s length.
Normalize x to make an arrow one unit longIn ordinary coordinates, the blue vector x=(3,1) and its shorter teal version x-hat point in exactly the same direction. The unit circle marks a distance of one from the origin. Dividing x by its length, square root ten, puts the tip of x-hat on that circle. Both axes use the same scale. Same direction, one unit long Ordinary coordinates x1​ x2​ 3 1 x = (3, 1) x̂ Circle radius = 1 Original arrow: x Original length: √10 x̂ = x / √10 New length: 1 The direction stays the same.
Same direction, length one. The tip of x̂ lands on the circle of radius one. We shortened the arrow without turning it, which gives us a one-unit step along x's direction.

As a check, x̂ has squared length 9/10 + 1/10 = 1. Dividing a nonzero vector by its length is called normalization. In Chapter 8, we’ll apply the same operation to our reference arrows.

How the dot product includes both length and angle

Let θ be the angle between two nonzero arrows a and b. Then a · b = ‖a‖ ‖b‖ cos θ. The lengths explain why scaling either arrow changes the dot product. The cosine explains the sign: at 90°, it is zero. If b has length one, only a’s length and its alignment with b remain in the measurement.

5. Projection: find the part along a line

Split one arrow into two useful pieces

Start with x = (3, 1). We want the part along the diagonal through d = (1, 1).

Imagine dropping a perpendicular from the tip of x onto that diagonal. The arrow from the origin to the landing point is the projection, or shadow, of x on the line. Call it p. The remaining step from p’s tip to x’s tip is r.

Comic: projection is a shadowPanel 1: The sun is directly overhead and its rays come straight down. An arrow labeled x leans out of the ground; its shadow, labeled p, lies on the ground directly beneath it, and a dashed drop from the tip of x meets the ground at a right angle. A says: Projection is a shadow, when the light hits the line at a right angle. Panel 2: Beside a whiteboard sketch of a low sun casting a long, slanted shadow, B asks: And if the light comes in at an angle? A says: Then it's a different kind of projection, and I will not be taking questions. x p (the shadow) Projection is a shadow, when the light hits the line at a right angle. And if the light comes in at an angle? Then it's a different kind of projection, and I will not be taking questions.
Comic: projection is a shadowPanel 1: The sun is directly overhead and its rays come straight down. An arrow labeled x leans out of the ground; its shadow, labeled p, lies on the ground directly beneath it, and a dashed drop from the tip of x meets the ground at a right angle. A says: Projection is a shadow, when the light hits the line at a right angle. Panel 2: Beside a whiteboard sketch of a low sun casting a long, slanted shadow, B asks: And if the light comes in at an angle? A says: Then it's a different kind of projection, and I will not be taking questions. x p (the shadow) Projection is a shadow, when the light hits the line at a right angle. And if the light comes in at an angle? Then it's a different kind of projection, and I will not be taking questions.
A perpendicular drop finds the projection. The remaining step meets the reference line at a right angle.

For our example, the two pieces are:

x = p + r = (2, 2) + (1, −1)
Find the closest point on the diagonalIn ordinary coordinates, the diagonal through the origin has direction d=(1,1). The closest point to the tip of x=(3,1) is (2,2). The teal projection p runs from the origin to that point. The orange remainder r runs from the tip of p to the tip of x and meets the diagonal at a right angle. It moves one step right and one step down, so r=(1,-1), even though it starts at (2,2). A faint alternate point at (1,1) has a longer connection to x. Following p then r reaches the same point as x. Which point on the line is closest to the tip of x? Ordinary coordinates x1​ x2​ Chosen line d = (1, 1) Longer Another point Closest point p x r Follow p, then r, to reach x. x: the original arrow From (0, 0) to (3, 1) p: component along the line Ends at the closest point r: perpendicular remainder Starts at the tip of p Ends at the tip of x The shortest connection meets the line at a right angle.
Find the closest point on the diagonalIn ordinary coordinates, the diagonal through the origin has direction d=(1,1). The closest point to the tip of x=(3,1) is (2,2). The teal projection p runs from the origin to that point. The orange remainder r runs from the tip of p to the tip of x and meets the diagonal at a right angle. It moves one step right and one step down, so r=(1,-1), even though it starts at (2,2). A faint alternate point at (1,1) has a longer connection to x. Following p then r reaches the same point as x. Which point on the line is closest to the tip of x? Ordinary coordinates x1​ x2​ Chosen line d = (1, 1) Longer Another point Closest point p x r Follow p, then r, to reach x. x: the original arrow From (0, 0) to (3, 1) p: component along the line Ends at the closest point r: perpendicular remainder Starts at the tip of p Ends at the tip of x The shortest connection is perpendicular.
Follow p along the line, then r to the tip of x. The faint alternative connection is longer than the perpendicular one. The coordinates of r describe its movement from p's tip, even though it doesn't start at the origin.

The piece p = (2, 2) follows the diagonal. The remainder r = (1, −1) is perpendicular to it: its dot product with d = (1, 1) is 1 − 1 = 0. These are the two checks that make this the projection split.

Optional: how do we find (2, 2)?

A point on the diagonal has equal coordinates, so write the unknown projection as $p=(a,a)$. The arrow from $p$ to our original point $x=(3,1)$ is:

\[r=x-p=(3-a,\;1-a)\]

The diagonal points in the direction $(1,1)$. We want $r$ to be perpendicular to that direction, so their dot product must be zero. Multiply matching coordinates and add:

\[r\cdot(1,1)=(3-a)\times1+(1-a)\times1=0\]

Since both multiplications are by 1, this simplifies to:

\[(3-a)+(1-a)=0\]

Combining terms gives $4-2a=0$, so $a=2$. Our projection is therefore $p=(2,2)$.

The remaining arrow is $r=(1,-1)$, which is perpendicular to the diagonal. This perpendicular connection is the shortest path from $x$ to the line.

Find a projection with a dot product

Let u be an arrow of length one along the chosen line. Think of u as a one-unit step in that direction.

The dot product x · u gives us a number. For example, if that number is 3, the projection is 3u: an arrow three units long in the direction of u. The original arrow x may also have a perpendicular piece.

If the number is −3, the projection points three units in the opposite direction.

To get the projection arrow, multiply that number by u:

p = (x · u)u

The number x · u is called the coefficient. The resulting arrow p is the component of x along the line.

Optional: the same component with two measuring steps

The diagonal arrow d = (1, 1) has length √2. Divide each entry by √2 to make a one-unit arrow:

u = (1, 1)/√2

The dot product tells us how many u steps to take:

x · u = (3 + 1)/√2 = 2√2

So we can reach the projection using either 2 steps of d or 2√2 steps of u:

p = 2d = 2√2 u = (2, 2)
The component stays fixed when its reference arrow changesBoth panels use ordinary coordinates at the same scale. They show the same teal component p=(2,2). The dashed dark reference d=(1,1) has length square root two, so p=2d. The shorter dashed reference u=(1,1)/sqrt(2) has length one, so p=2sqrt(2)u. Shortening the reference arrow means needing more copies to reach the same point. The teal component does not change. A shorter reference needs more copies to reach p Ordinary coordinates; both panels use the same scale Original reference Length √2 p (2, 2) d 2 × d = p d = (1, 1) Unit reference Length 1 p (2, 2) u 2√2 × u = p u = (1, 1) / √2 The reference changes. The teal component stays the same.
The component stays fixed when its reference arrow changesBoth panels use ordinary coordinates at the same scale. They show the same teal component p=(2,2). The dashed dark reference d=(1,1) has length square root two, so p=2d. The shorter dashed reference u=(1,1)/sqrt(2) has length one, so p=2sqrt(2)u. Shortening the reference arrow means needing more copies to reach the same point. The teal component does not change. Shorter reference arrow, more copies to reach p Ordinary coordinates; same scale Original reference Length √2 p (2, 2) d 2 × d = p d = (1, 1) Unit reference Length 1 p (2, 2) u 2√2 × u = p u = (1, 1) / √2 The teal component stays the same.
The reference arrow gets shorter; the component stays put. Both drawings use the same coordinate scale. The bigger coefficient makes up for the shorter step.

The unit arrow u is shorter than d, so we need more steps to reach the same point. The number of steps changes, but the projection stays at (2, 2).

The squared lengths add

Because p and r meet at a right angle, Pythagoras applies. Their squared lengths add to x’s squared length:

‖x‖² = ‖p‖² + ‖r‖² = 8 + 2 = 10

This will help us measure how much of an input lies in each of two perpendicular directions.

6. Eigenvectors and eigenvalues

M can change both an arrow’s length and direction. We want to find directions where it only scales the arrow. If we can split an input along those directions, we can get its output by scaling the pieces and adding them.

Watch three arrows go through the same matrix

Use our same matrix:

M =

Compare our input x = (3, 1) with two diagonal arrows, q₁ = (1, −1) and q₂ = (1, 1). Press Play transformation or drag from Before to After. This shows one application of M. The frames in between are animation steps, not repeated matrix multiplications.

Apply the same matrix to three arrowsThe final state of the matrix transformation with rows (2,1) and (1,2), drawn by hand. The grid has been stretched along the upward diagonal. The teal vector x=(3,1) changes to Mx=(7,5), changing its direction. The blue vector q1=(1,-1) is unchanged. The orange vector q2=(1,1) becomes (3,3), three times its original length on the same line. Dashed arrows mark the starting positions of x and q2. The ordinary coordinate axes stay fixed, with equal scales. The animation moves from each input to its output under one application of M. Almost everybody moves. Two directions stay on their lines. The teal arrow turns. Blue and orange stay on their dashed lines. x1​ x2​ -2 2 4 6 8 10 2 4 6 0 Mx Mq2​ = 3q2​ Mq1​ = q1​ Output Mx: (7, 5) q1​: unchanged q2​: length × 3 Dashed arrows: where x and q2​ started. The axes stay put.
100%
BeforeAfter M

Follow the arrows from where they start to where M sends them. This is one application of M.

The same M transforms the whole grid. The ordinary axes stay fixed so we can compare before and after. Dashed arrows mark where x and q₂ began; q₁ doesn't move at all.
Input Output What happened?
x = (3, 1) Mx = (7, 5) It grew and turned.
q₁ = (1, −1) Mq₁ = (1, −1) It stayed exactly the same: multiply by 1.
q₂ = (1, 1) Mq₂ = (3, 3) It stayed on its line and grew: multiply by 3.

Name the arrow and the number

A nonzero arrow that the matrix multiplies by one number is an eigenvector. That number is its eigenvalue. In symbols:

Mv = λv

Read this as: “applying M to v has the same effect as multiplying v by λ.” The eigenvector tells us the direction; the eigenvalue tells us the multiplier. For M, q₁ has eigenvalue λ₁ = 1 and q₂ has eigenvalue λ₂ = 3.

Comic: the eigenvector job interviewM, a character whose head is the matrix with rows 2 1 and 1 2, interviews candidates from behind a desk. Panel 1: M asks: What happens when I'm applied to you? A candidate named q2 = (1, 1) says: I stay on my line and get three times longer. M says: Hired. Panel 2: A candidate named x = (3, 1) says: I get longer, and I turn a little toward the... M says: Next! Panel 3: A tiny candidate named 0 cheers: I stay on every line! M, head in hand, says: That's the problem. 2 1 1 2 q2​ = (1, 1) What happens when I'm applied to you? I stay on my line and get three times longer. Hired. 2 1 1 2 x = (3, 1) I get longer, and I turn a little toward the— Next! 2 1 1 2 0 I stay on every line! That's the problem.
Comic: the eigenvector job interviewM, a character whose head is the matrix with rows 2 1 and 1 2, interviews candidates from behind a desk. Panel 1: M asks: What happens when I'm applied to you? A candidate named q2 = (1, 1) says: I stay on my line and get three times longer. M says: Hired. Panel 2: A candidate named x = (3, 1) says: I get longer, and I turn a little toward the... M says: Next! Panel 3: A tiny candidate named 0 cheers: I stay on every line! M, head in hand, says: That's the problem. 2 1 1 2 q2​ = (1, 1) What happens when I'm applied to you? I stay on my line and get three times longer. Hired. 2 1 1 2 x = (3, 1) I get longer, and I turn a little toward the— Next! 2 1 1 2 0 I stay on every line! That's the problem.
Eigenvectors must be nonzero. The zero vector satisfies M0 = λ0 for every λ, so it cannot identify a particular eigenvalue.

The direction matters more than the length

Any nonzero multiple of q₁ is still an eigenvector with eigenvalue 1. Any nonzero multiple of q₂ still has eigenvalue 3. Making an arrow longer does not change which eigenvector line it lies on.

For other matrices, a negative eigenvalue reverses the arrow along the same line. A zero eigenvalue sends a nonzero arrow to the origin. The zero arrow itself is excluded: multiplying it by any number gives zero, so it cannot identify a particular multiplier.

Optional: check every direction, and apply M more than once

The chart shows how much M turns an arrow for each starting direction. The two eigenvector lines are the only lines it leaves unturned.

Chart: how far M turns an arrow, by directionA hand-drawn chart. The horizontal axis is the direction an arrow starts in, from 0 to 180 degrees measured from the x1-axis. The vertical axis is how many degrees M turns it, counterclockwise positive. The curve starts at about 27 degrees at 0, falls to zero at 45 degrees (the direction of q2, which is only stretched by 3), reaches minus 30 degrees at 105, returns to zero at 135 degrees (the direction of minus q1, on the q1 line, which M leaves unchanged), and climbs to plus 30 degrees at 165. The point for x = (3, 1), at about 18 degrees, shows a turn of about 17 degrees. Dashed lines at plus and minus 30 degrees mark the largest turn of any direction. Every other direction is turned toward the q2 line. How far does M turn an arrow? −30° −15° 0° +15° +30° 0° 45° 90° 135° 180° direction the arrow starts in how much M turns it +30°: the most M turns anything −30°: the most, the other way q2​'s direction: no turn, just × 3 q1​'s line: no turn at all x = (3, 1) gets turned about 17° Every other direction gets turned toward the q2​ line, from one side or the other.
Directions 180° apart turn by the same amount, because M(−x) = −Mx. The pattern repeats after half a turn.

Other arrows turn toward the q₂ line, by at most 30° in one application. Repeated applications move them closer to that line unless they started exactly on q₁.

Along q₂, each application multiplies by 3. Two applications multiply by 3 × 3 = 9.

The list of eigenvalues, including repeats, is called the spectrum.

The moving-grid approach is inspired by 3Blue1Brown’s lesson on eigenvectors and eigenvalues.

7. Describe the same vector in new coordinates

Describe the same arrow using different steps

In ordinary coordinates, x = (3, 1) means three horizontal unit steps and one vertical unit step. We can reach exactly the same point using the eigenvectors q₁ = (1, −1) and q₂ = (1, 1) as our reference steps:

x = q₁ + 2q₂ = (1, −1) + (2, 2) = (3, 1)

Using q₁ and q₂, x has coordinates (1, 2): one q₁ step and two q₂ steps. Its ordinary horizontal and vertical coordinates are still (3, 1). Changing coordinates changes the description of x. It does not move x.

Comic: two sets of directionsPanel 1: B, holding a map, asks: How do I get to (3, 1)? A points and says: Three blocks east, one block north. Panel 2: C stands beside a signpost with two diagonal signs, q1 St and q2 Ave, and says: Or one block down q1 Street and two blocks up q2 Avenue. B asks: Are you both right? C says: Yes. How do I get to (3, 1)? Three blocks east, one block north. q1​ St q2​ Ave Or one block down q1​ St and two blocks up q2​ Ave. ...Are you both right? Yes.
Comic: two sets of directionsPanel 1: B, holding a map, asks: How do I get to (3, 1)? A points and says: Three blocks east, one block north. Panel 2: C stands beside a signpost with two diagonal signs, q1 St and q2 Ave, and says: Or one block down q1 Street and two blocks up q2 Avenue. B asks: Are you both right? C says: Yes. How do I get to (3, 1)? Three blocks east, one block north. q1​ St q2​ Ave Or one block down q1​ St and two blocks up q2​ Ave. ...Are you both right? Yes.
The same arrow can have different coordinates. Three horizontal steps and one vertical step reach the same point as one q₁ step and two q₂ steps.

Transform each piece, then add

M keeps the q₁ component the same and triples the q₂ component. So 1q₁ + 2q₂ becomes 1q₁ + 6q₂. Using q₁ and q₂, the output coordinates are (1, 6). Adding the component arrows gives the output in ordinary coordinates:

Mx = q₁ + 6q₂ = (1, −1) + (6, 6) = (7, 5)
Reference steps Input coordinates Output coordinates
Horizontal and vertical unit steps (3, 1) (7, 5)
q₁ and q₂ (1, 2) (1, 6)
Change the description first, then apply the matrixThree stages use ordinary coordinate axes and the same scale. First, the input x=(3,1) is shown as the horizontal component (3,0) plus the vertical component (0,1). Second, exactly the same input is shown as q1=(1,-1) plus 2q2=(2,2), with eigenvector coordinates (1,2). Third, M keeps the q1 component and triples the q2 component, giving Mx=q1+6q2=(7,5), with eigenvector coordinates (1,6). A faint copy of the original x remains in the last stage. Changing coordinates leaves x unchanged; applying M changes it. Change the description first. Then apply M. Ordinary axes in every panel; the drawing scale stays the same. 1. Use horizontal and vertical Ordinary coordinates: (3, 1) x1​ x2​ 0 3e1​ e2​ x = (3, 1) Each coordinate counts steps along a horizontal or vertical arrow. 2. Use eigenvector directions Eigenvector coordinates: (1, 2) x1​ x2​ 0 q1​ 2q2​ x = (3, 1) The same x is 1 copy of q1​ plus 2 copies of q2​. 3. Apply M to the components Eigenvector coordinates: (1, 6) x1​ x2​ 0 original x q1​ 6q2​ Mx Keep q1​ and triple 2q2​. Their sum is Mx = (7, 5). In eigenvector coordinates: (1, 2) → (1, 6) Keep the first coordinate. Triple the second. The ordinary-coordinate output is the same vector: Mx = (7, 5). Changing coordinates changes the description. Applying M changes the vector.
Change the description first, then apply the matrixThree stages use ordinary coordinate axes and the same scale. First, the input x=(3,1) is shown as the horizontal component (3,0) plus the vertical component (0,1). Second, exactly the same input is shown as q1=(1,-1) plus 2q2=(2,2), with eigenvector coordinates (1,2). Third, M keeps the q1 component and triples the q2 component, giving Mx=q1+6q2=(7,5), with eigenvector coordinates (1,6). A faint copy of the original x remains in the last stage. Changing coordinates leaves x unchanged; applying M changes it. Describe x. Then apply M. Ordinary axes in every panel. The drawing scale stays the same. 1. Use horizontal and vertical Ordinary coordinates: (3, 1) x1​ x2​ 0 3e1​ e2​ x = (3, 1) Each coordinate counts steps along a horizontal or vertical arrow. 2. Use eigenvector directions Eigenvector coordinates: (1, 2) x1​ x2​ 0 q1​ 2q2​ x = (3, 1) The same x is 1 copy of q1​ plus 2 copies of q2​. 3. Apply M to the components Eigenvector coordinates: (1, 6) x1​ x2​ 0 original x q1​ 6q2​ Mx Keep q1​ and triple 2q2​. Their sum is Mx = (7, 5). Only the third stage changes the vector.
Changing coordinates keeps x fixed. Applying M produces Mx. All three stages use the same ordinary scale. The first two split the same input into different pieces. In the third, the q₁ piece stays put and the q₂ piece triples. The faint original x shows how much it changed.

This works because M is linear: we can transform the pieces separately and then add the results. Eigenvector coordinates make each separate transformation a simple multiplication.

What makes a valid coordinate system?

A basis is a set of reference arrows that can build every vector by scaling and adding. Each vector must have exactly one choice of coefficients.

In the plane, any two nonparallel arrows form a basis. Our q₁ and q₂ qualify. Two arrows pointing along the same line do not: they cannot reach points away from that line.

Optional: “span” and “linearly independent”
What makes two arrows a coordinate systemTwo panels in ordinary coordinates. Left: the references e1 = (1, 0) and 2e1 = (2, 0) both lie on the horizontal axis. Every combination of them stays on that line, shown as a shaded band with dots at the reachable points. The target x = (3, 1), above the line, is marked as out of reach, and the point (2, 0) is noted as having two descriptions: 2 copies of e1 or 1 copy of 2e1. Right: q1 = (1, -1) and q2 = (1, 1) point in different directions. A faint grid of lines parallel to each shows that their combinations cover the plane, and x = (3, 1) is reached by one copy of q1 followed by two copies of q2. Enough directions, and only one recipe per point Ordinary coordinates Two parallel references “East” and “more east.” 0 e1​ 2e1​ x = (3, 1) can't get here Every combination stays on the line. And (2, 0) is 2e1​ or 1 × 2e1​: two recipes. Two different directions q1​ and q2​ form a basis. 0 q1​ q2​ x = q1​ + 2q2​ Two directions reach every point of the plane, each in exactly one way. A basis reaches every point, and gives each point exactly one description.
What makes two arrows a coordinate systemTwo panels in ordinary coordinates. Left: the references e1 = (1, 0) and 2e1 = (2, 0) both lie on the horizontal axis. Every combination of them stays on that line, shown as a shaded band with dots at the reachable points. The target x = (3, 1), above the line, is marked as out of reach, and the point (2, 0) is noted as having two descriptions: 2 copies of e1 or 1 copy of 2e1. Right: q1 = (1, -1) and q2 = (1, 1) point in different directions. A faint grid of lines parallel to each shows that their combinations cover the plane, and x = (3, 1) is reached by one copy of q1 followed by two copies of q2. Enough directions, and only one recipe per point Ordinary coordinates Two parallel references “East” and “more east.” 0 e1​ 2e1​ x = (3, 1) can't get here Every combination stays on the line. And (2, 0) is 2e1​ or 1 × 2e1​: two recipes. Two different directions q1​ and q2​ form a basis. 0 q1​ q2​ x = q1​ + 2q2​ Two directions reach every point of the plane, each in exactly one way. A basis reaches every point, and gives each point exactly one description.
Enough directions, and only one recipe per point. Left: with e₁ and 2e₁, every combination stays on the horizontal line, and even points on the line have two descriptions. Right: q₁ and q₂ point in different directions, so their combinations tile the whole plane, and each point gets exactly one recipe.

Reference arrows span the plane if their combinations reach every point. They are linearly independent if none is a combination of the others. Together, these properties give enough directions and a unique recipe.

The arrows e₁ and 2e₁ fail both tests. They only reach the horizontal line, and even there a point can have different recipes: (2, 0) is two copies of e₁ or one copy of 2e₁.

We can now understand every input from the matrix’s responses along its eigenvector lines. Next, we will see why perpendicular reference directions are especially useful.

8. Why perpendicular reference arrows help

We can already transform x by splitting it along q₁ and q₂. Now we want an easy way to find those pieces for any input. Perpendicular unit reference arrows let us do that with dot products.

Use reference arrows of length one

Our original reference arrows q₁ and q₂ each have length √2. Divide each by √2 and call the resulting unit arrows u₁ and u₂. Each u arrow points in the same direction as its matching q arrow:

u₁ = q₁/√2 = (1, −1)/√2
u₂ = q₂/√2 = (1, 1)/√2

This changes the size of a reference step. It does not change x or its pieces. The same pieces now need √2 steps along u₁ and 2√2 steps along u₂.

The figure compares before: q₁ and q₂ with after: u₁ and u₂. From here on, we’ll use u₁ and u₂ for the unit reference arrows.

Change the reference steps while keeping the whole input fixedTwo complete decompositions use ordinary coordinates and the same scale. In each, the teal input x=(3,1), blue component (1,-1), and orange component (2,2) have the same endpoints. Ticks on the components mark equal reference steps. With the original references q1 and q2, a step has length square root two; the coefficients are 1 and 2. With unit references u1 and u2, a step has length one; the coefficients become square root two and twice square root two. Only the measuring steps and coefficients change. The input and its two components stay fixed. Shorter reference steps; the whole input stays fixed Ordinary coordinates; both panels use the same scale Before: q1​, q2​ Each q step has length √2. x1​ x2​ 0 (1, −1) (2, 2) x (3, 1) Blue component: 1 × q1​ Orange component: 2 × q2​ After: unit arrows u1​, u2​ Each u step has length 1. x1​ x2​ 0 (1, −1) (2, 2) x (3, 1) Blue component: √2 × u1​ Orange component: 2√2 × u2​ The references get shorter. The coefficients grow. The arrow tips do not move.
Change the reference steps while keeping the whole input fixedTwo complete decompositions use ordinary coordinates and the same scale. In each, the teal input x=(3,1), blue component (1,-1), and orange component (2,2) have the same endpoints. Ticks on the components mark equal reference steps. With the original references q1 and q2, a step has length square root two; the coefficients are 1 and 2. With unit references u1 and u2, a step has length one; the coefficients become square root two and twice square root two. Only the measuring steps and coefficients change. The input and its two components stay fixed. Change the measuring steps. Keep the whole x fixed. Ordinary coordinates; same scale Before: q1​, q2​ Each q step has length √2. x1​ x2​ 0 (1, −1) (2, 2) x (3, 1) Blue component: 1 × q1​ Orange component: 2 × q2​ After: unit arrows u1​, u2​ Each u step has length 1. x1​ x2​ 0 (1, −1) (2, 2) x (3, 1) Blue component: √2 × u1​ Orange component: 2√2 × u2​ The arrow tips have not moved.
Before: q₁, q₂. After: u₁, u₂. Each q arrow has length √2; each u arrow has length 1. The blue and orange arrows show the same full components in both panels. Only the reference steps and coefficients change: 1q₁ = √2u₁ and 2q₂ = 2√2u₂. Both drawings use the same scale.

Together, u₁ and u₂ form an orthonormal basis: the reference arrows are perpendicular to each other and each has length one.

Because these directions are perpendicular, projecting x onto either line recovers just the component along that line.

Each reference arrow is one unit long, so ignoring its sign, the coefficient gives the length of its component. A coefficient of 3 means three units along the reference arrow; −3 means three units in the opposite direction.

Squaring the coefficient gives the piece’s squared length. Since u₁ and u₂ are perpendicular unit arrows, we find each coefficient by taking a dot product:

Reference arrow Coefficient Squared length of the piece
u₁ c₁ = x · u₁ = √2 (√2)² = 2
u₂ c₂ = x · u₂ = 2√2 (2√2)² = 8

How the squared length is shared

Our split is x = (1, −1) + (2, 2). The pieces are perpendicular, so their squared lengths add: 2 + 8 = 10.

The first piece accounts for 2/10 = 20% of x’s squared length, and the second accounts for 8/10 = 80%. These percentages describe squared length. We’ll use these shares in Chapter 9 to compare input directions.

Why symmetry lets us choose perpendicular eigenvectors

M has matching entries across its main diagonal: the upper-right and lower-left entries are both 1. A matrix with this mirror property is called symmetric. Turning its rows into columns gives the same matrix, written Mᵀ = M.

Comic: M admires its reflectionM, the matrix-headed character, stands beside a big drawing of itself: the entries 2 1 over 1 2 in brackets, with a dashed main diagonal through both 2s and curved arrows swapping the two 1s across it. M says: Flip me across my main diagonal and I look exactly the same. B says: Show-off. Lettering at the top right reads: Symmetric: M transpose equals M. 2 1 1 2 2 1 1 2 Flip me across my main diagonal and I look exactly the same. Symmetric: MT​ = M Show-off.
M matches its reflection across the main diagonal. For a real symmetric matrix, the spectral theorem guarantees a basis of perpendicular unit eigenvectors.

The spectral theorem says that every real symmetric matrix has an orthonormal basis of eigenvectors, with real eigenvalues. We can choose enough perpendicular unit eigenvectors to describe every input.

For our two-dimensional example, this means we can write any input as:

x = c₁u₁ + c₂u₂

The coefficients c₁ and c₂ are numbers: they tell us how many steps to take along each unit arrow. The components c₁u₁ and c₂u₂ are the actual arrows that add up to x. Because u₁ and u₂ are perpendicular unit arrows, dot products give us the coefficients:

c₁ = x · u₁
c₂ = x · u₂

We’ll follow four steps for each input: find the coefficients, build the component arrows, scale each component by its eigenvalue, and add the outputs. Both examples use the same unit arrows, u₁ = (1, −1)/√2 and u₂ = (1, 1)/√2.

Example 1: x = (3, 1)

1. Find the coefficients. Dotting with u₁ subtracts the second coordinate from the first and divides by √2. Dotting with u₂ adds the coordinates and divides by √2:

c₁ = x · u₁ = (3 − 1)/√2 = √2
c₂ = x · u₂ = (3 + 1)/√2 = 2√2

2. Build the component arrows. Multiply each coefficient by its unit arrow. The √2 factors cancel:

c₁u₁ = √2 × (1, −1)/√2 = (1, −1)
c₂u₂ = 2√2 × (1, 1)/√2 = (2, 2)

Adding the pieces gives our input back: x = (1, −1) + (2, 2) = (3, 1).

3. Scale each component by its eigenvalue. M’s eigenvalues are 1 along u₁ and 3 along u₂. The first piece stays (1, −1); the second becomes 3 × (2, 2) = (6, 6).

4. Add the outputs. Together, the scaled pieces give Mx:

Mx = 1 × (c₁u₁) + 3 × (c₂u₂)
= 1 × (1, −1) + 3 × (2, 2)
= (1, −1) + (6, 6) = (7, 5)

The figure shows this example. On the left, M acts on unit arrows. On the right, it applies the same eigenvalues to the complete pieces of x = (3, 1).

What the spectral theorem says about MTwo panels in ordinary coordinates. Left: the dashed unit circle of all length-one inputs and, in teal, the ellipse their outputs land on after applying M. The ellipse's axes lie along the two eigenlines: it reaches 1 along u1, where M multiplies by 1, and 3 along u2, where M multiplies by 3. The unit input x-hat and its output M x-hat on the ellipse are drawn as a sample. Right: the recipe for x = (3, 1). Dashed drops give its shadows on the eigenlines, (1, -1) and (2, 2). The first is multiplied by 1 and stays put; the second is multiplied by 3 to give (6, 6). Added tip to tail, 1 times (1, -1) plus 3 times (2, 2) equals (7, 5), which is M x. The spectral theorem in a picture M scales two perpendicular pieces by 1 and 3 Every unit input, before and after ×1 along u1​, ×3 along u2​ 0 u1​ stays: ×1 u2​ → 3u2​: ×3 Mx̂ x̂ unit inputs their outputs Circle in, ellipse out. The ellipse's axes are the eigenlines. The recipe, on x = (3, 1) shadows → stretch each → add 0 shadow (1, −1) ×1: stays shadow (2, 2) ×3 → (6, 6) Mx x 1 × (1, −1) + 3 × (2, 2) = (7, 5) = Mx. Shadow, stretch, add. Scale the perpendicular eigenvector pieces, then add them. That's the theorem.
What the spectral theorem says about MTwo panels in ordinary coordinates. Left: the dashed unit circle of all length-one inputs and, in teal, the ellipse their outputs land on after applying M. The ellipse's axes lie along the two eigenlines: it reaches 1 along u1, where M multiplies by 1, and 3 along u2, where M multiplies by 3. The unit input x-hat and its output M x-hat on the ellipse are drawn as a sample. Right: the recipe for x = (3, 1). Dashed drops give its shadows on the eigenlines, (1, -1) and (2, 2). The first is multiplied by 1 and stays put; the second is multiplied by 3 to give (6, 6). Added tip to tail, 1 times (1, -1) plus 3 times (2, 2) equals (7, 5), which is M x. The spectral theorem in a picture M scales two perpendicular pieces by 1 and 3 Every unit input, before and after ×1 along u1​, ×3 along u2​ 0 u1​ stays: ×1 u2​ → 3u2​: ×3 Mx̂ x̂ unit inputs their outputs Circle in, ellipse out. The ellipse's axes are the eigenlines. The recipe, on x = (3, 1) shadows → stretch each → add 0 shadow (1, −1) ×1: stays shadow (2, 2) ×3 → (6, 6) Mx x 1 × (1, −1) + 3 × (2, 2) = (7, 5) = Mx. Shadow, stretch, add. Scale perpendicular eigenvector pieces, then add them. That's the theorem.
For M, scale each piece and add. The first piece stays the same; the second triples. Their sum is (7, 5). The left panel shows all unit inputs forming a circle and their outputs forming an ellipse. The whole arrow can turn because its two pieces grow by different amounts.

Example 2: x = (4, 2)

1. Find the coefficients. Use the same dot products with the new input:

c₁ = x · u₁ = (4 − 2)/√2 = √2
c₂ = x · u₂ = (4 + 2)/√2 = 3√2

2. Build the component arrows. Multiply each coefficient by its unit arrow:

c₁u₁ = √2 × (1, −1)/√2 = (1, −1)
c₂u₂ = 3√2 × (1, 1)/√2 = (3, 3)

They add up to the new input: x = (1, −1) + (3, 3) = (4, 2).

3. Scale each component by its eigenvalue. M still uses eigenvalues 1 and 3. The first piece stays (1, −1); the second becomes 3 × (3, 3) = (9, 9).

4. Add the outputs. The two scaled pieces give:

Mx = 1 × (1, −1) + 3 × (3, 3)
= (1, −1) + (9, 9) = (10, 8)

In both examples, c₁ is √2. But c₂ changes from 2√2 to 3√2, so the second component changes from (2, 2) to (3, 3). The coefficients describe the input; the eigenvalues describe how M scales its pieces. The eigenvalues stay the same because we are using the same M.

Each eigenvector piece stays on its own line. The complete input can still turn. For a different symmetric matrix, a multiplier can also be negative, reversing a piece, or zero, removing it.

We’ll return to our original input x = (3, 1) for the rest of the primer.

Optional: what can go wrong without symmetry?

Consider A with rows (1, 1) and (0, 2). Its eigenvector lines, through (1, 0) and (1, 1), meet at 45° rather than 90°.

Perpendicular eigenvectors are a symmetric matrix's privilegeTwo panels. Left: for the symmetric matrix M, with rows (2, 1) and (1, 2), the unit eigenvectors u1 = (1, -1) divided by square root two and u2 = (1, 1) divided by square root two lie on lines that meet at a right angle, marked 90 degrees. Right: for the matrix A with rows (1, 1) and (0, 2), which is not symmetric, the eigenvector lines run through (1, 0), with eigenvalue 1, and (1, 1), with eigenvalue 2. They meet at 45 degrees. Was our matrix just lucky? Eigenvector lines for two different matrices Our M: eigenlines at 90° M has rows (2, 1) and (1, 2). 0 u1​ (λ = 1) u2​ (λ = 3) 90° Matching off-diagonal entries: symmetric. Another matrix: eigenlines at 45° A has rows (1, 1) and (0, 2). 0 (1, 0), λ = 1 (1, 1), λ = 2 45° The 1 and the 0 don't match: not symmetric. Symmetry guarantees perpendicular eigenlines: the spectral theorem.
Perpendicular eigenvectors are a symmetric matrix's privilegeTwo panels. Left: for the symmetric matrix M, with rows (2, 1) and (1, 2), the unit eigenvectors u1 = (1, -1) divided by square root two and u2 = (1, 1) divided by square root two lie on lines that meet at a right angle, marked 90 degrees. Right: for the matrix A with rows (1, 1) and (0, 2), which is not symmetric, the eigenvector lines run through (1, 0), with eigenvalue 1, and (1, 1), with eigenvalue 2. They meet at 45 degrees. Was our matrix just lucky? Eigenvector lines for two different matrices Our M: eigenlines at 90° M has rows (2, 1) and (1, 2). 0 u1​ (λ = 1) u2​ (λ = 3) 90° Matching off-diagonal entries: symmetric. Another matrix: eigenlines at 45° A has rows (1, 1) and (0, 2). 0 (1, 0), λ = 1 (1, 1), λ = 2 45° The 1 and the 0 don't match: not symmetric. Symmetry guarantees perpendicular eigenlines: the spectral theorem.
Not every matrix gives perpendicular eigenlines. Left: M's unit arrows u₁ and u₂ lie on eigenlines that meet at 90°. Right: the matrix A with rows (1, 1) and (0, 2) has eigenlines through (1, 0) and (1, 1), only 45° apart. Rotation by 90° is worse still: it knocks every arrow off its line, so it has no real eigenvectors at all.

Perpendicular directions let us measure one piece at a time. When we project x onto the u₁ line, the u₂ piece contributes zero along that direction. So the projection gives us exactly the u₁ piece. The same works the other way around.

For A, the two complete pieces are (2, 0) and (1, 1). Add their coordinates to get the input: x = (2 + 1, 0 + 1) = (3, 1).

Projecting onto the horizontal line keeps only the horizontal part of each piece:

  • The first piece, (2, 0), is already horizontal, so it stays (2, 0).
  • The second piece, (1, 1), loses its upward movement but keeps its one unit to the right, becoming (1, 0).

Add these projections: (2, 0) + (1, 0) = (3, 0). The result includes a horizontal part from the second piece too. If the second piece were perpendicular to the horizontal line, its projection would be zero, leaving only the first piece, (2, 0).

What perpendicular eigenlines buy usTwo panels in ordinary coordinates, both splitting x = (3, 1) along a matrix's eigenlines. Left, M's eigenlines, which are perpendicular: the pieces (1, -1) and (2, 2) are drawn from the origin. Dashed perpendiculars dropped from the tip of x onto each eigenline land exactly on the tips of the pieces, and the squared lengths 2 and 8 add to 10, the squared length of x. Right, A's eigenlines, 45 degrees apart: the pieces are (2, 0) and (1, 1). The perpendicular from x onto the horizontal line lands at (3, 0), one unit past the piece's tip, and the one onto the diagonal lands at (2, 2), past the piece (1, 1). The squared lengths 4 and 2 add to 6, not 10. What do perpendicular pieces buy us? The same x = (3, 1), split along each matrix's eigenlines M's eigenlines, 90° apart x = (1, −1) + (2, 2) 0 piece (1, −1) = its shadow piece (2, 2) = its shadow x drops Squared lengths: 2 + 8 = 10 = ||x||2​. The dashed drops land on the piece tips. A's eigenlines, 45° apart x = 2 (1, 0) + 1 (1, 1) 0 piece (2, 0) shadow (3, 0) piece (1, 1) shadow (2, 2) x Squared lengths: 4 + 2 = 6, not 10. Each shadow overshoots its piece. Perpendicular pieces don't overlap: a shadow finds each piece, and squared lengths add.
What perpendicular eigenlines buy usTwo panels in ordinary coordinates, both splitting x = (3, 1) along a matrix's eigenlines. Left, M's eigenlines, which are perpendicular: the pieces (1, -1) and (2, 2) are drawn from the origin. Dashed perpendiculars dropped from the tip of x onto each eigenline land exactly on the tips of the pieces, and the squared lengths 2 and 8 add to 10, the squared length of x. Right, A's eigenlines, 45 degrees apart: the pieces are (2, 0) and (1, 1). The perpendicular from x onto the horizontal line lands at (3, 0), one unit past the piece's tip, and the one onto the diagonal lands at (2, 2), past the piece (1, 1). The squared lengths 4 and 2 add to 6, not 10. What do perpendicular pieces buy us? The same x = (3, 1), split along each matrix's eigenlines M's eigenlines, 90° apart x = (1, −1) + (2, 2) 0 piece (1, −1) = its shadow piece (2, 2) = its shadow x drops Squared lengths: 2 + 8 = 10 = ||x||2​. The dashed drops land on the piece tips. A's eigenlines, 45° apart x = 2 (1, 0) + 1 (1, 1) 0 piece (2, 0) shadow (3, 0) piece (1, 1) shadow (2, 2) x Squared lengths: 4 + 2 = 6, not 10. Each shadow overshoots its piece. Perpendicular pieces don't overlap: a shadow finds each piece, and squared lengths add.
Perpendicular pieces make two calculations easy. On the left, each projection finds the corresponding piece, and squared lengths add: 2 + 8 = 10. On the right, the reference lines are slanted. Projections no longer recover the pieces, and 4 + 2 is not the whole input's squared length, 10.

Perpendicular pieces also have squared lengths that add. This is Pythagoras’ rule: for M’s pieces, 2 + 8 = 10, the squared length of x. It is the squared lengths that add this way, rather than the ordinary distances.

For A’s pieces, the squared lengths are 4 and 2. Adding them gives 6, while x still has squared length 10. We need an extra term: twice the dot product of the pieces. Their dot product is (2, 0) · (1, 1) = 2, so the full calculation is 4 + 2 + 2 × 2 = 10. When pieces are perpendicular, their dot product is zero and that extra term disappears.

We can still use nonperpendicular eigenvectors to split an input and scale its pieces. We lose the two shortcuts: finding each piece directly by projection, and adding squared lengths without an extra term. Some matrices, such as a 90° rotation, do not even have real eigenvectors.

Optional: why eigenvectors with different eigenvalues are perpendicular for a symmetric matrix

Let v and w be eigenvectors of a real symmetric matrix M, with eigenvalues α and β. Symmetry lets us move M from one side of the dot product to the other: vᵀMw = (Mv)ᵀw. Substituting Mw = βw and Mv = αv gives β(v · w) = α(v · w). If α and β are different, this can hold only when v · w = 0. So the vectors are perpendicular. The full spectral theorem also guarantees enough eigenvectors to form a basis, including when eigenvalues repeat; within a repeated eigenvalue’s space we simply choose perpendicular ones.

Optional: resizing the reference arrows versus resizing the input

Normalize the references: replace q₁ and q₂ with their unit versions u₁ and u₂. The input stays fixed, and its coefficients change.

Normalize the input: resize x itself to length one. The reference steps stay fixed, and all of x’s pieces resize together.

Two different things can be normalizedTwo panels in ordinary coordinates at the same scale, each showing the eigenvector split of the input. Left, normalizing the references: x = (3, 1) and its components (1, -1) and (2, 2) stay exactly where they were; short dark unit arrows u1 and u2 mark the new one-unit measuring steps, so the coefficients change from 1 and 2 to root 2 and 2 root 2. Right, normalizing the input: the unit references stay fixed while x shrinks to x-hat = (3, 1) divided by root 10, whose tip sits on the dashed unit circle; both components shrink with it, to 0.447 along u1 and 0.894 along u2. A faint copy of the original x remains for comparison. Which thing shrank? Same two directions in both panels; same drawing scale Normalize the references New one-unit steps u1​ and u2​. 0 u1​ u2​ (1, −1) = √2 u1​ (2, 2) = 2√2 u2​ x x and its pieces don't move. Coefficients: 1, 2 → √2, 2√2 Normalize the input Shrink x to length one. 0 u1​ u2​ 0.447 u1​ 0.894 u2​ x̂ original x length 1 Everything shrinks by √10, together. Coefficients: √2, 2√2 → 0.447, 0.894 Left: shorter measuring sticks, same arrow. Right: same sticks, shorter arrow.
Two different things can be normalizedTwo panels in ordinary coordinates at the same scale, each showing the eigenvector split of the input. Left, normalizing the references: x = (3, 1) and its components (1, -1) and (2, 2) stay exactly where they were; short dark unit arrows u1 and u2 mark the new one-unit measuring steps, so the coefficients change from 1 and 2 to root 2 and 2 root 2. Right, normalizing the input: the unit references stay fixed while x shrinks to x-hat = (3, 1) divided by root 10, whose tip sits on the dashed unit circle; both components shrink with it, to 0.447 along u1 and 0.894 along u2. A faint copy of the original x remains for comparison. Which thing shrank? Same two directions in both panels; same drawing scale Normalize the references New one-unit steps u1​ and u2​. 0 u1​ u2​ (1, −1) = √2 u1​ (2, 2) = 2√2 u2​ x x and its pieces don't move. Coefficients: 1, 2 → √2, 2√2 Normalize the input Shrink x to length one. 0 u1​ u2​ 0.447 u1​ 0.894 u2​ x̂ original x length 1 Everything shrinks by √10, together. Coefficients: √2, 2√2 → 0.447, 0.894 Left: shorter measuring sticks, same arrow. Right: same sticks, shorter arrow.
Which thing shrank? Left: normalizing the references shortens the measuring sticks; x and its pieces stay put and the coefficients grow. Right: normalizing the input, as we did with x̂ in Chapter 4, shrinks x and both of its pieces together, by the same factor, while the sticks stay fixed.

For x, normalizing the input gives x̂ = (3, 1)/√10. Its two squared-length shares are still 20% and 80%.

9. Measure the output along the input’s direction

Chapter 8 showed how to find the whole output arrow. Now we want to compare directions: which input direction gives the most output along its own line, and which gives the least? This will give us another way to understand the largest and smallest eigenvalues.

To make that comparison fair, start with inputs of length one. Otherwise, a longer input could give more output simply because it was larger to begin with.

Use the dot product to measure along the input

We already know how to measure an arrow along a chosen direction: dot it with a unit arrow in that direction. Here, the arrow we measure is the output, and the unit reference is the input itself. Any sideways part contributes zero.

Our running input is x = (3, 1), with length √10. Divide it by √10 to get the unit input x̂. Its output shrinks by the same factor:

x̂ = (3, 1)/√10
Mx̂ = (7, 5)/√10

Now dot the unit input with its output:

x̂ · Mx̂ = 3 × 7 + 1 × 510 = 2.6

The output goes 2.6 units along the input’s direction. Its projection is the arrow 2.6x̂. The full output also has a sideways part, so 2.6 is not its full length. The measurement is signed: a negative result would mean the projection points opposite to the input.

Compare the along-input output for three unit inputsThree ordinary-coordinate plots have the same coordinate scale and inputs of length one. The teal arrow is the input, orange its output, and blue the output component along the input line. The gray dashed arrow runs from that component’s tip to the output’s tip. Along u1 the amount along the input is 1 and the output equals the input. Along x-hat=(3,1)/sqrt(10), the amount along the input is 2.6, and the output has a nonzero perpendicular remainder. Along u2 the amount along the input is 3 and the output is three times the input. In both eigenvector directions, the output and its along-input component coincide. Same input length, different along-input output Ordinary coordinates; all three plots use the same scale First eigenvector 0 u1​ Mu1​ = u1​ Along input: 1 Input length 1 The running direction 0 x̂ Mx̂ 2.6x̂ Perpendicular remainder Along input: 2.6 Input length 1 Second eigenvector 0 u2​ Mu2​ = 3u2​ Along input: 3 Input length 1 Input Output Output along input Perpendicular remainder The blue arrow is the output’s component along the teal input.
Compare the along-input output for three unit inputsThree ordinary-coordinate plots have the same coordinate scale and inputs of length one. The teal arrow is the input, orange its output, and blue the output component along the input line. The gray dashed arrow runs from that component’s tip to the output’s tip. Along u1 the amount along the input is 1 and the output equals the input. Along x-hat=(3,1)/sqrt(10), the amount along the input is 2.6, and the output has a nonzero perpendicular remainder. Along u2 the amount along the input is 3 and the output is three times the input. In both eigenvector directions, the output and its along-input component coincide. Same input length, different along-input output Ordinary coordinates; same scale The running direction 0 Input x̂ Mx̂ 2.6x̂ Perpendicular remainder Along input: 2.6 Input length 1 Along the first eigenvector 0 Input u1​ Mu1​ = u1​ Along input: 1 Input length 1 No perpendicular remainder Along the second eigenvector 0 Input u2​ Mu2​ = 3u2​ Along input: 3 Input length 1 No perpendicular remainder Blue: output along the input line
Same input length, different amounts of output along it. All three inputs have length one. Along u₁ the amount is 1, along x̂ it is 2.6, along u₂ it is 3. The mixed input's output has a sideways part; the eigenvector inputs' outputs don't.

For u₁, the amount along the input is 1. For u₂, it is 3. An eigenvector’s output stays entirely on its input line, so this measurement gives exactly its eigenvalue.

Why does our direction give 2.6?

We can also calculate this from the two eigenvector pieces. Along a unit eigenvector with eigenvalue λ, an input coefficient c becomes an output coefficient λc. Their contribution to the dot product is:

c × (λc) = λc²

That is why each eigenvalue multiplies a squared coefficient. The two eigenvector lines are perpendicular, and M keeps each piece on its own line, so we can add the two contributions without any extra terms.

In Chapter 8, the original x had coefficients √2 and 2√2. We have now divided x by √10, so both coefficients are divided by √10 too. The reference arrows u₁ and u₂ stay the same:

Reference Coefficient in the unit input x̂ Squared coefficient
u₁ √2/√10 = 1/√5 1/5 = 20%
u₂ 2√2/√10 = 2/√5 4/5 = 80%

Because x̂ has length one, these squared coefficients add to one. They are its shares of squared length. Multiply each share by its eigenvalue and add:

x̂ · Mx̂ = 1 × 20% + 3 × 80% = 2.6

This is a weighted average of the eigenvalues: 20% of the weight goes to 1, and 80% goes to 3.

The amount along a unit input is a weighted average of the eigenvaluesFour unit inputs, one per row: u1, x-hat, the horizontal axis direction (1, 0), and u2. For each, a bar shows its split of squared length between u1 (blue) and u2 (orange): 100 and 0, 20 and 80, 50 and 50, 0 and 100. Beside each bar a dot marks the amount of output along the input on a scale from 1, the eigenvalue of u1, to 3, the eigenvalue of u2: the amounts are 1, 2.6, 2 and 3. Each dot sits the u2 share of the way from 1 to 3. The amount along the input is a blend of 1 and 3 The input's shares of squared length are the weights unit input share along u1​ | share along u2​ amount along input 1 (λ1​) 2 3 (λ2​) u1​ all along u1​ 100% 1 x̂ x̂ = (3, 1)/√10 20% 80% 2.6 (1, 0) the horizontal axis 50% 50% 2 u2​ all along u2​ 100% 3 Each dot sits exactly the u2​ share of the way from 1 to 3.
The amount along a unit input is a weighted average of the eigenvaluesFour unit inputs, one per row: u1, x-hat, the horizontal axis direction (1, 0), and u2. For each, a bar shows its split of squared length between u1 (blue) and u2 (orange): 100 and 0, 20 and 80, 50 and 50, 0 and 100. Beside each bar a dot marks the amount of output along the input on a scale from 1, the eigenvalue of u1, to 3, the eigenvalue of u2: the amounts are 1, 2.6, 2 and 3. Each dot sits the u2 share of the way from 1 to 3. The amount along the input is a blend of 1 and 3 The shares of squared length are the weights 1 (λ1​) 2 3 (λ2​) u1​ all along u1​ 100% 1 x̂ x̂ = (3, 1)/√10 20% 80% 2.6 (1, 0) the horizontal axis 50% 50% 2 u2​ all along u2​ 100% 3 The dot sits the u2​ share of the way from 1 to 3.
The amount along a unit input stays between 1 and 3. Each bar shows the input's shares of squared length along u₁ and u₂. The dot shows the resulting measurement. The eigenvectors reach the two ends; the horizontal input (1, 0) has a 50/50 split and gives 2. Our unit input x̂ has an 80% share along u₂, putting its result at 2.6.

More share along u₁ moves the result toward 1; more along u₂ moves it toward 3. The shares cannot be negative and add to 100%, so the result always stays between 1 and 3. The eigenvector directions give the smallest and largest amounts along the input. We can find these limits without trying every possible direction.

A name for the calculation: quadratic form

The same input-output dot product can be calculated for an input of any length:

Q(x) = x · Mx = xᵀMx

This is called a quadratic form. Q is just its label. We will call its value the raw score, because it includes the effect of input size. Double the input and the output doubles too, so their dot product becomes four times as large.

For the original x = (3, 1), the raw score is:

Q(x) = 3 × 7 + 1 × 5 = 26

For its unit version, Q(x̂) = 2.6. Only when the input has length one does the raw score directly give the signed length of the output’s projection. Chapter 11 will show how to get that same fair comparison from an input of any size.

Optional: check the calculation at both sizes

For the unit input x̂, the two contributions are 1 × 0.2 = 0.2 and 3 × 0.8 = 2.4. Together they give 2.6:

Why the unit input x-hat scores 2.6Left: ordinary coordinates with the dashed unit circle. The unit input x-hat is split into a blue piece 0.447 u1 and an orange piece 0.894 u2, drawn tip to tail. Their outputs, drawn faintly, are the blue piece unchanged (multiplier 1) and the orange piece tripled to 2.683 u2 (multiplier 3); tip to tail they reach the output M x-hat = (7, 5) divided by root 10. Right: a ledger. The u1 piece contributes input amount 0.447 times output amount 1 times 0.447, which is 0.2. The u2 piece contributes 0.894 times 3 times 0.894, which is 2.4. The total score is 2.6, the same as 1 times the 20 percent share plus 3 times the 80 percent share. Why does x̂ score 2.6? Each eigenvector piece is scored on its own line; then the pieces add Where each piece goes Ordinary coordinates; dashed circle = length 1 0 0.447 u1​ (× 1: stays put) 0.894 u2​ × 3: 2.683 u2​ x̂ Mx̂ Faint arrow: where M sends the orange piece. Score, piece by piece input amount × output amount piece input amount × output amount = u1​ 0.447 1 × 0.447 0.2 u2​ 0.894 3 × 0.894 2.4 Q(x̂) = 0.2 + 2.4 = 2.6 The same sum, read as shares: Q(x̂) = 1 × 0.2 + 3 × 0.8 eigenvalue × share of squared length 0.4472​ ≈ 0.2 and 0.8942​ ≈ 0.8: the shares are the squared coefficients. Score each piece on its own line, then add: 0.2 + 2.4 = 2.6.
Why the unit input x-hat scores 2.6Left: ordinary coordinates with the dashed unit circle. The unit input x-hat is split into a blue piece 0.447 u1 and an orange piece 0.894 u2, drawn tip to tail. Their outputs, drawn faintly, are the blue piece unchanged (multiplier 1) and the orange piece tripled to 2.683 u2 (multiplier 3); tip to tail they reach the output M x-hat = (7, 5) divided by root 10. Right: a ledger. The u1 piece contributes input amount 0.447 times output amount 1 times 0.447, which is 0.2. The u2 piece contributes 0.894 times 3 times 0.894, which is 2.4. The total score is 2.6, the same as 1 times the 20 percent share plus 3 times the 80 percent share. Why does x̂ score 2.6? Each eigenvector piece is scored on its own line; then the pieces add Where each piece goes Ordinary coordinates; dashed circle = length 1 0 0.447 u1​ (× 1: stays put) 0.894 u2​ × 3: 2.683 u2​ x̂ Mx̂ Faint arrow: where M sends the orange piece. Score, piece by piece input amount × output amount piece input amount × output amount = u1​ 0.447 1 × 0.447 0.2 u2​ 0.894 3 × 0.894 2.4 Q(x̂) = 0.2 + 2.4 = 2.6 The same sum, read as shares: Q(x̂) = 1 × 0.2 + 3 × 0.8 eigenvalue × share of squared length 0.4472​ ≈ 0.2 and 0.8942​ ≈ 0.8: the shares are the squared coefficients. Score each piece on its own line, then add: 0.2 + 2.4 = 2.6.
Two pieces, two multipliers, one score. The u₁ piece of x̂ has squared length 0.2 and multiplier 1; the u₂ piece has squared length 0.8 and multiplier 3. Their input-times-output products, 0.2 and 2.4, add to 2.6. The coefficient labels are rounded to three decimal places.

For the original x, the squared coefficients are 2 and 8, adding to 10. Its raw score is 1 × 2 + 3 × 8 = 26:

The matrix scales the two eigenvector coordinates separatelyThe orthonormal eigenvectors u1 and u2 form perpendicular coordinate axes. The input x has coordinates square root two and twice square root two. Applying M preserves the first coordinate and triples the second. Their squared lengths are 2 and 8. Multiplying by the eigenvalues 1 and 3 gives quadratic-form contributions 2 and 24. The squared norm is 10 and the quadratic form is 26. Each eigenvector component has its own score These axes follow the unit eigenvectors u1​ and u2​. u1​ u2​ 0 2 4 6 8 2 4 6 Mx x c1​ stays fixed; c2​ triples. Direction Squared length ci​2​ Score λi​ci​2​ u1​ 2 2 u2​ 8 24 Total 10 26 ||x||2​ = 10; xT​Mx = 26 Same input, two measurements.
Size and score use the same pieces differently. Squared length counts each squared coefficient once. The score gives the u₂ piece a multiplier of 3.

The output arrow, the raw score, and the output’s squared length are three different things:

Calculation Answer What it measures
Mx (7, 5) The output arrow.
Q(x) = x · Mx 26 The dot product of input and output.
‖Mx‖² 74 The output’s squared length.

Written in ordinary coordinates, the quadratic form is Q(x) = 2x₁² + 2x₁x₂ + 2x₂². Each term multiplies two input entries, which explains the word “quadratic.”

We have seen that our matrix gives a positive result for every unit input. Could another matrix give zero, even when the input is not zero?

10. When a matrix sends an arrow to zero

For our matrix M, every unit input gives a measurement between 1 and 3. It can never give zero. A different matrix can give zero by removing an entire direction.

Keep the horizontal part, remove the vertical part

Let N keep the horizontal coordinate of an arrow and remove its vertical coordinate. This is projection onto the horizontal line:

N(a, b) = (a, 0)

Compare two inputs, both of length one:

Input Output after N Input · output
Horizontal: (1, 0) (1, 0) 1
Vertical: (0, 1) (0, 0) 0

N leaves the horizontal input unchanged. It sends the vertical input v = (0, 1) to zero, even though v has length one. The zero result tells us that N removes vertical movement. That direction has eigenvalue zero.

A nonzero input can have zero output and zero scoreThis is a separate hypothetical transformation N, not the running matrix M. N sends (a,b) to (a,0). The nonzero vertical vector v=(0,1) is sent to the zero vector at the origin. Thus v is an eigenvector with eigenvalue zero and its quadratic score is zero. N removes every vertical input completely. A zero eigenvalue collapses a nonzero direction Separate example: N sends (a, b) to (a, 0). v = (0, 1) Nonzero input Apply N Nv = 0 Zero output The input still has length 1. Its score is v · Nv = 0.
A length-one input gives zero. The vertical input v has length one, and its output Nv is the zero arrow. N removes all movement in this direction, so its eigenvalue is zero.

The measurement depends only on the horizontal part

For any input (a, b), the output is (a, 0). Their dot product is:

(a, b) · (a, 0)
= a × a + b × 0 = a²

The raw score depends only on the horizontal coordinate a. Changing the vertical coordinate b makes no difference.

An entirely vertical arrow has a = 0, so it gives zero. Any arrow with a horizontal part gives a positive result. The result can never be negative, because it is a square.

Comic: N's blind spotN, a character whose head is the matrix with rows 1 0 and 0 0, sits behind a desk handing out scores. Panel 1: B, in a beanie, points at a vertical arrow labeled v = (0, 1). N says: Score: zero. B says: Zero? I'm a whole arrow! Panel 2: The vertical arrow is now twice as tall, labeled (0, 2). B asks: Okay, how about now? N says: Still zero. Vertical is not my department. Panel 3: Away from the desk, B asks A: So am I... nothing? A says: Nope. A zero from N means "nothing N counts," not "nothing there." 1 0 0 0 N v = (0, 1) Score: zero. Zero? I'm a whole arrow! 1 0 0 0 N (0, 2) Okay. How about now? Still zero. Vertical is not my department. So am I... nothing? Nope. A zero from N means "nothing N counts," not "nothing there."
Comic: N's blind spotN, a character whose head is the matrix with rows 1 0 and 0 0, sits behind a desk handing out scores. Panel 1: B, in a beanie, points at a vertical arrow labeled v = (0, 1). N says: Score: zero. B says: Zero? I'm a whole arrow! Panel 2: The vertical arrow is now twice as tall, labeled (0, 2). B asks: Okay, how about now? N says: Still zero. Vertical is not my department. Panel 3: Away from the desk, B asks A: So am I... nothing? A says: Nope. A zero from N means "nothing N counts," not "nothing there." 1 0 0 0 N v = (0, 1) Score: zero. Zero? I'm a whole arrow! 1 0 0 0 N (0, 2) Okay. How about now? Still zero. Vertical is not my department. So am I... nothing? Nope. A zero from N means "nothing N counts," not "nothing there."
N removes the vertical input (0, 1), giving zero output. With M, the same input has a positive score of 2.

Positive and nonnegative results

For real symmetric matrices, these properties have standard names:

Name Input · output
Positive definite Every nonzero input gives a positive result.
Positive semidefinite Every input gives a result that is zero or positive.

M is positive definite. N is positive semidefinite: its results are never negative, and vertical inputs give zero. Every positive definite matrix also counts as positive semidefinite, since a positive result is never negative.

The eigenvalues give a quick test. All positive means positive definite; all zero or positive means positive semidefinite. M has eigenvalues 1 and 3. N has eigenvalue 1 along the horizontal line and 0 along the vertical line.

Find the directions the matrix sends to zero

If we look for N’s smallest measurement among unit inputs, a vertical input gives zero. We have found a direction N removes.

To study what N keeps, remove the vertical component first. Then compare the remaining nonzero horizontal arrows at length one. They all give 1, because N leaves them unchanged.

Optional: does a zero score always mean zero output?

For a positive semidefinite matrix, yes. Each eigenvector piece contributes its eigenvalue times its squared coefficient. All contributions are zero or positive, so a total of zero means every contribution is zero. Every nonzero piece must lie along an eigenvector with eigenvalue zero, and the matrix sends all those pieces to zero.

For a symmetric matrix with both positive and negative eigenvalues, contributions can cancel, giving a zero score even when the output is nonzero. In that case, the output is perpendicular to the input, so their dot product is zero.

11. Compare directions regardless of length

In Chapter 9, we resized each input to length one before comparing directions. We can get the same measurement directly from the original input, using one division.

One direction, two lengths

Our input x = (3, 1) has raw score 26. Half of x is x/2 = (1.5, 0.5), with raw score 6.5. The shorter arrow points in exactly the same direction, but its raw score is smaller.

Now divide each raw score by the input’s squared length:

Input Raw score Squared length After dividing
x 26 10 2.6
x/2 6.5 2.5 2.6

Both give 2.6. Dividing by squared length removes the effect of input size, so the two arrows get the same result.

Halving a vector preserves its direction and the ratioThe vectors x=(3,1) and x/2=(1.5,0.5) share an origin in the x1/x2 coordinate plane, with equal scale on both axes. The shorter arrow lies halfway along the longer arrow. Using M with rows (2,1) and (1,2), their squared norms are 10 and 2.5, and their raw scores are 26 and 6.5. Both quantities fall by a factor of four, while the quotient remains 2.6. A smaller score can come from a shorter input x1​ x2​ 0 1.5 0.5 3 1 x / 2 x One direction, two lengths x x / 2 Squared length 10 2.5 Raw score 26 6.5 Their ratio 2.6 2.6 Both fall to ¼; the ratio stays 2.6 Same direction. Half the length. The ratio stays 2.6.
Resizing can't change the ratio. Both arrows point in the running example's direction. Their raw scores differ only because their sizes differ, and dividing by squared length removes exactly that.

Why divide by squared length?

Normalizing an input divides it by its length. Its output is divided by the same amount. The dot product multiplies entries from both arrows, so the result is divided by length twice—once for the input and once for the output. Together, those two factors give ‖x‖ × ‖x‖ = ‖x‖².

We can therefore calculate the measurement for a unit input without actually resizing the arrow:

R(x) = Q(x)‖x‖²

Dividing the raw score by the input’s squared length gives the Rayleigh quotient. For our example, R(x) = 26/10 = 2.6.

R(x) is the measurement that the same direction would have at length one. This is the same result we found in Chapter 9 for x̂. The input must be nonzero, because we cannot divide by a squared length of zero.

Turn the input and compare the results

Call the unit input in the next picture v. Since its squared length is 1, R(v) = Q(v). It starts at v = x̂, our running direction.

Click “Along u₁”, then “Along u₂.” The quotient changes from 1 to 3. Now choose “Along x̂”: it gives 2.6. Use the slider to explore other directions.

Turn a unit input and watch R(v) changeOrdinary coordinates show a teal unit input v, its orange output Mv, the blue output component R(v)v along the input, and a dashed perpendicular remainder. The dashed circle is the set of all unit inputs. Initially v=(3,1)/sqrt(10), so its Rayleigh quotient is 2.6. A closer view of the same unit input shows its two perpendicular eigenvector components. Their signed coefficients are about 0.447 and 0.894, and their shares of squared length are 20 percent and 80 percent. Turning the input changes its quotient between 1 and 3. A chart at the bottom plots the quotient of every direction from -180 to 180 degrees, a wave between 1 and 3 that touches 3 at 45 and -135 degrees (the u2 line) and 1 at -45 and 135 degrees (the u1 line); a dot on the curve marks the current input. Turn the input. Keep its length at 1. Ordinary coordinates in both pictures Input Output Output along input Perpendicular remainder Apply M and project its output Split the same input into pieces Closer view of the input -1 1 v Mv R(v)v Dashed circle: all unit inputs c1​u1​ c2​u2​ v Signed amount Squared-length share c1​ = 0.447 20% c2​ = 0.894 80% 1 (λ1​) 2 3 (λ2​) R(v) = 2.6 R(v) for every direction The dot is the current input; the small dots at ±45° and ±135° are the eigenvector directions λ1​ = 1 λ2​ = 3 −180° −90° 0° 90° 180° 0 1 2 3
Turn a unit input and watch R(v) changeOrdinary coordinates show a teal unit input v, its orange output Mv, the blue output component R(v)v along the input, and a dashed perpendicular remainder. The dashed circle is the set of all unit inputs. Initially v=(3,1)/sqrt(10), so its Rayleigh quotient is 2.6. A closer view of the same unit input shows its two perpendicular eigenvector components. Their signed coefficients are about 0.447 and 0.894, and their shares of squared length are 20 percent and 80 percent. Turning the input changes its quotient between 1 and 3. A chart at the bottom plots the quotient of every direction from -180 to 180 degrees, a wave between 1 and 3 that touches 3 at 45 and -135 degrees (the u2 line) and 1 at -45 and 135 degrees (the u1 line); a dot on the curve marks the current input. Turn the input. Keep its length at 1. Ordinary coordinates in both pictures Input Output Output along input Perpendicular remainder -1 1 v Mv R(v)v Dashed circle: all unit inputs The same input, split into pieces Closer view; ordinary coordinates c1​u1​ c2​u2​ v Signed amount Squared-length share c1​ = 0.447 20% c2​ = 0.894 80% 1 (λ1​) 2 3 (λ2​) R(v) = 2.6 R(v) for every direction The dot is the current input λ1​ = 1 λ2​ = 3 −180° −90° 0° 90° 180° 0 1 2 3
18.4°

Rayleigh quotient R(v): 2.6

20% of squared length along u₁; 80% along u₂.

Use the buttons to compare u₁, u₂, and x̂. Move the slider to try other directions; the angle is measured from the positive horizontal axis.

Every direction gets the same input length. The first view shows input v, output Mv, and the blue projection R(v)v. The second splits v into its eigenvector pieces. The bottom chart plots R(v) for every direction; the dot marks the current input.

The blue arrow, R(v)v, is the output’s projection onto the input line. For any nonzero input x, the same rule gives the projection R(x)x. The full output can also have a sideways part, so R(x) is generally different from the ratio of the full output length to the input length. At an eigenvector, the sideways part disappears.

What changes when you turn?

Chapter 9 showed that the measurement is a weighted average of the eigenvalues. Our original x and its unit version x̂ both have 20% of their squared length along u₁ and 80% along u₂:

R(x) = 0.2 × 1 + 0.8 × 3 = 2.6

Resizing an arrow scales both pieces together, keeping those shares unchanged. Turning it can change the shares. Resizing leaves the quotient unchanged; turning can change it.

The experiment suggests where the smallest and largest quotients occur. Next, we will use the weighted-average rule to prove that the eigenvector directions reach both limits.

12. Use eigenvalues to find the minimum and maximum

Chapter 11 gave us a number for each direction. Now we want to find the smallest and largest possible values. For an input of length one, these tell us the least and most output along the input’s own direction.

Our running direction gives 2.6. That is one possible value; it does not tell us where the limits are.

Why every quotient stays between 1 and 3

For our symmetric matrix M, the quotient is a weighted average of the eigenvalues 1 and 3. The weight on each eigenvalue is the share of the input’s squared length along its eigenvector. These shares cannot be negative and add to 100%.

Putting all the weight on 1 gives an average of 1. Moving any of that weight to 3 raises the average. Even when all the weight is on 3, the result is only 3. So every nonzero input has a quotient between 1 and 3, including the two ends.

The eigenvectors reach both limits

We can put all the weight on 1 by choosing u₁ as the input. It has no u₂ piece. Likewise, choosing u₂ puts all the weight on 3.

Compare these two unit inputs with our running unit input x̂. The shares below are percentages of squared length:

Unit input u₁ share u₂ share Quotient
u₁ 100% 0% 1
x̂ 20% 80% 2.6
u₂ 0% 100% 3

This proves both limits: no direction gives less than 1, and u₁ gives exactly 1; no direction gives more than 3, and u₂ gives exactly 3. Finding a minimum takes both parts: show that nothing can go lower, then find an input that reaches that value.

Chart: the Rayleigh quotient of every directionThe Rayleigh quotient of M for every input direction from 0 to 180 degrees, measured from the positive horizontal axis. The maximum is 3 at 45 degrees, along the unit eigenvector u2. The minimum is 1 at 135 degrees, along minus u1, the reverse of the unit eigenvector u1. The original input x = (3, 1) and its unit version x-hat have the same direction, about 18.4 degrees, and the same quotient, 2.6. Every direction stays between 1 and 3. Every direction's Rayleigh quotient maximum: λ2​ = 3 minimum: λ1​ = 1 1 1.5 2 2.5 3 3.5 0° 45° 90° 135° 180° input angle from the horizontal Rayleigh quotient R u2​ gives the maximum −u1​ gives the minimum x and x̂ R = 2.6
The eigenvector directions reach both limits. The u₁ line gives 1 and the u₂ line gives 3. Every other direction gives a value between them.

Resizing or reversing an arrow leaves its quotient unchanged. Every nonzero arrow on the u₁ line therefore gives the minimum, and every nonzero arrow on the u₂ line gives the maximum. In the chart, 135° points along −u₁, which is on the same line as u₁.

The same rule works in more dimensions

For any real symmetric matrix, every nonzero input’s quotient is a weighted average of its eigenvalues. The same argument works however many entries the input has:

  • The smallest eigenvalue is the minimum quotient. An eigenvector with that eigenvalue reaches it.
  • The largest eigenvalue is the maximum quotient. An eigenvector with that eigenvalue reaches it.

This gives us a way to find the minimum without checking every direction: find the smallest eigenvalue and an eigenvector that goes with it. The eigenvalue tells us the minimum value; the eigenvector tells us an input direction that achieves it. Spielman, Chapter 2.

What we learned

We started with arrows and a matrix that transforms them. By finding useful reference directions, we learned to break that transformation into simpler pieces. For a real symmetric matrix, we can choose perpendicular eigenvectors: each piece stays on its own line, and its eigenvalue tells us how the matrix scales it.

That same picture helped us compare input directions. After removing the effect of input length, the measurement becomes a weighted average of the eigenvalues. Its smallest and largest values are therefore the smallest and largest eigenvalues, and their eigenvectors tell us which directions reach those limits.

These ideas extend beyond arrows on a plane. In the spectral graph theory primer, a vector will assign values to nodes, and a matrix will describe their connections. The same tools will help us find bottlenecks and understand how well a network holds together.

Further reading

  1. 3Blue1Brown, Eigenvectors and eigenvalues. The moving-grid picture, done properly, with animation budgets.
  2. Gilbert Strang, MIT 18.06, Lecture 25: Symmetric matrices and positive definiteness. For the spectral theorem and orthogonal eigenvectors.
  3. Daniel Spielman, Spectral and Algebraic Graph Theory, Chapter 2. For the variational characterization of eigenvalues and the Courant–Fischer theorem.

Footnotes

  1. Unlike most directions you get from relatives, these work no matter where you start. ↩
  2. William Rowan Hamilton gave “scalar” and “vector” their mathematical meanings in the mid-1840s, while developing his quaternions. Real numbers, he explained, sit on a single scale running from negative to positive infinity. “Vector” comes from the Latin for “carrier.” ↩
  3. This is why the rule “add 1 to every entry” isn't linear in this sense, even though in one dimension f(x) = x + 1 draws a perfectly straight line. It moves the origin. That kind of rule is called affine, and someone will point this out if you get it wrong. ↩
  4. For two nonzero arrows in the plane, “orthogonal” and “perpendicular” mean the same thing. “Orthogonal” also works in more dimensions, and for things like functions, where “perpendicular” starts to sound odd. Technically the zero vector is orthogonal to everything, which is about as meaningful as it sounds. ↩
  5. √10 ≈ 3.162 is close enough to π that Zhang Heng in 2nd-century China and Brahmagupta in 7th-century India both used it as a value for π. We are not doing that here. ↩
  6. The zero vector can't be normalized: its length is zero, and dividing by zero remains, as ever, not allowed. ↩
  7. Without the right angle there would be an extra cross term: ‖p + r‖² = ‖p‖² + 2 p · r + ‖r‖². Here p · r = 0, so it vanishes. ↩
  8. The wobble in the hand-drawn grid is drawn on the plane itself, so M transforms the wobbles along with everything else. That's what a linear map does to any drawing you make on the plane. (The arrow tips sit exactly where the math says, though.) ↩
  9. “Eigen” is German for “own,” as in “the matrix's own vectors.” English borrowed half the word and never gave it back. ↩
  10. Flipping still counts as staying on the line. The arrow is on the same line through the origin, just facing the other way down the hallway. ↩
  11. Keep applying M and almost every arrow swings closer and closer to the q₂ line, because each application triples the q₂ component and leaves the q₁ component alone. Repeating a matrix to find its dominant eigenvector is called the power method; Google's original PageRank was computed this way. (The “almost”: arrows exactly on the q₁ line have no q₂ component to triple, so they stay put.) ↩
  12. David Hilbert made “spectrum” the standard word in the early 1900s (Wilhelm Wirtinger had borrowed it from optics a few years before). A couple of decades later, quantum mechanics showed that the lines in atomic spectra really are computed from eigenvalues. Hilbert reportedly said he'd used the name with no idea it would apply to the actual spectra of physics. The word went from optics to math and straight back again. ↩
  13. Of which there are a lot. Uncountably many, in fact. ↩
  14. Rotation by 180° is sneakier: it flips every arrow, which counts as staying on the line, so every nonzero arrow is an eigenvector with eigenvalue −1. ↩
  15. Remember the job interview in Chapter 6? x started explaining that it turns a little, and M said “Next!” The chart there says how little: about 17°. That turn is the sideways part in the picture. ↩
  16. One input, three different answers. Linear algebra is like this sometimes. ↩
  17. Positive semidefinite is the matrix version of “no complaints.” Not necessarily any compliments. Just no complaints. ↩
  18. An almost-vertical unit input can have a score as close to zero as we like. Removing the vertical component restricts the comparison to the perpendicular, horizontal direction. ↩
  19. Without nonnegativity, a zero can be a coincidence. The matrix with rows (1, 0) and (0, −1) gives (1, 1) a score of 1 − 1 = 0, yet sends it to (1, −1), not to zero. ↩
  20. Named after Lord Rayleigh, who also explained why the sky is blue and shared in the discovery of argon, which won him the 1904 Nobel Prize in Physics. He was having a good few decades. ↩
  21. For our x, ‖Mx‖/‖x‖ = √74/√10 ≈ 2.72, which is bigger than R(x) = 2.6. The sideways remainder adds length without adding anything along x. ↩
  22. Mathematicians call this the variational characterization of eigenvalues: “variational” because it comes from varying the direction and looking for the lowest and highest values. Physics is full of these. A soap film settles into a shape that (locally) minimizes its area, and light follows a path whose travel time is stationary, which is usually a minimum. ↩

Illustrations inspired by xkcd; fonts: Humor Sans by Michael Ciuffo and Playpen Sans by TypeTogether, licensed under the SIL Open Font License 1.1.

Written on October 20, 2026