First PrinciplesStart anywhere. Prove it, then move on.

Rung 28

Vectors

A list of numbers that also has a direction and a length.

Best attempted after 6. The coordinate plane. Nothing stops you trying this now — the gate will tell you if you were right.

The gate

Implement the dot product and magnitude from scratch, with no library. Use them to compute the angle between two vectors you chose, and check the answer against a drawing. Then construct a pair whose dot product is zero and say what that means geometrically without using the word "zero".

Nobody checks this but you. Do it honestly and the rungs above hold; do it loosely and they will not, somewhere further up where the cause is much harder to find.

A vector is three things at once, and which one you mean depends on what you are doing. A list of numbers. An arrow with a direction and a length. A point in space. They are the same object, and moving fluently between the three readings is most of what this rung is for.

Why this is on the ladder

Because everything a model ever handles is a vector. A sentence becomes a list of numbers. An image becomes a list of numbers. A model's entire set of parameters is one enormous vector, and training is a walk through that space.

The dot product in particular is the single most-used operation above this rung. It measures how much two vectors point the same way, and at rung 46 an entire attention mechanism is built out of nothing else.

Do this

Write magnitude(v) and dot(u, v) yourself, from the definitions, for vectors of any length. No NumPy — you are buying the intuition, and importing it defeats the purchase.

Then use them: the angle between two vectors satisfies cos θ = dot(u, v) / (|u| · |v|). Pick two vectors in the plane, compute the angle, draw them on paper, and measure with a protractor. Agreement is the check.

Now find a pair whose dot product is zero. Draw them. Find another pair. Draw those. State the geometric fact you have just discovered, in words, without saying "the dot product is zero" — the words should describe the picture.

Finally, take two vectors pointing in nearly the same direction and normalise both to length 1. Notice their dot product is close to 1. That number — cosine similarity — is how a machine decides two things are alike.

Where people get stuck

Treating the arrow picture as the real thing and the list as notation. In two or three dimensions the arrow helps. At rung 44 your vectors have hundreds of components and there is no picture at all — only the operations, which keep working. Trust the algebra early so you are not stranded later.

The other snag is forgetting to normalise. A dot product grows with the lengths of both vectors, so a large dot product can mean "similar" or merely "big". Dividing by the magnitudes is what separates those.

Reading