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?

  • 6,652
  • 6
  • 33
  • 54
  • 1,529
  • 2
  • 13
  • 22
  • 7
    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 03 '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 03 '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 03 '12 at 23:39

7 Answers7


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 together span 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.

  • 251
  • 2
  • 7
Qiaochu Yuan
  • 359,788
  • 42
  • 777
  • 1,145
  • 17
    makes sense, however, unfortunately this proof just relies on another fact I have been brought up to believe by faith which is the law of cosines. – Charlie Parker Jul 16 '17 at 18:16
  • @Pinocchio You can find many proofs of the law of cosines [here](https://en.wikipedia.org/wiki/Law_of_cosines#Proofs). – user Jun 23 '19 at 10:28

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.

  • 13,232
  • 1
  • 35
  • 47
  • 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 04 '12 at 00:10
  • 1
    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 05 '12 at 13:49
  • 1
    Your argument requires that students understand the rotation invariance of the scalar product. Any idea how to make this obvious? – shuhalo May 28 '17 at 11:00
  • @shuhalo [for example here](https://math.stackexchange.com/questions/947867/how-to-prove-invariance-of-dot-product-to-rotation-of-coordinate-system) – Adam Kurkiewicz Jul 05 '18 at 09:26
  • @shuhalo For the sake of having an answer here in the comments: the dot product is half the difference between the squared length of the sum of the two vectors and the sum of their squared lengths. It is therefore invariant by any length-preserving linear transformation (for instance, rotations). – Stephen May 30 '21 at 19:54
  • @Leo In fact, this is *precisely* how I think of the logic behind it. – Stephen May 30 '21 at 19:55

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$.

  • 105
  • 6
Michael Hardy
  • 1
  • 30
  • 276
  • 565
  • 3
    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 05 '12 at 13:45
  • 2
    So I've shown how to infer the general statement from one special case. – Michael Hardy Mar 05 '12 at 16:36
  • How would you show that a zero dot product means 90 degree angle? – Leo Mar 07 '12 at 09:33
  • @Leo In fact, the Pythagorean theorem, that a triangle is right if and only if its side lengths satisfy $a^2+b^2=c^2$ implies this, together with the algebraic identity $x \cdot y=\frac{1}{2}(|x+y|^2-|x|^2-|y|^2)$. That is, you can think of the dot product as half the amount by which the Pythagorean theorem fails for the triangle with sides given by the three vectors $x,y$ and $x+y$. – Stephen May 30 '21 at 20:00

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)$

Arturo Magidin
  • 356,881
  • 50
  • 750
  • 1,081
  • 31
  • 1


v1 dot v2 = x1*x2 + y1*y2 = |v1||v2|( cos(a)*cos(b)+sin(a)sin(b) ) = |v1||v2|cos(a-b) = |v1||v2|*cos(theta)

Besides, the proof of cos(a-b)==cos(a)*cos(b)+sin(a)*sin(b) : http://www.math.ubc.ca/~feldman/m100/trigId.pdf

  • 5
    Thanks for contributing to math.SE! One small suggestion, you could use [MathJax](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) to format your formula – Jay Zha May 23 '17 at 03:18

A 3-D rotation should be a transformation $T:\mathbb{R}^{3}\to\mathbb{R}^3$ that preserves the Euclidean norm. For any two vectors $\mathbf{x}, \mathbf{y}$, $T(\mathbf{x}):=\mathbf{a}$ and $T(\mathbf{y}):=\mathbf{b}$. As $T$ also preserves the angle between two vectors, the parallelogram formed by $\mathbf{a}$ and $\mathbf{b}$ is congruent to the one formed by $\mathbf{x}$ and $\mathbf{y}$, and thus the diagonal $$T(\mathbf{x}+\mathbf{y})= \mathbf{a}+\mathbf{b}$$ $$\lVert \mathbf{x}+\mathbf{y}\rVert = \lVert \mathbf{a}+\mathbf{b}\rVert $$ So $\langle \mathbf{a}+\mathbf{b}, \mathbf{a} +\mathbf{b}\rangle = \langle \mathbf{x}+\mathbf{y}, \mathbf{x} +\mathbf{y}\rangle$. By definition, $\lVert \mathbf{a}\rVert = \lVert \mathbf{x}\rVert$ and $\lVert \mathbf{b}\rVert=\lVert \mathbf{y}\rVert$, and by the commutativity of of the dot product and its distributivity over addition, $$\langle \mathbf{a}+\mathbf{b}, \mathbf{a} +\mathbf{b}\rangle = \langle \mathbf{a}, \mathbf{a} \rangle + 2\langle \mathbf{a}, \mathbf{b} \rangle + \langle \mathbf{b}, \mathbf{b} \rangle$$ $$\langle \mathbf{x}+\mathbf{y}, \mathbf{x} +\mathbf{y}\rangle = \langle \mathbf{x}, \mathbf{x} \rangle + 2\langle \mathbf{x}, \mathbf{y} \rangle + \langle \mathbf{y}, \mathbf{y} \rangle$$ So this shows that $\langle T(\mathbf{x}), T(\mathbf{y})\rangle = \langle \mathbf{x}, \mathbf{y} \rangle $ i.e. the dot product is preserved under any rotation. Which then leads rather directly to Stephen's answer.


This is what helped me understand it most:

from here

enter image description here

primarily the picture on the right side.

Let the pink left side of the rectangle be a vector v you're projecting onto.

Let the black line labeled with a '1' be a vector u that you're projecting onto v.

The bit of pink on the top left is the orthogonal "line of projection" from the tip of u to the span of v.

The angle $\alpha - \beta$ in the pink triangle is the angle between v and u.

Imagine you're tilting the diagram a bit clockwise so that the long side ($cos\beta$) of the orange triangle is horizontal.

Now the $cos\beta$ side of the orange triangle is the x component of u in an imagined cartesian coordinate system, and the $sin\beta$ side of the orange triangle is the y component.

The blue side on the right is equal in length to the pink side on the left since this is a rectangle. On the blue side we can see the length is made up of $cos\beta \cdot cos\alpha + sin\beta \cdot sin\alpha$, which, if u and v are unit length, is the dot product.

Here's another diagram of the same scenario with a "normal" axis, and then also a rotated grid corresponding to v, the orange vector being projected onto

enter image description here

$cos\beta$ is the length of the x component of u, a unit vector $\beta$ counter-clockwise from the x axis.

$cos\alpha$ is the same for v. It's also the factor by which a vector pointing along the x axis (such as the x part of u) is scaled when it's projected onto v. This is because: say you have a right triangle with hypotenuse of length 1 lying on the x axis, with another side aligned with v. That side will have angle $\alpha$ with the hypotenuse (because v is $\alpha$ counter-clockwise from the x axis) and so its length will be $cos\alpha$.

So the x component of u is of length $cos\beta$, then when being "scaled" by projecting onto $v$, it becomes $cos\beta \cdot cos\alpha$.

The case with y components and $sin$ is analogous.