MISSION · Geometry
The Dot Product
Two vectors in, one number out, and that number is the angle in disguise
LEVEL 1 · EXPLORE
Make the idea move
Change the controls and watch what happens. Follow your curiosity and see what you notice.
Loading the activity…
LEVEL 2 · LEARN
Unlock the explanation
Open the chapters in any order. Try the examples as you go.
The idea in one sentence
The dot product multiplies two vectors and gives back a plain number, and that number measures how much the two point the same way.
Two ways to compute it, both useful
From components, multiply matching entries and add:
\[\mathbf{a} \cdot \mathbf{b} = a_1 b_1 + a_2 b_2\]For \(\mathbf{a} = (3, 4)\) and \(\mathbf{b} = (2, 1)\): \(3(2) + 4(1) = 10\).
From lengths and the angle between them:
\[\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}| \, |\mathbf{b}| \cos \theta\]These two expressions are always equal, which is the whole point of the topic. The first is easy to calculate and tells you nothing on sight; the second is hard to calculate and is full of meaning. Setting them equal lets you trade one for the other.
Rearranged, that trade gives the angle between any two vectors:
\[\cos \theta = \frac{\mathbf{a} \cdot \mathbf{b}}{|\mathbf{a}| \, |\mathbf{b}|}\]For our two vectors, \(|\mathbf{a}| = 5\) and \(|\mathbf{b}| = \sqrt 5\), so \(\cos \theta = \frac{10}{5\sqrt 5} \approx 0.894\) and \(\theta \approx 26.6°\).
The sign is the headline
Because the lengths are never negative, the sign of the dot product is the sign of \(\cos\theta\) — and that alone answers the question most problems are really asking.
- Positive: \(\theta < 90°\). The vectors broadly agree.
- Zero: \(\theta = 90°\). They are perpendicular.
- Negative: \(\theta > 90°\). They broadly oppose.
The middle case does the most work. Testing whether two vectors are perpendicular is one multiplication and one addition — no angles, no square roots, no inverse cosine. For \((1, 2)\) and \((-4, 2)\): \(-4 + 4 = 0\), so they are at right angles. That is far quicker than comparing gradients, and it works just as well in three dimensions, where gradients do not.
Why a number and not a vector
It is reasonable to ask why vector multiplication should throw away the direction.
Look again at \(|\mathbf{a}||\mathbf{b}|\cos\theta\) and group it as \(\left(|\mathbf{a}|\cos\theta\right)|\mathbf{b}|\). The bracket is the length of \(\mathbf{a}\)’s shadow when you shine a light straight down onto the line of \(\mathbf{b}\) — the projection of \(\mathbf{a}\) onto \(\mathbf{b}\). So the dot product is “how much of \(\mathbf{a}\) goes along \(\mathbf{b}\), times how long \(\mathbf{b}\) is”.
Once it is a shadow length times a length, it is plainly a number. There is also a product of two vectors that returns a vector — the cross product — but it only exists in three dimensions and answers a different question.
Where it earns its keep
- Work in physics. \(W = \mathbf{F} \cdot \mathbf{d}\). Push a trolley sideways to its motion and you do no work, because the dot product is zero — which matches the rather unfair experience of pushing something that does not move forward.
- Lighting in graphics. The brightness of a surface is the dot product of the light direction with the surface normal. Facing the light gives 1, edge-on gives 0.
- Testing perpendicularity in geometry proofs, in any number of dimensions.
- Similarity of data. Two lists of numbers, normalised and dotted, give the cosine similarity that search and recommendation systems run on.
Common mix-ups
- Writing a vector as the answer. \(\mathbf{a} \cdot \mathbf{b}\) is a scalar. If your answer has components, something went wrong.
- Multiplying the magnitudes and forgetting \(\cos\theta\). That only works when the vectors are parallel.
- Reading zero as “one of them is zero”. Two perfectly good vectors at right angles also give zero. This is why you cannot cancel dot products.
- Losing a minus sign in the components and flipping the conclusion from acute to obtuse. The sign is the answer, so it is the thing to double-check.
Check yourself
Find \((3,4) \cdot (2,1)\), say what a dot product of zero means, and compute \((1,2) \cdot (-4,2)\).
\(3(2) + 4(1) = 10\), positive, so the angle is acute. Zero means perpendicular. And \(1(-4) + 2(2) = 0\) — those two are at right angles.
LEVEL 3 · REFLECT
Add this quest to your trail
When you feel ready, mark this idea as explored. You can always come back and try it again.
EXPLORER STRATEGIES