This formula
\(\cos(x)=\frac{a\cdot b}{||a||\,||b||}\). Just to clarify, The \(\cdot\) between the a and b is not a multiplication sign, it is a dot product.
This formula is very useful for calculating the angle between 2 vectors.
To prove: draw a vector, connecting vector \(\vec{a}\) and \(\vec{b}\), remembering vector subtraction, this vector is \(\vec{a-b}\).
We see a cosine, so we hope to use the law of cosines to help us relate side lengths. However, we don't know the side lengths of these vectors. However, we have a very important symbol called the norm, \(||~||\), and this the distance to the endpoint to the origin. Remember, vectors aren't defined with position, so norm gives an effective way to represent length. Here is a graph:
Set \(\theta = \angle AOB\)
Therefore by the law of cosines, we have:
\(\cos(\theta) = \frac{{||a||}^{2}+{||b||}^{2}-{||a-b||}^{2}}{2||a||\,||b||}\).
To relate norm to dot product, we have another very important formula:
\(v\cdot v ={||v||}^{2}\). (dot product again). PS, notice the resemblance to the formula \(z*\overline{z}={|z|}^{2}\), for complex number z.
Using this formula,
\(\cos(\theta) = \frac{a\cdot a+b\cdot b-(a-b)\cdot(a-b)}{2||a||\,||b||}\).
Dot products have a special property, because they are commutative, and distributive.
Therefore, \(\cos(\theta) = \frac{a\cdot a+b\cdot b-(a\cdot a- 2a\cdot b + b\cdot b)}{2||a||\,||b||}\)
Simplifying:
\(\cos(\theta) = \frac{2a \cdot b}{2||a|| \, ||b||}=\frac{a\cdot b}{||a||\,||b||}\).
This gives our desired formula.