Projection onto a chosen direction
Imagine taking a step a = (3, 1). We move three units to the right and one unit up. If we want to know how far we moved to the right, the answer is 3. If we want to know how far we moved up, the answer is 1. The coordinates of the step already answer both questions. We want to be able to ask the same question about any direction.
Let an arrow b with the same starting point O define the direction. From the endpoint A of the step, draw a perpendicular to the line along b. Label the intersection H. The segment from O to H shows how much of the step we took in that direction. This quantity is called the projection. Let us denote it by p. It is positive if H lies in the direction of arrow b, and negative if H lies in the opposite direction.
In Figure 1, the short dashed line runs from the endpoint A of the step at a right angle to the direction of b. The length of OH shows how far the step a takes us along b.
a onto the direction of b.From the projection to the dot product
The projection p tells us how much of vector a points along the nonzero vector b. If we make b longer without changing its direction, the projection stays the same. To account for the length of b as well, we multiply the projection by that length. The resulting number is called the dot product of vectors a and b and is denoted by a · b.
If the length of b is 1, the dot product equals the projection itself.
In Figure 2, vector a = (3, 1) is projected onto the horizontal axis in both cases. The projection is 3. When b changes from (2, 0) to (4, 0), its length doubles, so the dot product doubles too.
If the angle between the vectors is θ, the projection p is the length of a multiplied by cos θ. We can therefore write the dot product in terms of the lengths of both vectors and the angle between them. This form shows that swapping the vectors leaves the result unchanged.
The sign is straightforward. At an acute angle, the projection points forward and the product is positive. At a right angle, the projection is zero. At an obtuse angle, the projection points backward and the product is negative. The dot product is also zero for the zero vector.
Deriving the formula from coordinates
Let us calculate the square of the distance between the endpoints A and B in two ways. In Figure 3, segment AH is perpendicular to the direction of b. Let the length of AH be h. By the Pythagorean theorem, the square of the length of OA is the sum of the squares of p and h. We find the square of the distance AB using triangle AHB, whose legs are HB and AH.
Now consider the second right triangle in Figure 3. Its legs run along the coordinate directions. In the figure, Δx denotes the horizontal difference in coordinates, and Δy denotes the vertical difference. The square of the distance AB is again the sum of the squares of the legs. Expanding one square gives us a product of the x coordinates, and expanding the other gives us a product of the y coordinates.
In both calculations, the left-hand side is the same squared distance AB, and the right-hand side includes the same sum of squared lengths. After subtracting that sum from both sides, a factor of −2 remains. We cancel it to get that the length of b multiplied by the projection p equals the sum of the products of corresponding coordinates. This is the result we denoted by a · b.
Work done by a force as a dot product
In the formula A = FS, F denotes the magnitude of the force and S denotes the length of the displacement. In this form, the formula applies when the force points in the same direction as the displacement. If the directions differ, we take the projection of the force onto the direction of the displacement. In the notation above, vector a represents the force, vector b represents the displacement, and p denotes the projection of the force.
The last equality follows from the derivation above. For the x axis, we multiply the horizontal component of the force by the horizontal component of the displacement. For the y axis, we do the same with the vertical components. The axes are perpendicular, so a horizontal force does zero work during purely vertical displacement, and vice versa. This gives us the rule of multiplying coordinates from the same axis and then adding the results.
For example, a force of (3, −2) N acts during a displacement of (4, 1) m. Horizontally, the force and displacement point in the same direction and contribute 3 × 4 = 12 J. Vertically, the force points downward and the displacement upward, so the contribution is (−2) × 1 = −2 J. The total work is 10 J.
A numerical check
In Figure 3, the vectors have coordinates a = (3, 1) and b = (4, 3). The horizontal coordinates contribute 12, and the vertical coordinates contribute 3. Adding them gives a dot product of 15. The length of b is 5, so the projection p, the length of segment OH in this example, is 3.