Vector Mathematics

Dot Product & Cosine Similarity

Explore how two vectors relate through their dot product and the angle between them. Switch between scenarios or drag the custom controls to build intuition.

Vector space
Vectors
A = [00] |A| = 0
B = [00] |B| = 0
Dot product  A · B
AxBx + AyBy 0
...
Cosine similarity  cos(θ)
A·B / (|A| |B|) 0
Angle θ between vectors
Formula reference
Dot product
A · B = AxBx + AyBy
= |A||B|cos(θ)
Sensitive to magnitude. Large vectors → large dot product.
Cosine similarity
cos(θ) = A · B
          |A| · |B|
∈ [−1, +1]
Magnitude-independent. Only the angle matters.
Interpretation
cos = +1 → parallel
cos =  0 → orthogonal
cos = −1 → opposite
Used in NLP, recommendation systems, image retrieval.