Cosine Similarity
Compute cosine similarity between two 3D vectors. Enter x, y, z components of vectors a and b to calculate the similarity score, angle in degrees, and dot product.
About This Calculator
This cosine similarity calculator computes the cosine of the angle between two vectors, a fundamental metric in data science and machine learning for measuring how similar two vectors are regardless of their magnitude. The calculator supports 2D and 3D vectors -- simply leave the z component blank for 2D comparisons.
Cosine similarity ranges from -1 to 1, where 1 indicates identical direction, 0 indicates orthogonality (no correlation), and -1 indicates opposite directions. It is widely used in text analysis, recommendation systems, and information retrieval where documents or items are represented as high-dimensional vectors.
Regional Notes
India (IN): Cosine similarity is covered in undergraduate computer science and data science programs, particularly in courses on machine learning, information retrieval, and natural language processing taught at IITs, NITs, and other institutions.
United States (US): Cosine similarity is a core concept in data science, machine learning, and NLP courses at American universities. It is commonly used in collaborative filtering recommendation systems by major tech companies.
United Kingdom (UK): UK universities teach cosine similarity in computer science and data analytics programs, with applications in text mining, search engine technology, and artificial intelligence research across institutions like Cambridge, Oxford, and Imperial College.
Frequently Asked Questions
What is cosine similarity?
Cosine similarity measures the cosine of the angle between two vectors, indicating how similar their directions are. It ranges from -1 (opposite direction) through 0 (orthogonal) to 1 (same direction), and is widely used in machine learning and natural language processing.
How is cosine similarity calculated?
Cosine similarity is calculated as the dot product of the two vectors divided by the product of their magnitudes: cos(theta) = (a·b) / (||a|| x ||b||). The calculator also shows the angle in degrees using arccos of the similarity value.
Can cosine similarity be negative?
Yes, cosine similarity can be negative when the angle between the vectors exceeds 90 degrees, meaning the vectors point in generally opposite directions. A negative value indicates the two vectors are more dissimilar than similar.
What does a cosine similarity of 1 mean?
A cosine similarity of 1 means the two vectors point in exactly the same direction (angle = 0 deg). This does not necessarily mean the vectors are equal in magnitude, only that they are perfectly aligned in direction.
What happens if one vector is zero?
If either vector is a zero vector (all components are zero), its magnitude is zero and cosine similarity is undefined because division by zero occurs. The calculator returns no result in this case.
Is this cosine similarity calculator free to use?
Yes, all calculators on Calculy including this cosine similarity calculator are completely free to use with no registration or subscription required.