The dot product in this visualization
For two nonzero vectors and , the dot product has two definitions. One multiplies matching coordinates and adds them. The other multiplies the two lengths by the cosine of the angle θ between the vectors, and never mentions coordinates. Here you can turn the axes under two fixed vectors and see why the two always agree, as long as the axes are perpendicular with the same unit length.
The vectors stay where they are on the screen, and the axes turn under them. Turned through an angle φ, the axes give each vector new coordinates, written with primes, such as and . The sum bar under the plane lays the two terms and end to end. As the axes turn, both terms change, but the end of the row stays put. With the default and the sum is . Turned 135°, the terms are −1 and 6, and they still add up to 5.
Multiplying out the new coordinates shows why. The cross terms of the two products appear once with a plus sign and once with a minus sign, and collects the rest. Both terms expanded draws this with the current numbers.
Since the sum is the same in every pair of turned axes, pick the easiest pair: the x-axis along a. Then , the second term is 0, and b’s first coordinate is , how far b reaches along a, with a sign. This is b’s projection on a. So : the geometric formula is the coordinate formula read in the axes along a. Along b, it is |b| times a’s projection on b.
The lengths are positive, so the dot product has the sign of . It is positive for an acute angle, 0 for a right angle, and negative for an obtuse one, where b’s projection falls behind a. Two nonzero vectors are perpendicular exactly when their dot product is 0, as for (3, 1) and (−1, 3). Read the other way, the formula gives the angle from the coordinates:
Level lines answers another question: for a fixed a ≠ 0, which vectors x have ? Every such x has the same projection on a, , so they fill a line at right angles to a. Lines whose values of c differ by 1 are apart, so a longer a packs them closer. With a = (3, 1) the line through b = (1, 2) is , and (0, 5) and (2, −1) lie on it too. This is the normal form of a line, with a as its normal vector.
Things to notice
- A vector with itself gives . Here the coordinate formula is the Pythagorean theorem, which is one way to see why it needs perpendicular axes with the same unit length.
- Dragging b along a level line leaves the dot product unchanged, however far b moves and however its angle changes: its projection on a stays the same.
Controls
- Drag the ring at the end of the x-axis to turn the axes. It catches on the directions of a and b and on the right angles.