How this instrument works
Cosine similarity is the cosine of the angle between two vectors, produced straight from the dot product and the two magnitudes without ever finding the angle itself. The formula sim = (v1·v2) ⁄ (|v1||v2|) divides away everything about how long each vector is, leaving a single number between −1 and 1 that says only how aligned their directions are: 1 means pointing the same way, −1 means pointing exactly opposite, and 0 means no directional relationship at all. Stopping at the ratio, rather than pushing on to an inverse cosine, is the point — most uses of this number only need to rank or threshold it, and skipping that extra step on every comparison matters when there are thousands of vectors to compare.
A genuinely surprising consequence follows from that division: stretch either vector by any positive factor and the score does not move at all. Multiply a document's word-count vector by ten, or a user's rating vector by a hundred, and its cosine similarity to every other vector on record stays exactly what it was, because |v1| and |v2| in the denominator grow by precisely the same factor as the dot product in the numerator and the extra length cancels out. That scale invariance is why the measure took over in text search and recommendation systems: a long document and a short one, or an enthusiastic rater and a sparing one, can be compared on direction alone, with raw magnitude simply removed from the question.
The formula breaks down only at the zero vector, where no direction exists to compare and the denominator itself becomes zero. A subtler limit concerns the sign: vectors built from raw non-negative counts, such as how many times each word appears in a document, can never produce a negative dot product, so a similarity score computed from that kind of data never actually reaches the negative half of its theoretical range — negative scores only appear once the vectors are allowed negative entries, as with mean-centered ratings or trained word embeddings.
- Enter the first vector's components into Vector 1: x and Vector 1: y.
- Enter the second vector's components into Vector 2: x and Vector 2: y.
- Read Cosine similarity — a single number between −1 and 1.
- 1 means the two vectors point the same way, 0 means they are perpendicular, and −1 means they point exactly opposite.
- Multiply every component of one vector by the same positive number to confirm the score does not change, since only direction is measured.
Worked example — vectors 45 degrees apart
Enter Vector 1 as x1 = 1, y1 = 1 and Vector 2 as x2 = 1, y2 = 0. The dot product is x1x2 + y1y2 = 1×1 + 1×0 = 1. Vector 1's magnitude is √(1²+1²) = √2 ≈ 1.4142135624, and Vector 2's magnitude is √(1²+0²) = 1. Dividing gives sim = 1 ⁄ (1.4142135624 × 1) = 0.7071067811865475, and Cosine similarity reports that figure.
That number is exactly 1⁄√2, the cosine of the 45° angle separating the two arrows, but this sheet never actually computes 45° — it stops at the ratio itself. That distinction matters at scale: a search engine ranking a million documents against one query vector only needs this bounded number to sort results, and skipping the inverse-cosine step on every one of those million comparisons is a real saving, not just a shortcut on paper.
Questions
How is cosine similarity different from the angle between two vectors?
Both start from the same ratio, (v1·v2) ⁄ (|v1||v2|), but cosine similarity stops there and reports that ratio directly — a bounded score from −1 to 1 — while finding the angle takes the further step of applying an inverse cosine to convert the ratio into degrees or radians. Search and recommendation tools use the raw score because ranking results only needs the number, not the angle it corresponds to.
What does a cosine similarity of 0 mean?
A score of 0 means the dot product x1x2+y1y2 came out to zero, so the two vectors are perpendicular and share no directional overlap — knowing one vector's direction tells you nothing about the other's. In text search, this is the score two documents get when they share no meaningful term overlap in the space the vectors were built from.
Can cosine similarity be negative?
Yes, whenever the dot product itself is negative, which happens once the two vectors point into roughly opposite halves of the plane; −1 is the minimum, reached only when they point in exactly opposite directions. One exception: vectors built from raw non-negative counts, like word frequencies, can never produce a negative dot product, so their similarity score never drops below 0 regardless of how different the two vectors are.
Why doesn't the length of the vectors affect the score?
Because the formula divides the dot product by |v1| times |v2|, which cancels out both vectors' magnitudes exactly — stretch either arrow by any positive factor and the similarity score does not move. That scale invariance is the reason the measure exists: it lets a short document be compared against a long one, or a sparing rater against a prolific one, using direction alone.
Why is the score always between −1 and 1?
A dot product can never exceed the product of the two magnitudes in size, a bound known as the Cauchy–Schwarz inequality, so dividing v1·v2 by |v1||v2| always lands inside [−1, 1] for any pair of nonzero vectors, with no possibility of the ratio overshooting that range.
What input makes this calculator fail?
Entering (0, 0) for either vector, since a zero vector has no direction to compare and the formula would need to divide by a magnitude of zero. Every other pair of real-numbered coordinates produces a valid score somewhere between −1 and 1.