Projection onto a line
The orthogonal projection of a vector onto the span of a nonzero vector is the multiple whose difference from the original vector is perpendicular to that span.
On this page 8 sections
01Projection finds the part of a vector that points along a chosen line#
Projection finds the part of a vector that points along a chosen line. Imagine fitting a target vector using only one allowed direction. You may slide along that line, but cannot move sideways; projection chooses its closest point to the target.
The line span(u) passes through the origin. Its closest point to the tip of b defines the projected vector p. The gap from p to b is perpendicular to the line.
Use and . Their dot is 4; u·u=2. The coefficient is 4/2=2, so p=2u=(2,2).
For target and direction , compute and . Their ratio 3 is a coefficient. Multiply the entire direction by it to get projected vector . The leftover has dot product zero with , checking that no along-line correction remains.
, . Project b onto span(u).
Show answer and explanation
The coefficient is 8/2=4.
02Write p=cu#
Write p=cu. A perpendicular gap requires . Solving for c gives the rule, with :
, . Find c in the projection p=cu.
Show answer and explanation
c=6/4=1.5.
03The coefficient can be negative or zero#
The coefficient can be negative or zero. If b·u=0, then p=0. A projection can shorten a vector; it keeps b unchanged only when b already lies on the line. The zero vector cannot supply a line direction.
A rail allows multiples of . Desired . Closest allowed move?
Show answer and explanation
The coefficient is −6/4=−1.5.
04This is the geometry behind fitting a one-feature linear model with no intercept#
This is the geometry behind fitting a one-feature linear model with no intercept. The coefficient says how much of the allowed pattern to use; the projected vector contains the fitted outputs. Those two answers have different shapes and should not be interchanged.
Compute the coefficient, then scale the nonzero direction.
- Compute a complete projection vector onto a nonzero direction’s span