Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Could someone explain why the formula: $$\theta = \cos^ {-1}(a \cdot b)$$ provides the angle between vector $a$ and vector $b$? All the online resources seem to explain how to find the angle, but not why the method works.

Resources I looked at: http://chemistry.about.com/od/workedchemistryproblems/a/scalar-product-vectors-problem.htm



share|improve this question
How do you define the dot product? –  mixedmath May 23 '12 at 18:31
You can take this as a definition of angle. In any case, this is the law of cosines. –  Qiaochu Yuan May 23 '12 at 18:33
Multiplying corresponding entries of the vectors and then summing the products. –  user26649 May 23 '12 at 18:33
@QiaochuYuan I suspected it to have something to do with the cosine law, but I don't see any mention of the third side. Using cosine law, wouldn't $\theta = \cos^{-1}\left(\frac{c^2 - a^ 2 - b^2}{-2ab}\right)$ –  user26649 May 23 '12 at 18:39
The vectors must be unit vectors. Otherwise it's $\cos^{-1}\left( \dfrac{a.b}{\|a\| \|b\|} \right)$ –  Robert Israel May 23 '12 at 18:41
show 1 more comment

3 Answers

up vote 4 down vote accepted

The dot product can be derived from the cosine law. $$c^2=a^2+b^2-2ab\cos(C)$$ where C is the angle between $a$ and $b$. If you consider $a$ and $b$ as your vectors, then side $c$ can be represented as $(b-a)$. So (noting that I'm talking about distances)

$$|b-a|^2=|a|^2+|b|^2-2|a||b|cos(C)$$ $${(b_x-a_x)}^2+{(b_y-a_y)}^2={a_x}^2+{a_y}^2+{b_x}^2+{b_y}^2-2|a||b|cos(C)$$ $$({b_x}^2-2a_xb_x+{a_x}^2)+({b_y}^2-2a_yb_y+{a_y}^2)={a_x}^2+{a_y}^2+{b_x}^2+{b_y}^2-2|a||b|cos(C)$$ cancel out the squared terms and you get $$-2(a_xb_x+a_yb_y)=-2|a||b|cos(C)$$ $$a_xb_x+a_yb_y=|a||b|cos(C)$$ $$a\cdot b=|a||b|cos(C)$$ which gives you a nice way of getting the angle between vectors if you only have their components, by the simple rearrangement: $$C=\arccos(\frac{a\cdot b}{|a||b|})$$

It's less obvious why this works in the general dimensional case (and not just 2D), but a good place to start is to notice that any two vectors can always be put in a plane, and showing that expressing the $(x,y)$ of the plane in terms of the higher-dimensional vector components, then applying this calculation makes all the math come out okay.

share|improve this answer
Thank You Robert! –  user26649 May 23 '12 at 19:05
add comment

A combination of linear algebra and geometry can be useful. If $R$ is a rotation matrix, it satisfies $R^TR=I_n$, where $I_n$ is the $n\times n$ identity matrix. Assume $v,w$ are unit vectors. We compute

$$Rv\cdot Rw=(Rv)^T(Rw)=v^T(R^TR)w=v^TI_nw=v^Tw=v\cdot w$$

using matrix transpose properties. Thus the dot product is rotation-invariant. Rotations act transitively, which for our purposes means that given $v,w$ we can find a rotation $R$ so that $Rv=e_1$ is the first basis unit vector. After that we rotate around the $x$-axis so that $Rw$ becomes a vector on the $xy$-plane (while $Rv=e_1$ remains unchanged), and we are reduced to the case of $\Bbb R^2$. Here,


as desired (where $\theta$ is the angle between the second vector and the $x$-axis, or equivalently $e_1$).

share|improve this answer
add comment

We know that


Now let $\alpha$ be the angle between $a$ and the $x$-axis, and $\beta$ between $b$ and the $x$-axis. From the definition of sin and cos you got:


Since the angle between a and b is $\theta=\alpha-\beta$, you got



share|improve this answer
add comment

Your Answer


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