Mathwizurd.com is created by David Witten, a mathematics and computer science student at Stanford University. For more information, see the "About" page.

Finding the Angle Between Two Vectors

How to Find the Angle Between Two Vectors

Screenshot from KhanAcademy's video on this topic

Screenshot from KhanAcademy's video on this topic

This itself isn't calculus, but vectors are an important part of multivariable calculus, and I couldn't think of a better place to post this, so it's here.

Dot Product

Before we begin, we must define what a dot product is. The dot product is the sum of the products of the corresponding parts. For example, the dot product of <3, 4> and <5, 6> (written as <3,4>·<5,6>) is 3*5 + 4*6 = 39. When the dot product is 0, the vectors are perpendicular. We'll show this later.

Properties

This has numerous properties including the distributive property a·(b + c) = a·b + a·c, the reflexive property (a·b = b·a), and that ||a||^2 (the magnitude of a squared) = a·a.

Proof

On the left is a drawing of the vectors a, b, and a vector adjoining them, a-b. On the right, we have a corresponding triangle, with each side being the length of the vector, thus being completely equivalent to the triangle on the left. By the law of cosines:

MathJax TeX Test Page $$c^2 = a^2 + b^2 - 2ab\cos(C)$$ This corresponds to sides in the triangle. In our case, C is $\theta$. $$||\vec{a}-\vec{b}||^2 = ||\vec{a}||^2 + ||\vec{b}||^2 - 2||\vec{a}||*||\vec{b}||\cos(\theta)$$ $$||\vec{a}-\vec{b}||^2 = (\vec{a}-\vec{b}) \cdot (\vec{a} - \vec{b}) = (\vec{a} \cdot \vec{a}) - 2(\vec{a} \cdot \vec{b}) + (\vec{b} \cdot \vec{b}) = ||\vec{a}||^2 - 2(\vec{a} \cdot \vec{b}) + ||\vec{b}||^2$$ $$||\vec{a}||^2 - 2(\vec{a} \cdot \vec{b}) + ||\vec{b}||^2 = \||\vec{a}||^2 + ||\vec{b}||^2 - 2||\vec{a}||*||\vec{b}||\cos(\theta)$$ $$ \boxed{\vec{a} \cdot \vec{b} = ||\vec{a}||\vec{b}||\cos(\theta)}$$

Once you have that equation, you're able to solve any problem regarding the angle between two vectors by noting the relationship between the dot product and cosine. Thus, finding the angle between two vectors only involves taking the dot product, dividing, and taking the arccos of that.

Examples

 

MathJax TeX Test Page Find the angle between the vectors $\vec{a} = <3, 2, 5>$ and $\vec{b} = <6, 1, -4>$ $$\vec{a} \cdot \vec{b} = 3*6 + 2*1 + 5*-4 = 0$$ What does this mean? Well, we can see that $0 = ||a||*||b||\cos(\theta)$, so $0 = \cos(\theta)$ Therefore, $\theta = 90$ degrees. Whenever the dot product between two vectors is 0, they are perpendicular.
MathJax TeX Test Page Here's a real example. Find the angle between the vectors $\vec{a} = <2, 1, 2>$ and $\vec{b} = <3, 4, 5>$ $$\text{Dot product} = 2*3 + 1*4 + 2*5 = 20$$ $$20 = \sqrt{2^2 + 1^2 + 2^2}*\sqrt{3^2 + 4^2 + 5^2}\cos(\theta)$$ $$20 = 15\sqrt{2}\cos(\theta)$$ $$\dfrac{20}{15\sqrt{2}} = \cos(\theta)$$ $$\arccos{\left(\dfrac{20}{15\sqrt{2}}\right)} = \theta = 0.339 = \boxed{19.47 \text{ degrees}}.$$
David Witten

Cross Products

Crazy Tangent Integration