← All lessons

Math · 5 min · Interactive lesson

Why is the dot product connected to projection?

  • Linear algebra

Rotate a vector and watch its shadow change. Discover what the dot product measures, and when it equals a projection.

Imagine a vector a pointing diagonally and a vector b pointing horizontally. Shine a light perpendicular to b: a casts a shadow onto the line along b. That shadow is its vector projection.

The dot product is closely related, but it gives a number, not a vector. Let’s see exactly what that number measures.

How much of the length falls along b?

Keep a at length 10 and rotate it. Its signed projection onto the direction of b is:

p=∥a∥cos⁡θp = \|\mathbf a\|\cos\theta

The cosine converts the vector’s total length into the amount pointing along the chosen direction. Try 60°, then 90°, then 180°.

Rotate a. Watch its shadow.
Vector a projected onto the horizontal direction of bAt 20.00 degrees, a has length 10 and signed projection 9.40. Vector b has length 1. The dot product is 9.40. Vector b is drawn below the projection line for visibility, at the same scale.-10-50510ab

Blue: vector aGreen: projectionOrange: vector b

b points right and is drawn below the line for visibility. Both vectors use the same scale.

Signed projection9.40‖a‖ cos θ
Dot product9.40projection × ‖b‖
Projection vector(9.40, 0)on the horizontal line

The projection is positive: part or all of a points in the direction of b. Since b is a unit vector, the dot product equals the signed projection.

At 0°, all 10 units point along b. At 60°, only 5 do. At 90°, the projection is zero even though a still has length 10. At 180°, it is −10: the vector points entirely in the opposite direction.

The projection falls on the line through b, so it can extend beyond the tip of b or point backward.

Where the dot product comes in

The dot product multiplies the signed projection length by the length of b:

a⋅b=∥a∥∥b∥cos⁡θ=p∥b∥\mathbf a\cdot\mathbf b = \|\mathbf a\|\|\mathbf b\|\cos\theta = p\|\mathbf b\|

When b is a unit vector (∥b∥=1\|\mathbf b\|=1), the dot product equals the signed projection length. Change Length of b from 1 to 2 in the explorer. The shadow stays in place, but the dot product doubles.

For a concrete example, select a = (3, 4). With b=(1,0)\mathbf b=(1,0):

a⋅b=3(1)+4(0)=3\mathbf a\cdot\mathbf b=3(1)+4(0)=3

Now set the length of b to 2, so b=(2,0)\mathbf b=(2,0):

a⋅b=3(2)+4(0)=6\mathbf a\cdot\mathbf b=3(2)+4(0)=6

The signed projection length is still 3, and the projection vector is still (3, 0). Only the dot product changed.

For a nonzero reference vector b:

QuantityFormulaWhat you get
Dot producta⋅b\mathbf a\cdot\mathbf bSigned projection length multiplied by ∥b∥\|\mathbf b\|
Scalar projectiona⋅b∥b∥\dfrac{\mathbf a\cdot\mathbf b}{\|\mathbf b\|}Signed length along b
Vector projectiona⋅b∥b∥2b\dfrac{\mathbf a\cdot\mathbf b}{\|\mathbf b\|^2}\mathbf bA vector on the line through b

If b is the zero vector, the dot product is zero, but projection onto its direction is undefined: it has no direction to project onto.

Coordinates are projections, too

The horizontal coordinate of (3,4)(3,4) is 3 because its dot product with the horizontal unit vector (1,0)(1,0) is 3. Its vertical coordinate is 4 because its dot product with (0,1)(0,1) is 4.

More generally, in an orthonormal basis (perpendicular unit vectors), each coordinate is a dot product:

ai=a⋅eia_i = \mathbf a\cdot\mathbf e_i

Choosing a different orthonormal basis means measuring the same vector along different directions. This is the geometry behind the projection steps in PCA and SVD.

Why this matters for a neuron

A neuron’s weighted sum w⋅x\mathbf w\cdot\mathbf x measures the signed projection of the input x onto the weight direction w, scaled by ∥w∥\|\mathbf w\|. A bias shifts that result, and an activation function transforms it.

For inputs of the same length, stronger alignment with w gives a larger weighted sum. That’s the geometric sense in which a neuron can detect a direction in its input space.

Takeaway: the angle controls how much of one vector falls along another direction. The dot product measures that amount, scaled by the reference vector’s length.

Keep learning

To see how a matrix uses dot products to produce each output coordinate, continue with Dot products: building the output one row at a time.