What does the dot product tell you about two vectors?
A trail map shows how the dot product connects vector components, angles, and progress along a direction.
- Level
- Beginners
- Prerequisites
- Basic algebra and reading a coordinate grid
On this page
A trail marker sits 5 metres due east of your starting point. You follow a diagonal trail and end up 3 metres east and 4 metres north of where you started. To measure your progress along the direction to the marker, you need to describe where you went and where you meant to go.
Each arrow in Figure 1 represents a vector, a quantity with a size and, when its size is greater than zero, a direction. Both arrows start at the trailhead. The curved mark labelled $\theta$ (theta) shows the angle between them.
A dot product takes two vectors and gives you a single number that depends on their sizes and directions. If you’re new to vectors, this map gives you all the numbers you need. You’ll start by describing the arrows, then use the dot product to find the angle between them and measure the walk’s progress along the marker’s direction.
Components record the change along each axis#
The arrows on the map become pairs of numbers when you read them along two axes. The horizontal axis, $x$, measures east and west. The vertical axis, $y$, measures north and south. Each number in the pair is a component, the signed change along one axis.
Write the walk as $\mathbf a=(a_x,a_y)$ and the marker vector as $\mathbf b=(b_x,b_y)$. Both describe displacement, the change from a starting position to an ending position. The subscripts show which axis each component belongs to, with the east component first and all values measured in metres.
Positive components point east or north, and negative ones point west or south. The marker’s second component is zero because it lies due east. Once you have the components, you can use them to find the length of each arrow.
Magnitude gives the length of a vector#
The walk’s east and north components form the legs of a right triangle, and the arrow runs along its diagonal. Its magnitude, written $|\mathbf a|$, is the length of that arrow. The Pythagorean theorem gives the diagonal length by squaring the two leg lengths, adding them, and taking the square root.
The marker vector also has magnitude $5,\mathrm{m}$, since it runs straight east for 5 metres. These magnitudes set the scale for the dot product.
The dot product adds matching component products#
The dot product multiplies the two east components, multiplies the two north components, and adds those products. Write it with a centred dot. With both vectors written along the same perpendicular axes, the rule is
For the walk and the marker, the north term is zero because the marker’s north component is zero. The east components give the product of 3 metres and 5 metres.
The output is a scalar, a single number. Here its units are square metres because each term multiplies two lengths.
The rule extends to vectors with more components. For example, if you track elevation as a third axis, add the product of the two elevation components.
Combined with the two magnitudes, the dot product gives you the angle between the arrows.
Cosine connects the dot product to the angle#
The two arrows form an angle $\theta$ at their shared start. In Figure 1, the cosine of that angle, written $\cos\theta$, is the ratio of the horizontal leg to the diagonal of the right triangle. The walk has a horizontal leg of 3 metres and a diagonal of 5 metres, so the ratio is $3/5$.
For any two nonzero vectors, their dot product equals the product of their magnitudes times the cosine of the angle between them. Use the angle in the range from $0^\circ$ to $180^\circ$.
Dividing by both magnitudes recovers the cosine directly from the dot product. Then apply the inverse cosine, written $\arccos$, to find the angle with that cosine.
The law of cosines explains why the component and angle formulas give the same result (see Figure 4). The angle formula also gives you a quick test for direction. Since the two magnitudes are positive, the dot product has the same sign as $\cos\theta$.
The sign shows how the directions line up#
Keep the marker due east and move the walk’s endpoint around the map. An endpoint east of the trailhead gives a positive dot product, an endpoint directly north or south gives zero, and an endpoint west gives a negative dot product. The angle ranges give the same test for a marker in any direction.
| Walk vector ($\mathrm{m}$) | Dot product ($\mathrm{m}^2$) | Angle to marker |
|---|---|---|
| $(3,4)$ | $15$ | Below $90^\circ$ |
| $(0,4)$ | $0$ | Exactly $90^\circ$ |
| $(-3,4)$ | $-15$ | Above $90^\circ$ |
For two nonzero vectors, a zero dot product means they are perpendicular, so their directions meet at a right angle. The zero vector, whose components are all zero, also gives a dot product of zero with any vector. Its direction and the corresponding angle are undefined.
Finding a signed distance in metres requires dividing out the marker’s length.
A unit vector measures signed progress in metres#
A marker twice as far east would double the dot product for the same walk. To factor out the marker’s distance, divide each component of its nonzero vector by its magnitude. The result is a unit vector, an arrow with length 1 that points in the same direction. Write it as $\hat{\mathbf b}$, read as “b hat.”
Taking the dot product with this unit vector gives the scalar projection, the signed distance along the chosen direction. The marker’s length divides out, leaving the walk’s eastward component.
Figure 1 shows the same result on the map. The dashed line from the end of the walk lands at the 3-metre mark along the east axis.
Conclusion#
Use components to write each vector as changes along shared axes and the Pythagorean theorem to find its magnitude. Multiply matching components and add to compute the dot product. For two nonzero vectors, its sign tells you how the directions line up, and dividing by both magnitudes gives the cosine of their angle. Dividing by just the marker’s magnitude gives signed progress along its direction.
Try keeping the walk at $(3,4)$ and moving the marker to $(4,3)$, with both pairs measured in metres. Recalculate the dot product and check that the walk advances $4.8,\mathrm{m}$ along the new direction.