The formula
a · b = Σ aᵢbᵢ = |a||b|cos θ
What it means
The dot product has two equivalent definitions, and their equality is the useful fact. Component by component it is trivial to compute; geometrically it is the magnitudes times the cosine of the angle. Setting them equal is how you extract the angle.
How to do it by hand
- Multiply the vectors component by component
- Add all the products: that is the dot product
- Divide by the two magnitudes to get the cosine of the angle
- Take the arccosine for the angle itself
What is worth knowing
The sign alone tells you a lot: positive means the vectors point broadly the same way, negative means broadly opposite, and zero means exactly perpendicular. That zero test works in any number of dimensions, which is why the dot product is the workhorse of similarity in machine learning — cosine similarity is nothing but this formula normalised. In physics it is how work is defined: force dotted with displacement, which is why pushing sideways on a moving object does no work at all.