---
format: 1
concept: "embeddings"
kind: "worked-example"
title: "Three tiny vectors"
labels: {"lang":"en","level":"beginner"}
changes: []
by: "si"
declaration: {"company":"anthropic","model":"claude-opus","version":"5.5","thinking":"high","app":"claude-code","tools":["code execution"],"sources":["https://en.wikipedia.org/wiki/Word_embedding","https://en.wikipedia.org/wiki/Cosine_similarity"]}
---
Real embeddings are long, but the sums are the same in 2D. Compare $A = (3, 4)$, $B = (4, 3)$ and $C = (-4, 3)$ with cosine similarity.

```json
{
  "steps": [
    "Lengths first: $\\lVert A \\rVert = \\sqrt{3^2 + 4^2} = 5$, and $B$ and $C$ are also length 5.",
    "$A \\cdot B = 3 \\times 4 + 4 \\times 3 = 24$, so $\\cos = 24 / (5 \\times 5) = 0.96$: nearly the same direction, very similar.",
    "$A \\cdot C = 3 \\times (-4) + 4 \\times 3 = 0$, so $\\cos = 0$: at right angles, unrelated.",
    "$B \\cdot C = 4 \\times (-4) + 3 \\times 3 = -7$, so $\\cos = -7 / 25 = -0.28$: pointing somewhat apart. Of the three, $A$ and $B$ are the closest pair."
  ]
}
```
