"How much of v points in u's direction" is a question with an exact answer. It's a formula, not a guess, and it's the same question a Fourier coefficient answers about a function instead of a vector. Getting the projection formula solid here, in the plain vector setting, pays off directly in chapter 5. There, "a Fourier coefficient IS a projection" clicks as recognition, not as a fresh idea learned from scratch.
Picture v as a stick lying at some angle above a flat table, one end pinned to the origin. Shine a light straight down onto the table, directly overhead, not off to one side. The stick casts a shadow along whichever direction u marks out on the table. That shadow, as a vector, is \operatorname{proj}_u v. The leftover piece, the part of the stick standing straight up off the table, is the residual. It has to meet the table at a perfect right angle, the same way a stick's height above a flat table is always measured straight up, never on a slant.
The trap sits in checking that right angle against the wrong thing. "Perpendicular to u" means the leftover piece is perpendicular to u. It does not mean v itself is, and it does not mean the leftover piece is perpendicular to v. Dot the residual against v instead of against u, and the result generally isn't 0 at all, even when the projection was computed correctly. The perpendicularity the formula actually guarantees holds specifically between the residual and the direction being projected onto.
The orthogonal projection of v onto u (for u \ne \mathbf 0) is the vector along u's own direction that comes closest to v: \operatorname{proj}_u v = \left(\frac{v\cdot u}{u \cdot u}\right)u = \left(\frac{v\cdot u}{\lVert u\rVert^2}\right)u. Subtracting it off leaves the residual (or orthogonal component), w = v - \operatorname{proj}_u v. The defining property of a projection is that this residual is always perpendicular to u: w\cdot u = 0. That single perpendicularity fact is what makes the projection formula the closest point on u's line to v, not merely a point on it. Any other point on the line differs from v by a vector with a nonzero component along u, and the Pythagorean theorem shows that only ever makes the distance larger.
The same idea generalizes from a line to a whole subspace W. Every vector v decomposes uniquely as v = \hat v + z with \hat v \in W and z perpendicular to every vector in W: the Orthogonal Decomposition Theorem, recalled below. Computing \hat v is no harder than the single-vector case, once W has an orthogonal basis \{u_1,\dots,u_p\}. Project onto each basis vector separately and add the results, \hat v = \operatorname{proj}_{u_1}v + \cdots + \operatorname{proj}_{u_p}v. The cross-terms that would otherwise complicate this sum all vanish, because the basis vectors are pairwise orthogonal.
Formula
Vector Projection
also known as: the shadow one vector casts onto another
Recalled from College Algebra · Dot product and projection — first taught there.
For vectors \mathbf{u} and \mathbf{v} with \mathbf{u} \neq \mathbf{0}, the projection of \mathbf{v} onto \mathbf{u} is
\text{proj}_{\mathbf{u}}\mathbf{v} = \left(\frac{\mathbf{v}\cdot\mathbf{u}}{|\mathbf{u}|^2}\right)\mathbf{u}.Drop a perpendicular from the tip of \mathbf{v} down onto the line through \mathbf{u}; this forms a right triangle with hypotenuse |\mathbf{v}| and angle \theta between \mathbf{u} and \mathbf{v}. Exactly as in Chapter 8, the leg lying along \mathbf{u}'s line — the scalar projection — has length |\mathbf{v}|\cos\theta (adjacent equals hypotenuse times cosine). From the theorem above, \cos\theta = \frac{\mathbf{u}\cdot\mathbf{v}}{|\mathbf{u}|\,|\mathbf{v}|}, so the scalar projection simplifies to
|\mathbf{v}|\cos\theta = |\mathbf{v}|\cdot\frac{\mathbf{u}\cdot\mathbf{v}}{|\mathbf{u}|\,|\mathbf{v}|} = \frac{\mathbf{u}\cdot\mathbf{v}}{|\mathbf{u}|}.The vector projection points along \mathbf{u}'s own direction, so multiply this scalar length by the unit vector \frac{\mathbf{u}}{|\mathbf{u}|}:
\text{proj}_{\mathbf{u}}\mathbf{v} = \frac{\mathbf{u}\cdot\mathbf{v}}{|\mathbf{u}|}\cdot\frac{\mathbf{u}}{|\mathbf{u}|} = \frac{\mathbf{u}\cdot\mathbf{v}}{|\mathbf{u}|^2}\mathbf{u}.Theorem
The Orthogonal Decomposition Theorem
Recalled from Linear Algebra — Vectors, Matrices, and the Geometry of Data · The orthogonal decomposition theorem — first taught there.
Let W be a subspace of \mathbb{R}^n. Every vector \mathbf{y} \in \mathbb{R}^n can be written uniquely as
\mathbf{y} = \hat{\mathbf y} + \mathbf{z}, \qquad \hat{\mathbf y} \in W, \quad \mathbf{z} \in W^\perp,where \hat{\mathbf y} = \operatorname{proj}_W \mathbf{y}.
Existence. Let \{\mathbf{u}_1, \dots, \mathbf{u}_p\} be an orthogonal basis for W (one always exists, by Gram–Schmidt if no other is in hand). Define
\hat{\mathbf y} = \frac{\mathbf{y}\cdot\mathbf{u}_1}{\mathbf{u}_1\cdot\mathbf{u}_1}\mathbf{u}_1 + \cdots + \frac{\mathbf{y}\cdot\mathbf{u}_p}{\mathbf{u}_p\cdot\mathbf{u}_p}\mathbf{u}_p, \qquad \mathbf{z} = \mathbf{y} - \hat{\mathbf y}.Each term of \hat{\mathbf y} is a scalar multiple of some \mathbf{u}_i \in W, and W is closed under linear combinations, so \hat{\mathbf y} \in W outright — no further check needed there. The work is showing \mathbf{z} \in W^\perp, and for that it suffices to show \mathbf{z} is orthogonal to every basis vector \mathbf{u}_i, since orthogonality to a spanning set of W forces orthogonality to all of W. Fix i and compute \mathbf{z}\cdot\mathbf{u}_i, using that \mathbf{u}_i\cdot\mathbf{u}_j = 0 for j \ne i (orthogonality of the basis) so every term of \hat{\mathbf y} except the i-th drops out of the dot product:
\mathbf{z}\cdot\mathbf{u}_i = \mathbf{y}\cdot\mathbf{u}_i - \frac{\mathbf{y}\cdot\mathbf{u}_i}{\mathbf{u}_i\cdot\mathbf{u}_i}(\mathbf{u}_i\cdot\mathbf{u}_i) = \mathbf{y}\cdot\mathbf{u}_i - \mathbf{y}\cdot\mathbf{u}_i = 0.So \mathbf{z} \perp \mathbf{u}_i for every i, hence \mathbf{z} \in W^\perp, and \mathbf{y} = \hat{\mathbf y} + \mathbf{z} is a decomposition of the required form. That \hat{\mathbf y} is exactly \operatorname{proj}_W\mathbf{y} is just the definition of the projection onto W built from an orthogonal basis of W.
Uniqueness. Suppose \mathbf{y} also decomposes as \mathbf{y} = \hat{\mathbf y}' + \mathbf{z}' with \hat{\mathbf y}' \in W and \mathbf{z}' \in W^\perp. Subtracting the two decompositions of \mathbf{y} gives
\hat{\mathbf y} - \hat{\mathbf y}' = \mathbf{z}' - \mathbf{z}.The left side lies in W, since W is a subspace and both \hat{\mathbf y}, \hat{\mathbf y}' \in W; the right side lies in W^\perp for the same reason applied to \mathbf{z}, \mathbf{z}' \in W^\perp. So this common vector belongs to W \cap W^\perp. But a vector orthogonal to every vector in W — including itself, if it lies in W — must have zero length: taking \mathbf{v} = \hat{\mathbf y} - \hat{\mathbf y}' as that vector, \mathbf{v} \in W and \mathbf{v} \in W^\perp together force \mathbf{v}\cdot\mathbf{v} = 0, so \mathbf{v} = \mathbf{0}. Hence \hat{\mathbf y} = \hat{\mathbf y}' and, from the subtracted equation, \mathbf{z} = \mathbf{z}' as well. The decomposition is unique.
Sanity check: take W = \operatorname{span}\{(1,0,0),(0,1,0)\}, the xy-plane inside \mathbb{R}^3, and \mathbf{y} = (2,3,5). The orthogonal basis \{(1,0,0),(0,1,0)\} gives \hat{\mathbf y} = (2,3,0) and \mathbf{z} = (0,0,5), which is indeed orthogonal to both basis vectors — exactly the geometrically obvious split of \mathbf{y} into its in-plane part and its part along the perpendicular z-axis.
A first look: the shadow of v along u
Drag u or v. The green shadow is v's projection onto u's direction.
Loading interactive…
Recipe Find the orthogonal projection of one vector onto another Use when: you have a nonzero vector u and any vector v, and need the piece of v that lies exactly along u's own direction Goal: the projection vector \operatorname{proj}_u v, and if asked, confirmation that the leftover residual is perpendicular to u
Quick recipe
-
1
Multiply matching components of v and u and add them for v\cdot u; do the same with u against itself for u\cdot u.
Example
For u=(2,-1) and v=(3,4): v\cdot u = (3)(2)+(4)(-1) = 2, and u\cdot u = 2^2+(-1)^2=5.
- u is the nonzero vector being projected onto — continue normally; u\cdot u is guaranteed positive.
- u is the zero vector — the projection is undefined, since there's no direction to measure "along."
Why: the projection formula divides by u\cdot u, so it only makes sense once u genuinely points somewhere.
-
2
Divide v\cdot u by u\cdot u. That single number says how many multiples of u the shadow reaches.
Example
\dfrac{v\cdot u}{u\cdot u} = \dfrac{2}{5}.
Why: this ratio is exactly the coefficient the Orthogonal Decomposition Theorem needs to build the closest point on u's line.
-
3
Scale u by the fraction from Step 2, one component at a time.
Example
\operatorname{proj}_u v = \frac25(2,-1) = \left(\frac45,-\frac25\right).
⚡ Shortcut
If v is already a scalar multiple of u, skip the arithmetic: \operatorname{proj}_u v = v itself, since the whole vector already lies on u's line. If v is already perpendicular to u (so v\cdot u=0), skip straight to \operatorname{proj}_u v = \mathbf 0, since there's no shadow to cast at all.
Why: the projection is required to lie on u's line, meaning it must be some scalar multiple of u; Step 2 found exactly which multiple.
-
4
Subtract the projection from v to get the residual w=v-\operatorname{proj}_uv, then dot w specifically with u and confirm it comes out to 0.
Example
w = \left(3-\frac45,\ 4+\frac25\right) = \left(\frac{11}{5},\frac{22}{5}\right), and w\cdot u = \left(\frac{11}{5}\right)(2)+\left(\frac{22}{5}\right)(-1) = \frac{22}{5}-\frac{22}{5}=0.
- w\cdot u = 0 — the projection is verified correct.
- w\cdot u \ne 0 — an arithmetic error happened upstream; redo Steps 1 through 3.
Why: perpendicularity to u specifically, not to v, is the defining property that makes this the closest point on u's line to v.
Common mistakes
- Dotting the residual against v instead of against u when checking perpendicularity.
- Writing \lVert u\rVert where the formula actually needs u\cdot u, which is \lVert u\rVert^2.
- Assuming v itself must be perpendicular to u whenever a projection is asked for.
- Trying to project onto the zero vector without checking u is nonzero first.
Worked example
Computing a projection directly
-
1
Find \operatorname{proj}_u v for u = (4,1) and v=(2,3), running Steps 1 through 3 of the recipe above on a fresh pair of vectors.
-
2
v\cdot u = (2)(4)+(3)(1) = 11, and u\cdot u = 4^2+1^2 = 17.
-
3\operatorname{proj}_u v = \frac{11}{17}(4,1) = \left(\frac{44}{17}, \frac{11}{17}\right).
-
4
\boxed{\operatorname{proj}_u v = \left(\tfrac{44}{17},\tfrac{11}{17}\right)}, approximately (2.59, 0.65). The same shadow the widget above draws for these exact vectors.
The residual is always perpendicular to u, for ANY u,v
Drag u and v around freely. The small right-angle mark at the shadow's tip never disappears.
Loading interactive…
Worked example
Confirming the residual is perpendicular, to the right vector
-
1
Using u=(4,1), v=(2,3), and \operatorname{proj}_u v= \left(\tfrac{44}{17},\tfrac{11}{17}\right) from above, verify the residual is perpendicular to u, exactly Step 4 of the recipe above.
Common trap. The residual has to be dotted against u, the direction being projected onto, not against v.
-
2w = v - \operatorname{proj}_u v = \left(2-\tfrac{44}{17},\ 3-\tfrac{11}{17}\right) = \left(-\tfrac{10}{17},\ \tfrac{40}{17}\right).
-
3w\cdot u = \left(-\tfrac{10}{17}\right)(4) + \left(\tfrac{40}{17}\right)(1) = -\tfrac{40}{17}+\tfrac{40}{17} = 0.
-
4
\boxed{w\cdot u = 0}, confirmed. Dotting w against v instead gives w\cdot v = -\tfrac{20}{17}+\tfrac{120}{17} = \tfrac{100}{17} \ne 0. That proves nothing wrong. That dot product was simply never claimed to be zero in the first place.
Two special cases worth noticing
Drag v until it lies exactly along u's line. Then drag it until the two arrows form a right angle.
Loading interactive…
Worked example
Two edge cases of the same formula
-
1
Find \operatorname{proj}_u v when (a) v is already a scalar multiple of u, say u=(3,0), v=(6,0); and (b) v is already perpendicular to u, say u=(3,0), v=(0,3).
Special case. Both edge cases can be checked against the formula directly rather than trusted on intuition alone. Both are exactly the Step 3 shortcut named in the recipe above.
-
2
(a) v\cdot u = 18, u\cdot u=9, so \operatorname{proj}_uv = \frac{18}{9}(3,0)=(6,0)=v itself. Projecting a vector onto its own direction changes nothing, since the entire vector already points that way.
-
3
(b) v\cdot u = 0, so \operatorname{proj}_uv = \frac{0}{9}(3,0) = (0,0). A vector perpendicular to u has no shadow along u at all.
-
4
\boxed{(a)\ \operatorname{proj}_uv=v; \quad (b)\ \operatorname{proj}_uv=\mathbf 0}. These are the two extremes the formula has to reproduce correctly, with nothing in between changing the underlying computation.
Loading interactive…
Where this goes next
Fourier coefficients as projections, chapter 5
Chapter 5 reframes the entire Fourier coefficient computation from chapter 3 as exactly this. Each complex Fourier coefficient is the projection of the function being expanded onto the "direction" e^{in\theta} inside an infinite-dimensional inner product space. It's computed with precisely the formula above, \frac{\langle f, e^{in\theta}\rangle}{\langle e^{in\theta},e^{in\theta}\rangle}, with dot products replaced by the integral inner product from the previous section. Nothing else is different.
Check your understanding (counts toward your progress)
For u=(1,0) and v=(3,4), find the x-component of \operatorname{proj}_u v.
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
\operatorname{proj}_uv = \frac{v\cdot u}{u\cdot u}u = \frac{3}{1}(1,0) = (3,0) — u=(1,0) points along the x-axis, so the projection just keeps v's x-component, and its y-component is forced to 0.
Correct answer
Also accepted:
Why
Using the same u,v as above, find the y-component of the residual v-\operatorname{proj}_uv.
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
v-\operatorname{proj}_uv = (3,4)-(3,0) = (0,4), so the y-component is 4 — none of v's y-part lay along u, so all of it survives in the residual.
Correct answer
Also accepted:
Why
Find \operatorname{proj}_uv first, then subtract it from v component by component.
The residual from a projection is guaranteed to be perpendicular to which vector?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
The residual isn't generally perpendicular to v itself — only to the direction v was projected onto.
Only the relationship with u is guaranteed by the projection formula.
Why
The defining property of \operatorname{proj}_uv is that v-\operatorname{proj}_uv is perpendicular to u — that's what makes it the closest point on u's line to v.
Think about which vector defines the LINE the projection lands on — the residual is perpendicular to that line.
Practice: Projecting onto a line, then onto a whole subspace (4 problems · doesn’t affect your progress)
For u=(0,3) and v=(4,-6), find the y-component of \operatorname{proj}_u v.
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
v\cdot u = (4)(0)+(-6)(3) = -18 and u\cdot u = 9, so \operatorname{proj}_uv = \frac{-18}{9}(0,3) = (0,-6) — u points straight along the y-axis, so the projection just keeps v's y-component.
Correct answer
Also accepted:
Why
If v is already perpendicular to u, what is \operatorname{proj}_uv?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
That's the OTHER edge case — when v already lies along u's own direction, not when it's perpendicular to it.
The projection always lands somewhere on u's line, but there's no reason it should equal u specifically.
Why
When v\cdot u=0, the projection formula's numerator is 0, so \operatorname{proj}_uv=\mathbf 0 — a vector perpendicular to u has no shadow along u at all.
\mathbf 0
Let W have orthogonal basis u_1=(1,0,0) and u_2=(0,1,0). For v=(3,4,5), find the z-component of \hat v = \operatorname{proj}_{u_1}v+\operatorname{proj}_{u_2}v.
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
Why
Projecting onto u_1 and u_2 only ever recovers multiples of (1,0,0) and (0,1,0) — neither basis vector has a z-component, so \hat v's z-component is forced to 0; all of v's z-part ends up in the residual instead.
Correct answer
Also accepted:
Why
For u=(1,1) and v=(3,1), is the residual w=v-\operatorname{proj}_uv perpendicular to v itself?
Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.
The defining property only ever guarantees w\cdot u=0 — dotting w against v instead generally gives something nonzero.
Why
The projection formula guarantees the residual is perpendicular to u, the direction being projected onto — nothing guarantees perpendicularity to v itself.
No — the residual is only guaranteed perpendicular to u