In Chapter 2.2, we used an orthonormal basis to split a vector into two perpendicular components. Now let’s focus on the component along a given line. This will let us answer questions such as: how much of a vehicle’s weight pulls it down a ramp?
Decomposing a vector into perpendicular components¶
Let be a line through the origin, and let be a vector in . We can split into two components:
where lies along and is perpendicular to .


The blue and orange components add to the original vector, shown in pink.
So . Here, is the line of vectors orthogonal to every vector on . We use this notation for a line through the origin.
Move the slider below to choose a vector along , where
The chosen vector and its error, drawn from its tip to the tip of , always add to :
Which choice makes the error perpendicular to ? At that position, the chosen vector is the projection , and the error is the perpendicular component .
The blue vector and orange error always add to the pink original vector. At , they are the perpendicular components and .
Finding the projection using a unit vector¶
Choose a unit vector along and a unit vector perpendicular to . Together, they form an orthonormal basis. By Chapter 2.2,
The first term lies along , and the second is perpendicular to . This identifies the projection:
Projecting onto ¶
Let’s project onto .
A direction vector along is , since . Its length is , so a unit vector along is
First, take the dot product:
Then multiply by the unit vector:


The projection of onto is .
Finding the projection without normalizing¶
The square roots canceled in the final answer. Can we avoid introducing them in the first place?
Let be any nonzero vector along . Substituting into the unit-vector formula gives
Let’s check this in the same example, using and :
This is exactly the result we found using a unit vector. This formula usually makes the computation easier: we can skip normalization, so the square roots it introduces typically go away. Any nonzero multiple of gives the same projection, even if it points in the opposite direction.
Finding the perpendicular component¶
Once we know the projection, we can find the other component by subtraction:
In our example,
This vector is perpendicular to the line because its dot product with the direction vector is zero:
The components also add back to the original vector:
We could also project directly onto . A unit vector along it is , so
Both methods give the same perpendicular component. Subtraction saves us from finding another unit vector.
A vehicle on a ramp¶
A vehicle with a weight of 1000 N is on a frictionless ramp. For every 4 meters of horizontal distance, the ramp rises 3 meters. A cable pulls the vehicle parallel to the ramp. How much force must the cable exert to keep the vehicle stationary?

The cable pulls uphill, the ramp pushes perpendicular to its surface, and gravity acts vertically downward.
The cable must exert 600 N up the ramp. To see why, we’ll resolve gravity into components parallel and perpendicular to the ramp.
Use horizontal–vertical coordinates, with positive pointing upward. The gravitational force is
The ramp’s direction comes from a 3–4–5 triangle, so a unit vector pointing uphill is
Let be the line through the origin parallel to the ramp. Projecting gravity onto this direction gives
The negative sign means this component points downhill, opposite to . Since has length one, the component has magnitude 600 N. The cable must balance it by pulling uphill:
We can get the same projection without normalizing, using :
The same 600 N cable force also lets the vehicle move at constant speed along the straight ramp, since the net force is zero.
Why doesn’t the vehicle move into the ramp?
What balances the rest of gravity? Its perpendicular component is
This component pushes into the ramp. The ramp supplies an equal and opposite normal force:
Because the ramp is frictionless, its contact force has no component along the ramp. The cable balances gravity along the ramp, while the normal force balances gravity perpendicular to it. Together,
The projection minimizes the error length¶
So far, we’ve found the projection by making the error perpendicular to the line. There is another way to describe that same vector: it is the vector on the line closest to the original vector.
Let’s work with a new example:
The projection is
Its error vector and error length are
Compare this with another vector on the line:
The projection has the shorter error. The picture shows the right triangle that explains why.

The orange error from the projection is perpendicular to the blue line. The dashed error from another point on the line is longer.
Finding the minimum directly¶
Every candidate on has the form
The squared error length is
The square is smallest when . At that value, the squared error is 18, the error length is , and the candidate is exactly the projection .
Why this always works¶
For any other vector on , the difference lies along the line, while is perpendicular to it. The Pythagorean theorem gives
Equality holds only when . Moving away from the projection along the line makes the error longer.