Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can one see that a dot product gives the angle's cosine between two vectors. (assuming they are normalized)

Thinking about how to prove this in the most intuitive way resulted in proving a trigonometric identity: $\cos(a+b)=\cos(a)\cos(b)-\sin(a)\sin(b)$.

But even after proving this successfully, the connection between and cosine and dot product does not immediately stick out and instead I rely on remembering that this is valid while taking comfort in the fact that I've seen the proof in the past.

My questions are:

  1. How do you see this connection?

  2. How do you extend the notion of dot product vs. angle to higher dimensions - 4 and higher?

share|cite|improve this question
In 2d, you're looking precisely at the cosine "angle difference" formula. Just express the vectors in a polar-like form: if $v = r (\cos\theta, \sin\theta)$ and $w= s(\cos\phi,\sin\phi)$, then $v \cdot w = r s (\cos\theta \cos\phi+\sin\theta\sin\phi)= r s \cos(\theta-\phi) = (\text{product of lengths}) \cos(\text{angle between})$. – Blue Mar 3 '12 at 23:21
I think the cosine comes from the cosine rule and not the compound angle formula. Given 2 vectors $\vec{a}$ and $\vec{b}$ emanating from the same point. Given the angle between them and the fact that the vector opposite the angle is $\vec{b}-\vec{a}$ you can use the cosine rule and derive the formula for the dot product. – E.O. Mar 3 '12 at 23:27
The Law of Cosines certainly drives the result in general. Evidently, $u\cdot u = |u|^2$ in any dimension; that's just the Distance Formula. Writing $w$ for $u-v$, we have $|w|^2 = (u-v)\cdot (u-v) = u \cdot u + v \cdot v - 2 u\cdot v = |u|^2 + |v|^2 - 2 u\cdot v$. The Law of Cosines tells us that this should be $|w|^2 = |u|^2 + |v|^2 - 2 |u||v|\cos\psi$ for angle $\psi$ between $u$ and $v$; consequently, we must have that $u\cdot v = |u||v|\cos\psi$. Nevertheless, I like that I can "see" the angle-difference formula in the 2d dot product. – Blue Mar 3 '12 at 23:39

The dot product is basically a more flexible way of working with the Euclidean norm. You know that if you have the dot product $\langle x, y \rangle$, then you can define the Euclidean norm via $$\lVert x\rVert = \sqrt{\langle x, x \rangle}.$$

Conversely, it turns out that you can recover the dot product from the Euclidean norm using the polarization identity $$\langle x, y \rangle = \frac{1}{4} \left(\lVert x + y\rVert^2 - \lVert x - y\rVert^2 \right).$$

Okay, so how can you see the relationship between the dot product and cosines? The key is the law of cosines, which in vector language says that $$\lVert a - b\rVert^2 = \lVert a\rVert^2 + \lVert b\rVert^2 - 2 \lVert a\rVert \lVert b\rVert \cos \theta$$

where $\theta$ is the angle between $a$ and $b$. On the other hand, by bilinearity and symmetry we see that $$\lVert a - b\rVert^2 = \langle a - b, a - b \rangle = \lVert a\rVert^2 + \lVert b\rVert^2 - 2 \langle a, b \rangle$$

so it follows that $$\langle a, b \rangle = \lVert a\rVert \lVert b\rVert \cos \theta$$

as desired.

Any two vectors in an $n$-dimensional Euclidean space spans a Euclidean space of dimension at most $2$, so the connection between the dot product and angles in general reduces to the case of $2$ dimensions.

share|cite|improve this answer

Here's one way to remember it easily: assume one of the two unit vectors is $(1,0)$ (by an appropriate choice of coordinates we may assume we are working in $2$ dimensions, and then that one of the vectors is the standard basis vector). Then the dot product is just the $x$-coordinate of the other, which is by definition the cosine of the angle between them.

share|cite|improve this answer
This is essentially how I was taught to think about it as well. The dot product between two vectors is the component of one vector in the direction of the other. So, if you pretend vector $A$ is infinitely long, then draw a line from the tip of vector $B$ down to $A$ such that it creates a right angle with $A$, then the point where it hits $A$ is the dot product (or rather, the distance to that point from the origin is the dot product). – Carl Mar 4 '12 at 0:10
thanks, but I'm not striving to remember this law, but rather to understand the logic behind it. This logic is not immediate - the law of cosines proof for example, although the operation is quite simple. I was wondering how others reason about this. And how to extend the idea of an angle to more than 3 dimensions. – Leo Mar 5 '12 at 13:49

Suppose $x,y$ are unit vectors and $x\cdot y=a$. Let $w=ax$. If we can show that $w$ is the orthogonal projection of $y$ on $x$, that does it, by definition of the cosine. So is $y-w$ orthogonal to $x$? Let's find the dot product: $(y-w)\cdot x = (y\cdot x) - (w\cdot x)= a = a(x\cdot x) = a-a=0$.

share|cite|improve this answer
this begs the question, why is the dot product of orthogonal vectors zero? if the answer is again "because it equals the cosine of the angle", the original question remains – Leo Mar 5 '12 at 13:45
So I've shown how to infer the general statement from one special case. – Michael Hardy Mar 5 '12 at 16:36
How would you show that a zero dot product means 90 degree angle? – Leo Mar 7 '12 at 9:33

Let $u=(a, b)$ and $v=(c, d)$ be two vectors having angles $p$, $q$ with x axis then $\cos p=a/\lVert u\rVert$ and $\sin p=b/\lVert u\rVert$ and $\cos q=c/\lVert v\rVert$, $\sin q=d/\lVert v\rVert$ then $\cos(p-q)= (a/\lVert \rVert) (c/\lVert v\rVert)+(b/\lVert u\rVert)(d/\lVert v\rVert)$ then $ac+bd=\lVert u\rVert\,\lVert v\rVert\cos(p-q$) then $\langle u, v\rangle = \lVert u\rVert\lVert v\rVert\cos(p-q)$

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.