Splitting one vector along another
Projection answers a single question: how much of vector a points along the direction of vector b? The answer comes in two forms, and confusing them is the most common error in this topic.
The scalar projection - also called the component of a along b, written comp₋a - is a single signed number: the length of the shadow a casts on the line through b, positive when the shadow falls in the same direction as b and negative when it falls the other way.
The vector projection proj₋a is that same shadow written as a vector: it has the scalar projection's length and lies along b. It is what you subtract from a to get the part of a that has nothing to do with b.
Those two pieces together give the decomposition that makes projection useful:
a = proj₋a + (a − proj₋a)
The first term is entirely parallel to b, the second entirely perpendicular to it, and the split is unique. Every application of projection - resolving a force along and across an incline, separating a velocity into radial and tangential parts, removing a known direction from a data vector - is that one identity used in a particular context.
The formula, and why b appears twice
The two projections are
comp₋a = (a · b) / |b| and proj₋a = ((a · b) / |b|²) b
The vector version divides by |b|² rather than |b| because it then multiplies by b itself, which contributes another factor of |b| in length. Split it apart and the logic is obvious: (a·b)/|b| is the length you want, and b/|b| is the unit vector giving the direction. Multiply them and you get ((a·b)/|b|²)b. Writing |b| where |b|² belongs produces a vector whose length is wrong by a factor of |b|, and it is the single most frequent slip in this calculation.
Where does the dot product come from? Start from a·b = |a||b|cosθ. The shadow of a on the line of b has length |a|cosθ by simple trigonometry. Divide the identity by |b| and that is exactly what remains. So the scalar projection is |a|cosθ written in a form you can evaluate from coordinates without ever finding the angle.
Note what the formula does not depend on: the length of b. Scale b by any positive number and a·b scales the same way as |b|, so the ratio is unchanged. Only b's direction matters, which is why b is often called the direction vector. Reverse b, though, and the scalar projection changes sign, because the shadow now falls opposite to the reference direction.
The orthogonal component a⊥ = a − proj₋a is perpendicular to b by construction: take its dot product with b and you get a·b − (a·b/|b|²)(b·b) = a·b − a·b = 0. Because the two parts are perpendicular, their lengths obey Pythagoras: |a|² = (comp₋a)² + |a⊥|². The calculator prints that check on every run.
Worked example: a = (5, 6, 2) onto b = (3, 4, 0)
- Dot product. a · b = (5)(3) + (6)(4) + (2)(0) = 15 + 24 + 0 = 39.
- Squared length of b. |b|² = 9 + 16 + 0 = 25, so |b| = 5.
- Scalar projection. comp₋a = 39 / 5 = 7.8. Positive, so the shadow falls along b rather than against it.
- Scale factor. 39 / 25 = 1.56, so proj₋a = 1.56(3, 4, 0) = (4.68, 6.24, 0). Its length is 1.56 × 5 = 7.8, matching the scalar projection as it must.
- Orthogonal part. a − proj₋a = (5 − 4.68, 6 − 6.24, 2 − 0) = (0.32, −0.24, 2). Check perpendicularity: (0.32)(3) + (−0.24)(4) + (2)(0) = 0.96 − 0.96 = 0.
- Length of the orthogonal part. √(0.1024 + 0.0576 + 4) = √4.16 = 2.0396078.
Now the Pythagoras check. |a|² = 25 + 36 + 4 = 65. The two parts give 7.8² + 2.0396078² = 60.84 + 4.16 = 65. The decomposition accounts for the whole of a and nothing more.
This is exactly the arithmetic behind resolving a force on a ramp. If a is a force and b is the direction of the slope, then 7.8 is the component driving motion along the slope and 2.0396078 is the component pressing into the surface. Change the sign of b - point it down the ramp instead of up - and the scalar projection becomes −7.8 while the perpendicular magnitude stays the same, because the surface does not care which way you chose to call positive.
Reading the numbers
The sign of the scalar projection is the first thing to read. Positive means a and b make an acute angle and the projection points along b; negative means the angle exceeds 90° and the projection points along −b; zero means the two are perpendicular and a has no component along b at all. That single sign is often the whole answer in physics - it decides whether a force helps or resists a motion.
Compare the scalar projection with |a|. Their ratio is cos θ, so a projection of 7.8 out of a total length of 8.0622577 means the vectors are well aligned: 7.8 / 8.0622577 = 0.9674585, an angle of about 14.6°. A projection much smaller than |a| means most of a is doing something else.
The orthogonal magnitude is the residual - what is left of a once everything explicable by b has been removed. In least-squares fitting that residual is the error, and the whole method consists of choosing coefficients to make it as short as possible. In signal work it is the part of a signal not accounted for by a known component. Zero orthogonal magnitude means a is a multiple of b and carries no new direction.
One caution about units. The scalar projection carries the units of a, not of b - it is a length if a is a displacement, a force if a is a force. The vector projection likewise. Only the scale factor (a·b)/|b|² is a pure number, and even that is only dimensionless when a and b carry the same units.
The special cases at a glance
| Angle θ | cos θ | Scalar projection | Vector projection | Orthogonal magnitude |
|---|---|---|---|---|
| 0° | 1 | |a| | a itself | 0 |
| 30° | 0.8660 | 0.8660|a| | 0.8660|a| along b | 0.5|a| |
| 45° | 0.7071 | 0.7071|a| | 0.7071|a| along b | 0.7071|a| |
| 60° | 0.5 | 0.5|a| | 0.5|a| along b | 0.8660|a| |
| 90° | 0 | 0 | Zero vector | |a| |
| 120° | −0.5 | −0.5|a| | 0.5|a| along −b | 0.8660|a| |
| 180° | −1 | −|a| | −a | 0 |
Each row satisfies (scalar projection)² + (orthogonal magnitude)² = |a|², since cos²θ + sin²θ = 1. The orthogonal magnitude is |a| sin θ.
Mistakes to avoid
- Dividing by |b| instead of |b|² in the vector formula. The result then has the wrong length by a factor of |b|. It is correct only when b happens to be a unit vector, which is why the error survives so many worked examples.
- Projecting the wrong way round. proj₋a and proj₂b are different vectors with different lengths and different directions. The subscript names the direction you are projecting onto.
- Reporting a negative length. The scalar projection is signed and may be negative; the length of the vector projection is its absolute value. Both are useful, but they are not the same number.
- Assuming the orthogonal component is perpendicular to a. It is perpendicular to b. Only when a and b are themselves perpendicular does the orthogonal component equal a.
- Projecting onto a zero vector. There is no direction to project onto and the formula divides by zero. The calculator reports nothing rather than a misleading zero.
- Forgetting that projection loses information. The scalar projection alone cannot reconstruct a - infinitely many vectors share the same shadow. You need the orthogonal part as well, which is exactly why this calculator reports both.
Where projection leads
Work is the canonical application. A constant force F acting through a displacement d does work W = F · d = (compₔF)|d|: only the component of the force along the motion counts, and the perpendicular component does no work at all. That is why a centripetal force changes direction without changing speed, and why carrying a box across a level floor does no work against gravity.
In linear algebra, projection onto a single vector generalises to projection onto a subspace, and that generalisation is the entire content of least squares. Fitting a line to data means projecting the observation vector onto the column space of the design matrix; the residual you are minimising is precisely the orthogonal component computed here, one dimension at a time. Repeating the projection-and-subtract step across a set of vectors is the Gram-Schmidt process, which turns any basis into an orthogonal one and underlies QR factorisation.
The dot product does the work in all of these, so the dot product calculator is the natural companion page, and the angle between vectors is the same ratio read as an angle instead of a length. Where projection extracts the parallel part, the cross product measures the perpendicular part, with magnitude |a||b| sinθ - exactly |b| times the orthogonal magnitude reported here. For the matrix machinery that turns these ideas into a general solver, see the row reduction and eigenvector pages, since an eigenvector is precisely a direction whose projection under a transformation is itself.
