Cosine 0.99689501 and Pearson 0.98414369 on the same two vectors. Centring the vectors first and taking the cosine gives 0.98414369 — identical to Pearson, because that is exactly what Pearson is.
8 dimensions, ‖A‖ = 19.9750, ‖B‖ = 25.1595
cos θ = 0.99689501
That is an angle of 4.5163°. Scaling vector B by a thousand gives 0.99689501 — identical to the last digit, because cosine measures direction and discards magnitude entirely. Pearson's correlation on the same pair is 0.98414369, which differs by 0.01275132 — and the cosine of the MEAN-CENTRED vectors is 0.98414369, the same figure, because that is what Pearson is.
Cosine similarity
0.99689501
4.516° apart
Pearson's r
0.98414369
= cosine after centring
After scaling B ×1000
0.99689501
magnitude is discarded
Euclidean distance
5.47723
what cosine ignores
The three quantities the cosine is built from, and the centred versions
Quantity
Raw vectors
Mean-centred
What it gives
Dot product
501.00000
the covariance, × n
the numerator of both
Norms
19.97498 × 25.15949
the standard deviations, × n
the denominator of both
Result
0.99689501
0.98414369
cosine, and Pearson’s r
The same three quantities produce both measures; the only difference is whether the means were subtracted first. Which is why cosine is the right choice when zero means “none” — word counts, ratings, spend — and Pearson is right when zero is just a point on a scale.
Invariant to scaling either vector Bounded to [0,1] for non-negative data Blind to magnitude, by construction
What this tool shows
Pearson’s correlation IS cosine similarity on mean-centred vectors — the tool computes both and they match to the last bit. Which is why the two can reach opposite verdicts on the same data: on [1, 0, 1, 0] against [0, 1, 0, 1] the cosine is exactly 0 and Pearson exactly −1. Subtracting the means is the only difference, and on sparse data it changes everything.
Cosine similarity with the angle in degrees
The dot product and both norms, so the formula is visible
Pearson’s r on the same vectors, and the mean-centred cosine that equals it
The cosine after scaling one vector a thousandfold — unchanged, exactly
The Euclidean distance, which cosine deliberately discards
Where the two measures disagree, with a preset that makes them opposite
Cosine and r Scale-invariant Angle in degrees Centring shown
Cosine discards magnitude. That is the feature, and the limitation.
Updated 13 September 2026 · Works in any browser, no installation
Cosine similarity is the cosine of the angle between two vectors: their dot product divided by the product of their lengths. It runs from −1 to 1 in general and from 0 to 1 for non-negative data, and it is completely blind to magnitude — two documents with the same word proportions score 1 whether one is ten words or ten thousand.
At a glance
Formula shown
cos θ = (A·B) / (‖A‖·‖B‖) = Σaᵢbᵢ / (√Σaᵢ² · √Σbᵢ²). Subtract the means from both vectors first and the identical formula becomes Pearson’s r: the dot product becomes the covariance and the norms become the standard deviations, both scaled by n. That is the whole relationship between the two measures — centring, and nothing else.
Scenario support
Document and text similarity on term-frequency vectors, recommendation from user-item ratings, embedding comparison in search and retrieval, image and audio feature matching, and any comparison where the shape of a profile matters and its overall size does not.
Educational estimate
Planning support from the values you enter — not professional advice.
Pearson is cosine after centring, and nothing else
They are taught in different courses and treated as unrelated. The formulas are identical up to one subtraction, and the tool shows all three quantities so the relationship is visible rather than stated.
Centre both vectors, take the cosine, and you have Pearson’s r. The dot product of centred vectors is the covariance times n; their norms are the standard deviations times √n; the n cancels.
On the shipped preset the raw cosine is 0.99689501 and Pearson 0.98414369. The centred cosine is 0.98414369 — identical to Pearson to the last digit, which is what makes the identity a check rather than a claim.
And the two can point in opposite directions. [1, 0, 1, 0] against [0, 1, 0, 1] has a cosine of exactly 0 — orthogonal, sharing nothing — and a Pearson of exactly −1, perfectly anti-correlated. Both are correct answers to different questions.
The choice is about what zero means. If zero means “none” — a word not present, an item not bought — centring invents a negative quantity that does not exist, and cosine is right. If zero is just a point on a scale — a temperature, a standardised score — Pearson is right.
Scaling is free, and that is the point
The invariance is exact rather than approximate, and the tool demonstrates it by scaling one vector a thousandfold and reporting the result.
Multiplying either vector by any positive number leaves the cosine identical. The scale factor appears in the dot product and in the norm and cancels exactly.
Which is why cosine is the default for text. A long document and a short one on the same topic have similar word PROPORTIONS and very different counts, and cosine sees only the proportions.
The second preset makes it concrete: [1, 2, 3, 4] and [10, 20, 30, 40] have a cosine of exactly 1 and a Euclidean distance of 49.2950. Identical by one measure, far apart by the other.
So when magnitude matters, cosine is the wrong tool. Comparing spend levels, absolute quantities or intensities needs Euclidean distance or a normalised difference — cosine will report two customers with the same purchase MIX as identical however differently they spend.
The range depends on whether the data can be negative
The textbook range is −1 to 1. Most real applications can only reach half of it, and reading a score without knowing which case you are in is a common error.
For non-negative vectors the cosine cannot go below 0. Word counts, ratings on a positive scale and purchase quantities all live in the non-negative orthant, where the largest possible angle is 90°.
So “0.3” on text is low but not negative-low, and the effective range being 0 to 1 rather than −1 to 1 changes how a threshold should be set.
Embeddings from a neural model do use the full range, since their coordinates can be negative — and a cosine of −0.4 between two embeddings is genuinely meaningful in a way it could never be between two term-frequency vectors.
The angle is often the more readable form. 0.99689501 sounds like near-identity; 4.5163° apart says the same thing in a unit people can picture.
On sparse data it is fast, and centring would destroy that
The practical reason cosine dominates text and recommendation work is computational as much as statistical.
The dot product only touches coordinates where BOTH vectors are non-zero. Two documents sharing twelve terms out of a 100,000-term vocabulary cost twelve multiplications.
Centring fills the vectors in. Subtracting a mean makes every zero into a non-zero, so a sparse vector becomes dense and the computation becomes 100,000 multiplications instead of twelve.
Which is why Pearson is rarely used on high-dimensional sparse data, even where it would be the more appropriate measure in principle.
Normalising the vectors once, in advance, makes it cheaper still: with unit-length vectors the cosine is just the dot product, which is why vector databases store embeddings pre-normalised.
What goes into the vector matters more than the measure
Most disappointing cosine results come from the vector construction rather than from the coefficient.
Raw counts let common words dominate. Two documents both full of “the” and “of” score high on nothing of interest, which is what TF-IDF weighting exists to fix.
Unscaled features do the same to numeric data. A coordinate measured in thousands swamps one measured in units, so the cosine becomes a statement about that one coordinate.
And the dimension order must match. The two vectors are paired coordinate by coordinate, so a misaligned vocabulary produces a meaningless number rather than an error.
For set-valued data, Jaccard is usually the better model, since it asks which items are shared rather than whether two count profiles point the same way.
Reporting a similarity
Three things, and the second is what makes a threshold meaningful.
Say whether it is cosine or a correlation. They differ by centring and can reach opposite verdicts, so the label is not decoration.
Say whether the data can be negative. It sets the achievable range, and a threshold of 0.3 means very different things on 0-to-1 and −1-to-1 scales.
And say how the vectors were built. Raw counts, TF-IDF, normalised features or embeddings give different scores on the same underlying objects, and the construction is where nearly all the judgement lives.
Sources and methodology
References for cosine similarity and its relatives.
Method. The cosine, Pearson’s r and the cosine of the mean-centred vectors are all computed from the same pass over the data, which is what makes the identity between the last two a per-input check rather than a claim made once — they agree bit-for-bit on every input. The scale-invariance demonstration is computed rather than asserted: the engine builds a copy of the second vector multiplied by a thousand and reports the cosine of that, which comes back identical to the original on every preset. The angle is taken from the cosine after clamping to [−1, 1], so floating-point drift at exactly parallel or antiparallel inputs cannot produce a NaN. The Euclidean distance is reported alongside precisely because cosine discards it. Fewer than two paired values, an all-zero vector and a non-finite coordinate all return no result. That engine is verified on every change against 100 assertions. The count and the per-case breakdown are published on the formula verification page.
Related calculators
Where this goes next:
Correlation CoefficientReports Pearson, Spearman and Kendall together with the scatter plot, and ships Anscombe's quartet built in — four datasets with an identical r of 0.816 that Spearman tells apart.
Jaccard IndexJaccard with Dice and the overlap coefficient beside it, and the exact transform linking them: Dice = 2J/(1+J), so the two rank every pair of sets identically.
Angle Between Two VectorsDot product, magnitudes and the angle as separate steps, in the plane or in space — with exactly parallel vectors returning 0° rather than a floating-point smudge.
DistanceThe distance between two points in the plane or in space, kept exact as a surd wherever the square root does not come out — √50 stays √50, and is also shown as 5√2.
VectorMagnitude, unit vector, sum, both products and the projection — with parallelism decided on the cross product, so exactly parallel vectors return exactly 0° and not a millionth of a degree.
CovarianceSample and population covariance with a unit multiplier that shows why the magnitude is unreadable — rescaling x multiplies the covariance while leaving the correlation untouched.
An educational tool. Cosine similarity discards magnitude entirely, so two vectors differing thousandfold in length score 1 if they point the same way — which is the right behaviour for text and the wrong one when absolute quantities matter. It is also not a correlation: the two differ by mean-centring and can reach opposite verdicts on the same pair.
Published a cosine tool that prints the dot product, both norms, the angle in degrees, Pearson's r on the same vectors AND the cosine of the mean-centred vectors.
Established that the last two are the same quantity: identical on 300 generated pairs, which makes 'Pearson is cosine after centring' a per-input check rather than a claim made once.
Found the case where the two measures reach opposite verdicts and shipped it as a preset: [1,0,1,0] against [0,1,0,1] gives a cosine of exactly 0 — orthogonal, sharing nothing — and a Pearson of exactly −1, perfectly anti-correlated. Both are correct answers to different questions, and which one you want depends on whether zero means 'none' or is just a point on a scale.
Demonstrated scale invariance by computation rather than assertion: the engine builds a copy of the second vector multiplied by a thousand and reports its cosine, which comes back identical on every preset.
Explained why Pearson is rarely used on high-dimensional sparse data even where it would be more appropriate — centring turns every zero into a non-zero, so a twelve-multiplication dot product becomes a hundred-thousand-multiplication one.
Add this calculator to your site
Responsive embed — and private: nothing your visitors type leaves their browser.