The Maths You Actually NeedLesson 5 of 76

Module 1 · Vectors, and the space they live in

Cosine or distance, and why it often does not matter

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 5 of 9 in this chapter

This chapter’s goalTurn a real piece of data into a vector and defend the choices made, compute a length, a distance, a projection and a cosine by hand, and explain using the 1/√d rule why a similarity threshold that works in a 3-dimensional picture is meaningless in a 768-dimensional embedding space.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The identity that settles the argument

Teams argue about whether to use cosine similarity or Euclidean distance in a vector search. Most of the argument disappears once you write down one line of algebra.

For any two vectors a and b:

Text
||a - b||^2  =  ||a||^2 + ||b||^2 - 2 (a . b)

Expand the squared distance term by term and you get exactly this; it is the law of cosines wearing different clothes.

Now suppose both vectors have been normalised to length 1. Then ||a||^2 = 1 and ||b||^2 = 1, and the dot product of two unit vectors is the cosine of the angle between them. So:

Text
||a - b||^2 = 2 - 2 cos(theta)

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Cosine or distance, and why it often does not matter’, in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/cosine-versus-euclidean (Accessed: 29 November 2026).