Part I · Ch. 1 — Numbers That Point

Part I · Chapter 1 of 21

Numbers That Point

Vectors: arrows, coordinates, and why direction is information


An arrow and a list

“Go 3 blocks east and 2 blocks north.” We have given a friend one trip using two numbers. Together they describe an arrow: a direction and a distance. A vector lets us move between those two views. Later these arrows will carry information about words.

What a vector is

Consider the 2D plane, written $\mathbb{R}^2$. The origin is where both axes read zero.

The trip [3, 2] starts at [0, 0].
PartMovement
Across3 blocks east
Up2 blocks north
Endpoint[3, 2]

Our notation stays consistent: bold lowercase $\mathbf{v}$ means “the vector v.” Its components are $v_1=3$ and $v_2=2$, read “v-one” and “v-two.” The little numbers below the letter are subscripts.

$$\mathbf{v} = \begin{bmatrix} 3 \\ 2 \end{bmatrix}$$

In words: the vector v is the pair of numbers 3 and 2. The first is how far to go across, the second is how far to go up.

Worked example

Turn the list back into the arrow by hand. Start at the origin. Walk 3 steps to the right, which puts you above the "3" on the across-axis. From there, walk 2 steps straight up. Draw an arrow from where you started to where you are standing. That arrow is $\mathbf{v}$. Given the list you just drew the arrow, and given the arrow you could read the list straight back off the grid.

Both direction and length are encoded. We can estimate the length by eye; the next chapter shows how to calculate it.

Adding arrows

The diagram labels $\mathbf{v}=[3,2]$ and $\mathbf{u}=[1,3]$. Follow the first trip, then start the second from its tip. The combined trip ends at [4,5].

Four arrows show v=[3,2], u=[1,3] at the origin, u moved to the tip of v, and the sum [4,5]. The moved u has the same length and direction.
Tip-to-tail addition reaches [4, 5].
$$\mathbf{v} + \mathbf{u} = \begin{bmatrix} 3 \\ 2 \end{bmatrix} + \begin{bmatrix} 1 \\ 3 \end{bmatrix} = \begin{bmatrix} 3 + 1 \\ 2 + 3 \end{bmatrix} = \begin{bmatrix} 4 \\ 5 \end{bmatrix}$$

In words: add the two first-components to get the new first component (3 plus 1 is 4), and add the two second-components to get the new second component (2 plus 3 is 5). Nothing mixes across the slots.

Worked example

Follow the labeled arrows in the figure. The mint arrow moves 3 right and 2 up; the amber arrow, starting from the mint tip, moves 1 more right and 3 more up. Total: $3 + 1 = 4$ squares right and $2 + 3 = 5$ squares up, landing where the violet arrow points. The picture and the arithmetic agree.

This is vector addition. Reversing the trip order reaches the same corner: the two routes form a parallelogram.

The two views agree
OperationNumbersPicture
Read components[3,2]3 across, 2 up.
Add[3+1,2+3]=[4,5]Walk one trip after the other.
Scale2[3,2]=[6,4]Double both parts of the trip.

Stretching and flipping

Scaling changes every component by the same factor. That factor is a scalar, written in ordinary italic type rather than bold.

A positive scale keeps direction; a negative scale reverses it.
ScaleEndpointEffect
1[3, 2]Original trip
2[6, 4]Twice as long
0.5[1.5, 1]Half as long
−1[−3, −2]Same length, opposite direction
$$2\mathbf{v} = \begin{bmatrix} 2 \times 3 \\ 2 \times 2 \end{bmatrix} = \begin{bmatrix} 6 \\ 4 \end{bmatrix}$$

In words: to double a vector, double each of its numbers. 3 becomes 6 and 2 becomes 4. Halving works the same way: $0.5\,\mathbf{v} = [1.5, 1]$.

What each scalar does to [3,2]
ScalarResultEffect
2[6,4]Twice the length, same direction.
0.5[1.5,1]Half the length, same direction.
−1[−3,−2]Same length, opposite direction.
0[0,0]Zero length; no direction.

Positive scaling preserves direction. That separation will let us compare directions even when arrows have different lengths.

See it move

Watch the component lines become a list. Then use the playground to connect each number to a movement of the tip.

Watch (1:08): what to notice. Each dashed line is one number in the list. When the arrow is scaled, its tip glides along the same direction line and the direction itself stays put.

From two numbers to thousands

A third component adds height: [3,2,5] describes an arrow in a room. A dimension is one coordinate slot. We write $d$ for the number of dimensions.

Three panels. Left: small 2D axes with an arrow and the list [3, 2], labeled '2 numbers — a page'. Middle: small 3D isometric axes with an arrow and the list [3, 2, 5], labeled '3 numbers — a room'. Right: a row of small cells reading 0.2, minus 1.4, 3.1, 0.8, an ellipsis, 0.5, with a brace labeled 'd numbers' and the note 'no picture — and none needed'.
Each dimension adds another coordinate.

With thousands of components, we lose the picture but keep the arithmetic. Add matching slots; multiply every slot by the scalar. Our two-dimensional drawings teach operations that work on longer lists too.

Why the LLM cares

A token becomes an embedding: a vector with many components. Its direction can encode relationships such as the similarity of “cat” and “dog.” We'll build that idea carefully in Chapter 8.

The additions and scalings we just checked will combine information inside a language model. The lists grow; the operations stay familiar.

What you now know

  • A vector is both a list and an arrow.
  • Components say how far to move in each coordinate direction.
  • Add vectors by adding matching components.
  • A positive scalar changes length; a negative one also reverses direction.
  • More dimensions mean more entries, with the same arithmetic.

Where we're headed

We can draw, add, and stretch arrows. Next we'll measure how much two arrows agree with one number: the dot product.