A force pushing a sled up a slope does two things at once: part of it moves the sled along the slope, and part of it presses the sled into the slope. Splitting the force into those two parts — one along a direction, one across it — is the operation this section builds. Given a vector and a nonzero direction , we want with a multiple of and orthogonal to . The part along is called the projection of onto ; its tip is the foot of the perpendicular dropped from the tip of onto the line through .
The figure lives in the plane, where a right angle is a right angle from every viewpoint. The direction is fixed, the line of its multiples is dashed, and is on two sliders.
Interactive figureThe projection of v onto the line through dDrag the v, x-component and v, y-component sliders.
XYZ Graph · viewer build 5edf91b
The direction and the vector in red. The blue arrow along the dashed line is the projection of onto ; the dashed green arrow from its tip to the tip of is the perpendicular part, and the two add back to .
Explore the figure
At the starting values , the blue projection is exactly , and the green perpendicular part runs from to : head minus tail gives . Check the right angle by the last section's test: .
Drag to . The red vector now points below the line, and the projection shrinks to — three tenths of . The perpendicular part drops from the line downward.
Set and . The red vector is perpendicular to and the blue arrow vanishes: the projection is the zero vector, and the perpendicular part is all of .
Set and , so that . Now the green arrow vanishes instead: a vector already on the line is its own projection.
Sweep across its range with fixed and watch the blue foot slide along the line. Whatever the red tip does, the green arrow meets the dashed line at a right angle. That right angle is the definition, and the formula below is what it forces.
Solving for the scalar
The parallel part is some multiple ; the whole problem is finding . Dot both sides of with :
The perpendicular part contributed nothing, because it is orthogonal to — that is the only thing we asked of it, and it is enough. So , and
At the figure's starting values, and , so and the projection is itself, as step 1 found. Notice that replacing by multiplies the numerator by and the denominator by , and the extra factor of restores the balance: the projection depends on the line, not on which vector along it was chosen to name the direction.
For the fixed direction the formula is a recipe with two inputs, and , and two outputs. Writing it out, and the projection is — each output a fixed combination of the inputs. That is exactly what a matrix does, and Chapter 3 will call the array of coefficients, with rows and , the projection matrix. It appears below as a machine check on step 1.
The projection at the figure's starting values ✓ Computed · mojocas 0.1.0✓ Agrees with the text The projection at the figure's starting values, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The projection recipe for the direction , written as the matrix with rows and and applied by a computer algebra system to : the output is , the direction vector itself, as step 1 observed.
A projection onto a line has rank 1 ✓ Computed · mojocas 0.1.0✓ Agrees with the text A projection onto a line has rank 1, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The same array with its common factor removed. Its rank is : every output of the recipe lies on one line, the dashed line of the figure. Chapter 3 reads this number as the dimension of everything a matrix can reach.
The projection at the figure's starting values ✓ Computed · mojocas 0.1.0✓ Agrees with the text The projection at the figure's starting values, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The figure's own numbers, computed by the projection op rather than by the matrix above: , which is itself — step 1's observation, certified.
And the perpendicular part ✓ Computed · mojocas 0.1.0✓ Agrees with the text And the perpendicular part, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The other half of the same split, asked for by name. The engine returns , the dashed arrow of step 1, and the two parts add back to .
The right angle that forces the formula ✓ Computed · mojocas 0.1.0✓ Agrees with the text The right angle that forces the formula, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The perpendicular part dotted with the direction. Zero — which is not a happy accident but the single condition the derivation solved for, and the reason the whole formula has one unknown.
The worked example's parallel part ✓ Computed · mojocas 0.1.0✓ Agrees with the text The worked example's parallel part, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The vector from to projected onto the line's direction: .
Its perpendicular part ✓ Computed · mojocas 0.1.0✓ Agrees with the text Its perpendicular part, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
What is left over: .
And the distance to the line ✓ Computed · mojocas 0.1.0✓ Agrees with the text And the distance to the line, computed exactly by mojocas 0.1.0, and confirmed to agree with the result stated in the text.
The length of that leftover, which is the distance from to the line: . The engine writes it with the root in the numerator; the prose writes the same number as , and stating either one certifies against the other because the check is by value, not by spelling.
An original work of XYZ Homework, built around interactive XYZ 3D figures. Its chapter sequence is aligned to Interactive Linear Algebra (Margalit & Rabinoff, Georgia Tech, GNU FDL); this work is original, copies nothing from it, and is not affiliated with or endorsed by its authors. License: CC-BY-NC-SA-4.0.
These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.