Cosine Similarity Calculator
Measuring Direction, Not Magnitude
Cosine similarity ignores how long two vectors are and measures only the angle between them — two documents with very different word counts can still be judged highly similar if the proportions of their vocabulary point in the same direction. That magnitude-independence is exactly why it's the standard similarity measure for text embeddings and other high-dimensional vector comparisons.
The Formula
The result ranges from −1 (pointing in exactly opposite directions) through 0 (orthogonal, no relationship) to 1 (pointing in exactly the same direction). This calculator also converts the result into the actual angle in degrees.
Where This Matters
- Document and text similarity — comparing TF-IDF or embedding vectors to find related documents regardless of length.
- Recommendation systems — measuring similarity between user preference vectors or item feature vectors.
- Clustering and nearest-neighbor search — cosine similarity is a common distance metric in high-dimensional spaces where Euclidean distance behaves poorly.
Worked Example
| Quantity | Value |
|---|---|
| A · B (dot product) | 32 |
| |A| (magnitude) | 3.742 |
| |B| (magnitude) | 8.775 |
| cos(θ) | 0.974632 |
| Angle θ | ≈ 12.93° |
cos(θ) = 32 / (3.742 × 8.775) = 0.9746; the small angle confirms the vectors point in nearly the same direction.
How to Use This Calculator
- Enter Vector A as a comma-separated list of components.
- Enter Vector B with the same number of components.
- Select Calculate to get the cosine similarity and the angle between the vectors.
Related Calculations
For a distance-based rather than angle-based comparison, use the Euclidean Distance Calculator, or standardize vectors first with the Feature Scaling Calculator.