Cosine Similarity Calculator

Quick answer

The cosine similarity calculator measures how similar the directions of two vectors are (−1 to 1), with the angle between them and the cosine distance, for vectors of 2 to 10 dimensions.

Cosine similarity S_C
0.438529
Angle θ between the vectors
63.9899
Cosine distance D_C
0.561471
Dot product a · b
5

Cosine similarity ignores length and compares direction. It is the standard way to compare documents (word-count vectors), user preferences in recommendation systems and embeddings in machine learning.

How to use the Cosine Similarity Calculator

  1. Vector length (dimension)
  2. a₁
  3. b₁
  4. a₂
  5. b₂
  6. a₃
  7. b₃
  8. a₄
  9. b₄
  10. a₅
  11. b₅
  12. a₆
  13. b₆
  14. a₇
  15. b₇
  16. a₈
  17. b₈
  18. a₉
  19. b₉
  20. a₁₀
  21. b₁₀

Results update as you type, and everything is calculated in your browser.

How it works

The dot product is divided by the product of the vector lengths. 1 means the same direction, 0 means perpendicular (unrelated) and −1 means opposite.

Inputs explained

Field What to enter
Vector length (dimension) Choose one: 2, 3, 4, 5 …
a₁ A number
b₁ A number
a₂ A number
b₂ A number
a₃ A number
b₃ A number
a₄ A number
b₄ A number
a₅ A number
b₅ A number
a₆ A number
b₆ A number
a₇ A number
b₇ A number
a₈ A number
b₈ A number
a₉ A number
b₉ A number
a₁₀ A number
b₁₀ A number

Example values

How the main result changes when a₁ changes and everything else stays at the example values above:

a₁ Cosine similarity S_C
0.5 0.356
0.75 0.398
1 0.4385
1.25 0.4772
1.5 0.514
2 0.5813

Formula

S_C = (a · b) ÷ (‖a‖ ‖b‖), θ = arccos S_C, D_C = 1 − S_C

Worked example

Inputs — Vector length (dimension): 3; a₁: 1; b₁: 2; a₂: 3; b₂: 1; a₃: 4; b₃: 0.
Results — Cosine similarity S_C = 0.438529; Angle θ between the vectors = 63.9899 °; Cosine distance D_C = 0.561471; Dot product a · b = 5.

Key terms

Cosine similarity
The cosine of the angle between two vectors.

Frequently asked questions

What does a cosine similarity of 0 mean?

The vectors are perpendicular – no similarity in direction.

Why ignore vector length?

A long and a short document on the same topic should be similar.

Can cosine similarity be negative?

Yes, down to −1 for opposite directions; with non-negative data (word counts) it stays between 0 and 1.

Is cosine distance a true metric?

Not strictly – it can violate the triangle inequality.

Sources

  1. OpenStax – Calculus Volume 3
  2. Wolfram MathWorld – Vector

Cite this calculator

Speedy Calculator. (2026). Cosine Similarity Calculator. Speedy Calculator. https://speedycalculator.com/calculators/math/cosine-similarity/