# Inverse Functions: Arccosine and Dot Products (Part 23)

The Law of Cosines can be applied to find the angle between two vectors ${\bf a}$ and ${\bf b}$. To begin, we draw the vectors ${\bf a}$ and ${\bf b}$, as well as the vector ${\bf c}$ (to be determined momentarily) that connects the tips of the vectors ${\bf a}$ and ${\bf b}$.

Using the usual rules for adding vectors, we see that ${\bf a} + {\bf c} = {\bf b}$, so that ${\bf c} = {\bf b} - {\bf a}$

We now apply the Law of Cosines to find $\theta$:

$\parallel \! \! {\bf c} \! \! \parallel^2 = \parallel \! \! {\bf a} \! \! \parallel^2 + \parallel \! \! {\bf b} \! \! \parallel^2 - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

$\parallel \! \! {\bf b} - {\bf a} \! \! \parallel^2 = \parallel \! \! {\bf a} \! \! \parallel^2 + \parallel \! \! {\bf b} \! \! \parallel^2 - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

We now apply the rule $\parallel \! \! {\bf a} \! \! \parallel^2 = {\bf a} \cdot {\bf a}$, convert the square of the norms into dot products. We then use the distributive and commutative properties of dot products to simplify.

$( {\bf b} - {\bf a} ) \cdot ({\bf b} - {\bf a}) = {\bf a} \cdot {\bf a} + {\bf b} \cdot {\bf b} - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

${\bf b} \cdot ({\bf b} - {\bf a}) - {\bf a} \cdot ({\bf b} - {\bf a}) = {\bf a} \cdot {\bf a} + {\bf b} \cdot {\bf b} - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

${\bf b} \cdot ({\bf b} - {\bf a}) -{\bf a} \cdot ({\bf b} - {\bf a}) = {\bf a} \cdot {\bf a} + {\bf b} \cdot {\bf b} - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

${\bf b} \cdot {\bf b} - {\bf a} \cdot {\bf b} - {\bf a} \cdot {\bf b} + {\bf a} \cdot {\bf a} = {\bf a} \cdot {\bf a} + {\bf b} \cdot {\bf b} - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

${\bf b} \cdot {\bf b} - 2 {\bf a} \cdot {\bf b} + {\bf a} \cdot {\bf a} = {\bf a} \cdot {\bf a} + {\bf b} \cdot {\bf b} - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

We can now cancel from the left and right sides and solve for $\cos \theta$:

$- 2 {\bf a} \cdot {\bf b} = - 2 \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel \cos \theta$

$\displaystyle \frac{ {\bf a} \cdot {\bf b} }{ \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel } = \cos \theta$

Finally, we are guaranteed that the angle between two vectors must lie between $0$ and $\pi$ (or, in degrees, between $0^\circ$ and $180^\circ$). Since this is the range of arccosine, we are permitted to use this inverse function to solve for $\theta$:

$\cos^{-1} \left( \displaystyle \frac{ {\bf a} \cdot {\bf b} }{ \parallel \! \! {\bf a} \! \! \parallel \parallel \! \! {\bf b} \! \! \parallel } \right) = \theta$

The good news is that there’s nothing special about two dimensions in the above proof, and so this formula may used for vectors in $\mathbb{R}^n$ for any dimension $n \ge 2$.

In the next post, we’ll consider how this same problem can be solved — but only in two dimensions — using arctangent.