Linear Algebra
The Dot Product
Drop one vector perpendicularly onto the other and you get a shadow. The dot product is the length of the second one times that shadow, and nothing else. Drag the arrows and watch the number follow the picture.
x 2.0
y 0.6
z 0.0
x 0.8
y 1.8
z 0.0
a · b—
shadow of b on a—
length of a—
length of b—
angle between—
from the components—
Drag either arrowhead, or drag the empty space to move the scene around. In 3D the arrows are set with the sliders, dragging orbits and shift-dragging pans.
What to observe
- Drag the head of b in a circle around the origin, keeping it the same length. Its shadow on a grows, shrinks, vanishes and comes back negative, and the number follows it exactly. The dot product only ever measures that shadow.
- Stop where the shadow disappears. The arrows are at right angles, the number is zero, and it got there smoothly from both sides. Perpendicular means "nothing of one goes along the other", which is the one fact this operation exists to detect.
- Push b past that point. The foot of the perpendicular lands on the far side of the origin, so the shadow counts as negative and so does the product. The sign is not a convention, it is which way the shadow fell.
- The shaded rectangle is the product made visible: one side is the shadow, the other is the length of a, so its area is a · b. Lengthen a and the rectangle grows in one direction only; swing b and it grows in the other.
- Make a twice as long. Every bit of the answer doubles, while the angle and the shadow direction do not move at all. The dot product knows nothing except two lengths and how much they agree.
- Set a to length 1. Now a · b is the shadow, with no scaling left over. That is why "how much of this lies in that direction" is always written as a dot product against a unit vector.
- The panel computes the same number a second way, straight from the components: axbx + ayby. It always matches the picture, which is the whole reason the algebraic formula is worth trusting. Switch to 3D and one more term joins in, and nothing else about the picture changes.
Shortcuts: space run/pause · s step · r reset · f fullscreen