# Dot Product to find vector length vs. cosine law

When using the dot product to find vector lengths should the answer always be the same as when you apply cosine law? I was doing some linear algebra review and decided to solve some questions about vector lengths using both dot product and cosine law.

Lets say you have a vector $$\vec u = 2\vec a + 3\vec b$$ and $$\vec v = 3\vec a -\vec b$$ where $$\|\vec a\| = 3$$, $$\|\vec b\| = 4$$, and $$\vec a \cdot \vec b = 5$$. Find $$\|\vec u\|$$ and the angle between $$\vec u$$ and $$\vec v$$.

We know that the dot product of a vector and its self is $$\vec x\cdot \vec x = \|\vec x\|^2$$ because the angle between a vector and its self is 0 and cosine of 0 is 1 so the dot product just the magnitude (length) squared.

Using this method I computed the following: $$\vec u\cdot \vec u = (2\vec a + 3\vec b)\cdot(2\vec a + 3\vec b)$$ $$\|\vec u\|^2 = 4(\vec a\cdot \vec a) + 6(\vec a\cdot \vec b) + 6(\vec b\cdot \vec a) + 9(\vec b\cdot \vec b)$$ $$\|\vec u\|^2 = 4\|\vec a\|^2 + 12(\vec a\cdot \vec b) + 9\|\vec b\|^2$$ $$\|\vec u\|^2 = 4(3)^2 + 12(5) + 9(4)^2$$ $$\|\vec u\| = \sqrt{240} = 15.5$$

I used the same strategy for solving the magnitude of $$\|\vec v\|$$. This looks like: $$\vec v\cdot \vec v = (3\vec a - \vec b)\cdot(3\vec a - \vec b)$$ $$\|\vec v\|^2 = 9\|\vec a\|^2 -3(\vec a\cdot \vec b) -3(\vec b\cdot \vec a) + \|\vec b\|^2$$ $$\|\vec v\|^2 = 9\|\vec a\|^2 -6(\vec a\cdot \vec b) + \|\vec b\|^2$$ $$\|\vec v\|^2 = 9(3)^2 -6(5) + (4)^2$$ $$\|\vec v\|^2 = \sqrt{67}=8.12$$

Then using $$\vec u\cdot \vec v$$ I can solve for the angle. $$\vec u\cdot \vec v = \|\vec u\| \|\vec v\| cos(\theta)$$ $$(2\vec a + 3\vec b)\cdot (3\vec a -\vec b) = \|\vec u\| \|\vec v\| cos(\theta)$$ $$6\|\vec a\|^2 +7(\vec a\cdot \vec b) - 3\|\vec b\|^2 = \sqrt{240}\sqrt{67}cos(\theta)$$ $$cos^{-1}(\frac{6(3)^2 +7(5) - 3(4)^2}{\sqrt{240}\sqrt{67}}) = \theta$$ $$71.13^{\circ}= \theta$$

If I use cosine law to calculate the same vector lengths as I did above then I get different lengths. For $$\|\vec u\|$$ I calculated the following using cosine law: $$\|\vec u\|^2 =(2\|\vec a\|)^2 + (3\|\vec b\|)^2 - 2(2\|\vec a\|)(3\|\vec b\|)cos(180-\gamma)$$ Gamma is the angle between vectors $$\vec a$$ and $$\vec b$$ $$\vec a\cdot \vec b = \|\vec a\| \|\vec b\| cos(\gamma)$$ $$cos^{-1}(\frac{5}{(3)(4)})=\gamma$$ $$65.37^\circ = \gamma$$ Back to solving for $$\|\vec u\|$$ $$\|\vec u\|^2 =(2)^2(3)^2 + (3)^2(4)^2 - 2(2(3))(3(4))cos(114.62^\circ)$$ $$\|\vec u\| =\sqrt{240}=15.5$$

Using cosine law for the vector magnitude of $$\|\vec v\|^2$$ I get: $$\|\vec v\|^2 = ((3\|\vec a\|)^2) + ((-\|\vec b\|)^2 -2(3\|\vec a\|)(-\|\vec b\|)cos(\gamma)$$ $$\|\vec v\|^2 = (3)^2(3)^2 + (-1)^2(4)^2 -2(3(3))(-1(4))cos(65.37^\circ)$$ $$\|\vec v\| = \sqrt{127.00}$$ $$\|\vec v\| = 11.23$$

And then using dot product to solve for the angle between $$\vec u$$ and $$\vec v$$ would be the same method as I did earlier but with a different magnitude for $$\|\vec v\|$$. $$\vec u\cdot \vec v = \|\vec u\| \|\vec v\| cos(\theta)$$ $$(2\vec a + 3\vec b)\cdot(3\vec a -\vec b)= (15.5)(11.23)cos(\theta)$$ $$6\|\vec a\|^2 +7(\vec a\cdot \vec b) - 3\|\vec b\|^2 = (15.5)(11.23)cos(\theta)$$ $$cos^{-1}(\frac{6(3)^2 +7(5) - 3(4)^2}{(15.5)(11.23)}) = \theta$$ $$76.37^{\circ}= \theta$$

I am trying to figure out why the cosine law method and dot product give me different magnitudes for $$\|\vec v\|$$. This results in a different angle between the two vectors.

Sorry if this has been posted before. I tried to look for something like this but couldn't find anything. Any help is greatly appreciated!

• You did a great job of showing your work up until you got to your actual question, which is really vague. I’m having a really hard time understanding exactly what it is you’re asking. Show all of your work!
– amd
May 14, 2020 at 2:18
• Can you tell us what $\vec{a}$ and $\vec{b}$ are? You seem to have made some calculations with these vectors, so it'll depend on what they are. Also $\sqrt{67} \approx 8.185$. not $8.12$, which may have affected your calculations. May 14, 2020 at 2:23
• So $\vec a$ and $\vec b$ are not defined. All that is given is the magnitude of those two vectors and the dot product between them which you can use to calculate the angle between the vectors. I updated the question with the cosine method for $\|\vec u\|$ and $\|\vec v\|$.
– Olek
May 14, 2020 at 2:45
• Are you sure you're applying the cosine law correctly? E.g. $u$ is $2a + 3b$, so it represents one diagonal of the parallelogram formed by $2a$ and $3b$. You can't just apply the cosine law here; it would (usually) only work for the other diagonal. May 14, 2020 at 3:03
• Thanks a lot for the help twosigma! Really appreciate the feedback and the answer! This question was driving me crazy!
– Olek
May 14, 2020 at 3:38

$$\|\vec v\|^2 \stackrel?= (3\|\vec a\|)^2 + (-\|\vec b\|)^2 -2(3\|\vec a\|)(-\|\vec b\|)cos(\gamma).$$
You don't have a triangle with a side of length $$-\|\vec b\|$$ making an angle $$\gamma$$ with another side of length $$3\|\vec a\|$$. You have a triangle with a side of length $$\|\vec b\|$$ making an angle $$\gamma$$ with another side of length $$3\|\vec a\|$$.
Yes, the side whose length you specified as "$$-\|\vec b\|$$" is part of a vector diagram produced by a vector in the direction opposite from $$\vec b.$$ Nevertheless, once you have identified that part of the diagram as the side of a triangle and apply the cosine rule to it, the length of the side is positive because the cosine rule assumes the lengths of all three sides of your triangle are positive numbers. The fact that you got this side from $$-\vec b$$ instead of $$\vec b$$ was accounted for when you identified the angle between sides as $$\gamma$$ instead of $$180^\circ - \gamma.$$
Because of this sign error, you added $$30$$ when you should subtract $$30.$$ That is how you conclude that $$\|\vec v\|^2 = 127$$ although the correct answer is $$\|\vec v\|^2 = 67.$$
• Yes. The point is that $\lVert -\vec{b} \rVert = \lVert \vec{b} \rVert$. May 14, 2020 at 3:33