ContentsThe library

Vectors, Distance and Similarity

Multiply, Add, and Get an Angle

Last timeHow Far Apart

Multiply two vectors coordinate by coordinate and add the results. That one number turns out to encode the angle between them, which is why it appears in almost every similarity calculation.

There is one way to turn two vectors into a single number that matters more than

all the others. It is also the cheapest thing you could reasonably do with them.

FIG 1The dot product, computed
the ith coordinate of the first vector
the ith coordinate of the second, in the same position
One multiplication and one addition per coordinate, and nothing depends on anything but matching positions. This is the operation that specialised hardware is designed around, which is why comparing a query against a million stored vectors is routine rather than ambitious.

The same number, said differently

Now the part that is not obvious from the arithmetic at all.

FIG 2The dot product, in geometry
the length of the first vector
the length of the second
the angle between them, measured in the plane the two of them span
Two vectors, however many coordinates they have, always lie in a plane together, so there is always an angle between them even when there is no picture. This equation is the reason a sum of products can be used to answer a question about direction.

Everything else in this course comes out of reading that equation in one

direction or the other. Computing the left side is cheap; the right side is what

you actually wanted to know.

The lesson stops here

3 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01The Same List, Read Two Ways
  2. 02Straight Lines and City Blocksopening only
  3. 03Multiply, Add, and Get an Angleyou are here
  4. 04Dividing the Lengths Outopening only
  5. 05When Distance and Angle Become the Same Questionopening only
  6. 06Everything Is Far Away and Nothing Is Nearbyopening only
  7. 07The Cost of Asking What Is Nearbyopening only
  8. 08Which Question Are You Actually Askingopening only

Read alongside