# How does law of cosines work with vectors?

I just recently started physics for fun and started with the basics but something is already bugging me. It is about the implementation of law of cosines to sum of vectors.

I know how it works with triangles. I get the logic about the interaction between the two edges and the angle between them. But there is something I don't understand about choosing which angle we should use for the formula.

In the following visual:

• Orange vector's magnitude is $2$ and angle is $0^\circ$.

• Green vector's magnitude is $2$ and angle is $45^\circ$.

• Grey is sum.

• Blue is X line.

• Red is Y line. Now angle $\angle B = 45^\circ$ and therefore $\angle A = 135^\circ$. If we consider the shape as a triangle, then in order to find the grey line, we must implement the law of cosines with $\cos 135^\circ$. Like this:

$$V_\text{grey}=\sqrt{{V_\text{orange}}^2 + {V_\text{green}}^2 - 2V_\text{orange}\cdot V_\text{green}\cos 135^\circ}$$

However, on the tutorial I have seen on the internet, when calculating the sum of vector forces, they use $\cos 45^\circ$ in the formula instead, saying we must use the angle between the vectors (in the tutorial they both originate from the $(0,0)$ point). But then, when generating the shape geometrically, we technically don't use the angle that is facing the edge we want to find the value of. Can someone explain why we use $\cos 45^\circ$ and not $\cos 135^\circ$?

• The formula you wrote down is wrong; the last term should be $-2 \cos 135$. Since $\cos x = -\cos(180 - x)$, this is the same as $+2 \cos 45$ which is what your tutorial uses. – knzhou Feb 26 '16 at 17:18
• In fact, by turning some of your numbers to variables, you can prove that the two approaches are the same! (Using their method is actually the easiest way to derive the law of cosines in the first place.) – knzhou Feb 26 '16 at 17:19
• @knzhou: you should post that as an answer – John Rennie Feb 26 '16 at 17:23
• This is a good question, but it seems not to have a physical context. Perhaps we should send it to Mathematics? – David Z Feb 26 '16 at 17:27
• @DavidZ I agree. But the question is right out of the physics book that's why I posted here. Still, anything goes for me :) – SarpSTA Feb 26 '16 at 17:28

The law of cosines is just an expansion of a vector identity.

\begin{align*} \|V_3\|^2&=\|V_1+V_2\|^2\\ &=(V_1+V_2)\cdot(V_1+V_2)\\ &=V_1\cdot V_1+V_2\cdot V_2+2 V_1\cdot V_2\\ &=\|V_1\|^2+\|V_2\|^2+2 \|V_1\| \|V_2\| \cos(\theta) \end{align*}

Where, in the dot product identity, $\theta$ is the angle between the vectors. This alone solves your problem and proves that you should use forty five degrees!

But where did you go wrong? There's lots of confusion with the minus sign because of the law for triangles. Take the following diagram: say, $V_1$ is the vector from B to C, and $V_2$ is the vector from C to A. $C$ is the angle you want to use in the above vector formula $\|V_3\|^2=\|V_1\|^2+\|V_2\|^2+2 \|V_1\| \|V_2\| \cos(\theta)$. But the "$\theta$" in that formula is actually $\theta=\pi-C$. Then:

\begin{align*} c^2&=\|V_3\|^2\\ &=\|V_1\|^2+\|V_2\|^2+2 \|V_1\| \|V_2\| \cos(\pi-C)\\ &=\|V_1\|^2+\|V_2\|^2+2 \|V_1\| \|V_2\|\left( \cos(\pi)\cos(C)-\sin(\pi)\sin(C)\right)\\ &=\|V_1\|^2+\|V_2\|^2-2 \|V_1\| \|V_2\|\cos(C)\\ &=a^2+b^2-2 ab\cos(C)\\ \end{align*}

• Why is $\Theta = \pi - C$ ? – SarpSTA Feb 26 '16 at 18:58
• @SarpSTA Draw an arrow from B to C. Then draw the vector from C to A. Then place both vectors at the origin. The angle they make -- the one used by the dot product -- is not C, but $\pi-C$. This can be seen if you extend BC to a line and then look at the outside angle to $C$ (and the rule $\theta+C=\pi$) – user18862 Feb 26 '16 at 19:03
• I believe I got it. One question to make sure. If we change the first vector you mentioned (B to C) to C to B for the same design, would we use the angle 'C' then? – SarpSTA Feb 26 '16 at 19:08
• @SarpSTA Yep! That's it. – user18862 Feb 26 '16 at 19:42

Okay I found the answer. The reason we use $\angle B$ is because it is equal to $180 - \angle A$ which when implied to $cos$, is equal to $-cos \angle A$. Also I figured the tutorial doesn't use the normal law of cosines but rather this:

$$V_\text{sum}=\sqrt{{V_\text{1}}^2 + {V_\text{2}}^2 + 2V_\text{1}\cdot V_\text{2}\cos \angle (between \space vectors)}$$

Not that it is + instead of - before $cos$.

We all know now which of the following ideas is more closely linked to the theory of of Euclidean Vector Analysis:

Law of cosines
OR
Quaternions

You might even make the claim that if mathematicians (should I say physicists?) three centuries ago focused on trying to elegantly express the Law of Cosines in 3-Space, the development of vector analysis would have been available to humanity at a much earlier time; see A History of Vector Analysis.

So we now have the dot product (and the more abstract inner product) that we can learn how to use. But don't ever take it for granted!

Newton gave us the Parallelogram of Force Theory. Perhaps if he had time/interest to think just about math, he would have given us the Polarization Identity and its relation to the Law of Cosines.