# Error when computing Cosine Similarity

I'm trying to compute the cosine similarity of the following vector:

1 1 0 1
2 0 1 1


$$\frac {1*2+1*0+0*1+1*1}{ \sqrt{1^2+1^2+0^2+1^2}\sqrt{2^2+0^2+1^2+1^2}} \,\,.$$

According to Wolframalpha this is equal to:

$$\frac{3}{1.732 * 2.449} = 0.707 \,\,.$$

But according to this document Example for computing cosine similarity (where I have the upper equation from) the result is $0.72$.

Who is wrong?

• I don't see anything off topic in asking how to calculate cosine similarity. – gung - Reinstate Monica Dec 16 '15 at 13:02

v1 = c(1, 1, 0, 1)

Second, by hand you can find that this is exactly equal to $\frac{1}{\sqrt 2}$ which is approximately 0.707. So Wolfram Alpha is correct. The pdf might have rounded strangely or made an arithmetic error.