## Lost Among Notes

 << Newer Xmonad Older >> Number of trailing zeros in n factorial
Tags:

# Scalar product and direction cosines

When I learned about the scalar product in high school, I was somewhat surprised by how lucky its properties are.
The treatment is usually this: define $latex x \cdot y = |x| |y| \cos \theta$, where $latex \theta$ is the angle between $latex x$ and $latex y$. Then deduce that $latex x \cdot y$ is linear on the left and right arguments. Then, deduce that $latex (x_1 \vec i + x_2 \vec j + x_3 \vec k) \cdot (y_1 \vec i + y_2 \vec j + y_3 \vec k) = x_1 y_1 + x_2 y_2 + x_3 y_3$

Now, define the direction cosines of a vector $latex x$ as the cosines of the angles the vector forms with the basis vectors. By definition: $latex x = |x| (\cos \phi_1, \cos \phi_2, \cos \phi_3)$.
If we define $latex \theta$ as the angle between $latex x$ and $latex y$, $latex \alpha_i$ as the angles between $latex x$ and the axis, and $latex \beta_i$ as the angles between $latex y$ and the axis, we have: $latex \cos \theta = \sum_i \cos \alpha_i \cos \beta_i$.

This last formula mystified me. The deduction was so purely algebraic that I found it unsatisfactory. I wanted to see the geometric meaning.

A more geometric deduction follows: $latex (\cos \alpha_1, \cos \alpha_2, \cos \alpha_3)$ is a point $latex a$ on the unit sphere. If we take another point $latex b$ on the unit sphere, the subtend an angle $latex \theta$: On the unit sphere, we can find the angle $latex \theta$ subtended by $latex a$ and $latex b$, by calculating the distance $latex l$ between them: As you can see in the picture, $latex l = 2 \sin \frac{\theta}{2}$. Therefore: $$2 \sin \frac{\theta}{2} = \sqrt{\sum (\cos \alpha_i - \cos \beta_i)^2}$$ By basic trigonometry: $$\sin \frac{\theta}{2} = \sqrt{\frac{1 - \cos \theta}{2}}$$ Putting the above two together: $$4 \frac{1 - \cos \theta}{2} = \sum (\cos \alpha_i - \cos \beta_i)^2 = \sum (\cos^2 \alpha_i - 2 \cos \alpha_i \cos \beta_i + \cos^2 \beta_i)$$ Since $latex a$ and $latex b$ are both on the unit sphere: $$4 \frac{1 - \cos \theta}{2} = 2 - \sum 2 \cos \alpha_i \cos \beta_i$$, and $$\cos \theta = \sum \cos \alpha_i \cos \beta_i$$

In this deduction of $latex \cos \theta$, we didn’t assume any knowledge of the scalar product. In fact, we could have used it as a basis for the definition of the scalar product.