← All interactives
Eulerly · Lesson 3.3 · Try it yourself

Cosine similarity dial

Drag the tips of a and b. The dial reads cos θ = a · b / (‖a‖ ‖b‖): +1 same direction, 0 unrelated (a right angle), −1 opposite. It compares directions only, so stretching an arrow never moves the needle.

Arrow keys move: Grid:

Stretch an arrow, watch the needle stay put

a =   b =
a · b (dot product)
‖a‖
‖b‖
cos θ = a · b / (‖a‖ ‖b‖)
angle θ
Similarity dial −1 +1 0 · unrelated opposite alike
Unit vectors: â · b̂

Lesson examples

Pick an example, then drag.

What to try