Interactive Vector Space
Drag the red and blue vector endpoints to see how cosine similarity changes. Vectors can have any length within the coordinate bounds:
Cosine Similarity
0.71
Angle:
45.0°
Dot Product:
0.71
Vector A:
(2.0, 1.5)
|A| = 2.50
Vector B:
(-1.0, 2.5)
|B| = 2.69
Cosine Similarity Formula
$$\cos(\theta) = \frac{\mathbf{A} \cdot \mathbf{B}}{|\mathbf{A}| |\mathbf{B}|} = \frac{A_x B_x + A_y B_y}{\sqrt{A_x^2 + A_y^2} \sqrt{B_x^2 + B_y^2}}$$
Current calculation:
$$\cos(\theta) = \frac{(0.71)(0.00) + (0.71)(1.00)}{\sqrt{0.71^2 + 0.71^2} \sqrt{0.00^2 + 1.00^2}} = \frac{0.71}{1.00 \times 1.00} = 0.71$$