What the dot product measures
The dot product turns two vectors into one number, and that number measures alignment. Multiply matching components, add the results, and you have it: for (3, −1, 2) and (1, 4, 5) the sum is 3 − 4 + 10 = 9. There is no vector in the answer, which is why it is also called the scalar product.
The same number has a purely geometric description: |a||b| cos θ. Those two definitions look unrelated — one is bookkeeping over coordinates, the other is lengths and an angle — and the fact that they always agree is the central theorem about the operation. It is what lets you extract an angle from coordinates without ever drawing anything.
Read the sign first, because it carries most of the meaning. Positive means the angle is under 90° and the vectors broadly agree in direction. Zero means exactly 90°, perpendicular, with no component of one along the other. Negative means over 90° and broadly opposed. That three-way test is the reason the dot product appears in lighting models, in classifiers, in similarity search and in every projection formula you will meet.
Why the two formulas agree, and what follows from it
The bridge is the law of cosines. Take the triangle formed by a, b and a − b. The law of cosines says |a − b|² = |a|² + |b|² − 2|a||b| cos θ. Expand the left side using the component definition and the cross terms collapse to −2(a · b). Comparing the two expressions gives a · b = |a||b| cos θ directly. No geometry is assumed beyond the law of cosines itself.
Three consequences do most of the work in practice.
Length from the product with itself. a · a = |a|² cos 0 = |a|², so |a| = √(a · a). Length is not a separate idea; it falls out of the dot product.
Angles without drawing. Rearranging gives cos θ = (a · b)/(|a||b|), which works in any number of dimensions. This is exactly the cosine similarity used to compare documents or embeddings, where the vectors have thousands of components and no picture is available.
Projection. The scalar projection of a onto b is (a · b)/|b|, the signed length of the shadow a casts along b's direction. Multiply by the unit vector along b and you get the vector projection, which is how any vector is split into a part along a given direction and a perpendicular remainder — the operation behind least squares, Fourier coefficients and Gram-Schmidt.
The Cauchy-Schwarz inequality |a · b| ≤ |a||b| is the guarantee that cos θ never leaves [−1, 1], and it holds with equality exactly when the vectors are parallel or antiparallel.
Worked example: a = (3, −1, 2) and b = (1, 4, 5)
- Multiply matching components. 3 × 1 = 3, then (−1) × 4 = −4, then 2 × 5 = 10.
- Add them. 3 − 4 + 10 = 9. That is the dot product. It is positive, so the angle is under 90°.
- Length of a. √(3² + (−1)² + 2²) = √(9 + 1 + 4) = √14 = 3.7416574.
- Length of b. √(1² + 4² + 5²) = √(1 + 16 + 25) = √42 = 6.4807407.
- Cosine. 9 / (3.7416574 × 6.4807407) = 9 / 24.2487113 = 0.3711537. Note that √14 × √42 = √588 = 24.2487113, so the product of the lengths can be taken in one square root.
- Angle. arccos(0.3711537) = 68.2132°.
- Scalar projection of a onto b. 9 / 6.4807407 = 1.3887301. So a reaches 1.39 units along the direction of b, against its own total length of 3.74 — most of a points somewhere else.
Sanity-check the cosine against Cauchy-Schwarz: 0.371 lies comfortably inside [−1, 1], as it must. And check the projection differently: the vector projection is 1.3887301 × (1, 4, 5)/6.4807407 = (0.2142857, 0.8571429, 1.0714286), whose length is 1.3887301 again ✓.
How to read the numbers
The sign is the headline. Positive, zero, negative maps onto acute, right, obtuse. In a lighting calculation, a negative dot product between a surface normal and the direction to the light means the surface faces away and receives nothing. In a classifier, the sign of w · x is the decision.
The cosine is the scale-free version. The raw dot product grows with both lengths, so it cannot be compared across different pairs. Dividing by |a||b| gives a number in [−1, 1] that depends only on direction, which is why cosine similarity rather than the raw product is what search and recommendation systems use.
The scalar projection has the units of a, not of a·b. Dividing by |b| cancels b's units, leaving a length along b's direction. It is negative when the angle exceeds 90°, meaning the shadow falls on the far side of the origin, and it is exactly |a| when the vectors are parallel.
Zero is a genuine verdict, not a failure. Orthogonality is the most useful special case in the subject: it is what makes a basis convenient, what makes a residual independent of the fit, and what makes the Pythagorean identity |a + b|² = |a|² + |b|² hold.
How the dot product varies with the angle
| Angle θ | cos θ | Relationship | a · b for unit vectors |
|---|---|---|---|
| 0° | 1 | Parallel, same direction | 1 |
| 30° | 0.866025 | Strongly aligned | 0.866025 |
| 45° | 0.707107 | Aligned | 0.707107 |
| 60° | 0.5 | Weakly aligned | 0.5 |
| 90° | 0 | Orthogonal | 0 |
| 120° | −0.5 | Weakly opposed | −0.5 |
| 135° | −0.707107 | Opposed | −0.707107 |
| 180° | −1 | Antiparallel | −1 |
For the worked example the cosine is 0.371154, which sits between the 60° and 90° rows — consistent with the computed angle of 68.2132°.
Mistakes worth avoiding
- Expecting a vector back. The dot product is a single number. If you wanted a vector perpendicular to both inputs, that is the cross product.
- Dotting vectors of different lengths. The sum Σ aᵢbᵢ has no meaning when the two lists differ in length; the operation is defined only within one vector space. The calculator refuses and says which counts failed to match.
- Comparing raw dot products across pairs. A product of 100 between long vectors can mean less alignment than a product of 2 between short ones. Normalise to the cosine before comparing.
- Reading a zero as an error. Zero is the orthogonality verdict, and it is the single most useful value the operation returns.
- Assuming cancellation. a · b = a · c does not imply b = c. The two may differ by any vector perpendicular to a, which is a whole subspace of possibilities.
- Forgetting the zero vector. It has a dot product of zero with everything and no direction of its own, so no angle exists. By convention it is counted as orthogonal to every vector, which keeps the theorems tidy.
Work is a dot product
The work done by a constant force is W = F · d, and the cos θ factor is the physics: only the component of the force along the displacement does any work. Push a trolley horizontally and all of your force counts; push down on it as you walk and none of that downward component does. Carry a suitcase along a level corridor and the work you do against gravity is exactly zero, because the vertical force and the horizontal displacement are orthogonal — a result that feels wrong to tired arms but is what the mathematics says.
Related tools
The complementary operation is the cross product, which returns a vector perpendicular to both inputs and is largest exactly where the dot product is smallest. Together they pin down the geometry of a pair: the dot product supplies |a||b|cos θ and the cross product |a||b|sin θ.
If the angle is the whole point, the angle between vectors calculator gives it directly. If you want the projection as a vector rather than a length, together with the perpendicular remainder, use the vector projection calculator.
The dot product is also the atom of matrix arithmetic: entry (i, j) of a matrix product is the dot product of row i with column j, which the matrix multiplication calculator spells out term by term. In multivariable calculus, the directional derivative is the dot product of the gradient with a unit direction, so the rate of change along a direction is literally the alignment between that direction and the gradient found by the partial derivative calculator.
