Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

2.3: Orthogonal projections

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 ℓ\ell be a line through the origin, and let w⃗\vec w be a vector in R2\mathbb R^2. We can split w⃗\vec w into two components:

w⃗=w⃗∥+w⃗⊥,\vec w=\vec w_{\parallel}+\vec w_{\perp},

where w⃗∥\vec w_{\parallel} lies along ℓ\ell and w⃗⊥\vec w_{\perp} is perpendicular to ℓ\ell.

Image produced in Jupyter
Image produced in Jupyter

The blue and orange components add to the original vector, shown in pink.

So w⃗∥=proj⁡ℓ(w⃗)\vec w_{\parallel}=\operatorname{proj}_{\ell}(\vec w). Here, ℓ⊥\ell^\perp is the line of vectors orthogonal to every vector on ℓ\ell. We use this notation for a line through the origin.

Move the slider below to choose a vector tv⃗1t\vec v_1 along ℓ\ell, where

w⃗=[89],v⃗1=[32],ℓ:2x−3y=0.\vec w=\begin{bmatrix}8\\9\end{bmatrix},\qquad \vec v_1=\begin{bmatrix}3\\2\end{bmatrix},\qquad \ell:2x-3y=0.

The chosen vector and its error, drawn from its tip to the tip of w⃗\vec w, always add to w⃗\vec w:

tv⃗1+(w⃗−tv⃗1)=w⃗.t\vec v_1+(\vec w-t\vec v_1)=\vec w.

Which choice makes the error perpendicular to ℓ\ell? At that position, the chosen vector is the projection w⃗∥\vec w_{\parallel}, and the error is the perpendicular component w⃗⊥\vec w_{\perp}.

Loading...

The blue vector and orange error always add to the pink original vector. At t=42/13t=42/13, they are the perpendicular components w⃗∥\vec w_{\parallel} and w⃗⊥\vec w_{\perp}.


Finding the projection using a unit vector

Choose a unit vector u⃗1\vec u_1 along ℓ\ell and a unit vector u⃗2\vec u_2 perpendicular to ℓ\ell. Together, they form an orthonormal basis. By Chapter 2.2,

w⃗=(w⃗⋅u⃗1)u⃗1+(w⃗⋅u⃗2)u⃗2.\vec w=(\vec w\cdot\vec u_1)\vec u_1+(\vec w\cdot\vec u_2)\vec u_2.

The first term lies along ℓ\ell, and the second is perpendicular to ℓ\ell. This identifies the projection:

Projecting onto 2x−3y=02x-3y=0

Let’s project w⃗=[89]\vec w=\begin{bmatrix}8\\9\end{bmatrix} onto ℓ:2x−3y=0\ell:2x-3y=0.

A direction vector along ℓ\ell is v⃗1=[32]\vec v_1=\begin{bmatrix}3\\2\end{bmatrix}, since 2(3)−3(2)=02(3)-3(2)=0. Its length is 32+22=13\sqrt{3^2+2^2}=\sqrt{13}, so a unit vector along ℓ\ell is

u⃗1=v⃗1∥v⃗1∥=[3/132/13].\vec u_1=\frac{\vec v_1}{\lVert\vec v_1\rVert}=\begin{bmatrix}3/\sqrt{13}\\2/\sqrt{13}\end{bmatrix}.

First, take the dot product:

w⃗⋅u⃗1=8(313)+9(213)=4213.\vec w\cdot\vec u_1=8\left(\frac3{\sqrt{13}}\right)+9\left(\frac2{\sqrt{13}}\right)=\frac{42}{\sqrt{13}}.

Then multiply by the unit vector:

proj⁡ℓ(w⃗)=4213[3/132/13]=[126/1384/13].\operatorname{proj}_{\ell}(\vec w)=\frac{42}{\sqrt{13}}\begin{bmatrix}3/\sqrt{13}\\2/\sqrt{13}\end{bmatrix}=\begin{bmatrix}126/13\\84/13\end{bmatrix}.
Image produced in Jupyter
Image produced in Jupyter

The projection of w⃗=[89]\vec w=\begin{bmatrix}8\\9\end{bmatrix} onto 2x−3y=02x-3y=0 is w⃗∥=[126/1384/13]\vec w_{\parallel}=\begin{bmatrix}126/13\\84/13\end{bmatrix}.


Finding the projection without normalizing

The square roots canceled in the final answer. Can we avoid introducing them in the first place?

Let v⃗1\vec v_1 be any nonzero vector along ℓ\ell. Substituting u⃗1=v⃗1/∥v⃗1∥\vec u_1=\vec v_1/\lVert\vec v_1\rVert into the unit-vector formula gives

proj⁡ℓ(w⃗)=(w⃗⋅v⃗1∥v⃗1∥)v⃗1∥v⃗1∥=w⃗⋅v⃗1∥v⃗1∥2v⃗1=w⃗⋅v⃗1v⃗1⋅v⃗1v⃗1.\begin{aligned} \operatorname{proj}_{\ell}(\vec w) &=\left(\vec w\cdot\frac{\vec v_1}{\lVert\vec v_1\rVert}\right)\frac{\vec v_1}{\lVert\vec v_1\rVert}\\ &=\frac{\vec w\cdot\vec v_1}{\lVert\vec v_1\rVert^2}\vec v_1\\ &=\frac{\vec w\cdot\vec v_1}{\vec v_1\cdot\vec v_1}\vec v_1. \end{aligned}

Let’s check this in the same example, using w⃗=[89]\vec w=\begin{bmatrix}8\\9\end{bmatrix} and v⃗1=[32]\vec v_1=\begin{bmatrix}3\\2\end{bmatrix}:

proj⁡ℓ(w⃗)=8(3)+9(2)32+22[32]=4213[32]=[126/1384/13].\begin{aligned} \operatorname{proj}_{\ell}(\vec w) &=\frac{8(3)+9(2)}{3^2+2^2}\begin{bmatrix}3\\2\end{bmatrix}\\ &=\frac{42}{13}\begin{bmatrix}3\\2\end{bmatrix}\\ &=\begin{bmatrix}126/13\\84/13\end{bmatrix}. \end{aligned}

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 v⃗1\vec v_1 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:

w⃗⊥=w⃗−proj⁡ℓ(w⃗).\vec w_{\perp}=\vec w-\operatorname{proj}_{\ell}(\vec w).

In our example,

w⃗⊥=[89]−[126/1384/13]=[−22/1333/13].\vec w_{\perp}=\begin{bmatrix}8\\9\end{bmatrix}-\begin{bmatrix}126/13\\84/13\end{bmatrix}=\begin{bmatrix}-22/13\\33/13\end{bmatrix}.

This vector is perpendicular to the line because its dot product with the direction vector is zero:

[−22/1333/13]⋅[32]=−66+6613=0.\begin{bmatrix}-22/13\\33/13\end{bmatrix}\cdot\begin{bmatrix}3\\2\end{bmatrix}=\frac{-66+66}{13}=0.

The components also add back to the original vector:

[126/1384/13]+[−22/1333/13]=[89].\begin{bmatrix}126/13\\84/13\end{bmatrix}+\begin{bmatrix}-22/13\\33/13\end{bmatrix}=\begin{bmatrix}8\\9\end{bmatrix}.

We could also project directly onto ℓ⊥\ell^\perp. A unit vector along it is u⃗2=[−2/133/13]\vec u_2=\begin{bmatrix}-2/\sqrt{13}\\3/\sqrt{13}\end{bmatrix}, so

proj⁡ℓ⊥(w⃗)=(−16+2713)[−2/133/13]=[−22/1333/13].\operatorname{proj}_{\ell^\perp}(\vec w)=\left(\frac{-16+27}{\sqrt{13}}\right)\begin{bmatrix}-2/\sqrt{13}\\3/\sqrt{13}\end{bmatrix}=\begin{bmatrix}-22/13\\33/13\end{bmatrix}.

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?

Image produced in Jupyter

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 yy pointing upward. The gravitational force is

F⃗g=[0−1000] N.\vec F_g=\begin{bmatrix}0\\-1000\end{bmatrix}\text{ N}.

The ramp’s direction comes from a 3–4–5 triangle, so a unit vector pointing uphill is

u⃗=[4/53/5].\vec u=\begin{bmatrix}4/5\\3/5\end{bmatrix}.

Let ℓ=span⁡(u⃗)\ell=\operatorname{span}(\vec u) be the line through the origin parallel to the ramp. Projecting gravity onto this direction gives

F⃗g,∥=(F⃗g⋅u⃗)u⃗=(0(45)−1000(35))u⃗ N=−600u⃗ N=[−480−360] N.\begin{aligned} \vec F_{g,\parallel} &=(\vec F_g\cdot\vec u)\vec u\\ &=\left(0\left(\frac45\right)-1000\left(\frac35\right)\right)\vec u\text{ N}\\ &=-600\vec u\text{ N}\\ &=\begin{bmatrix}-480\\-360\end{bmatrix}\text{ N}. \end{aligned}

The negative sign means this component points downhill, opposite to u⃗\vec u. Since u⃗\vec u has length one, the component has magnitude 600 N. The cable must balance it by pulling uphill:

F⃗c=600u⃗ N=[480360] N.\vec F_c=600\vec u\text{ N}=\begin{bmatrix}480\\360\end{bmatrix}\text{ N}.

We can get the same projection without normalizing, using v⃗1=[43]\vec v_1=\begin{bmatrix}4\\3\end{bmatrix}:

F⃗g,∥=0(4)−1000(3)42+32[43] N=−120[43] N=[−480−360] N.\vec F_{g,\parallel}=\frac{0(4)-1000(3)}{4^2+3^2}\begin{bmatrix}4\\3\end{bmatrix}\text{ N}=-120\begin{bmatrix}4\\3\end{bmatrix}\text{ N}=\begin{bmatrix}-480\\-360\end{bmatrix}\text{ N}.

The same 600 N cable force also lets the vehicle move at constant speed along the straight ramp, since the net force is zero.


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:

w⃗=[71],ℓ=span⁡([11]).\vec w=\begin{bmatrix}7\\1\end{bmatrix},\qquad \ell=\operatorname{span}\left(\begin{bmatrix}1\\1\end{bmatrix}\right).

The projection is

p⃗=proj⁡ℓ(w⃗)=7+112+12[11]=[44].\vec p=\operatorname{proj}_{\ell}(\vec w) =\frac{7+1}{1^2+1^2}\begin{bmatrix}1\\1\end{bmatrix} =\begin{bmatrix}4\\4\end{bmatrix}.

Its error vector and error length are

w⃗−p⃗=[3−3],∥w⃗−p⃗∥=18=32.\vec w-\vec p=\begin{bmatrix}3\\-3\end{bmatrix},\qquad \lVert\vec w-\vec p\rVert=\sqrt{18}=3\sqrt2.

Compare this with another vector on the line:

q⃗=[22],w⃗−q⃗=[5−1],∥w⃗−q⃗∥=26.\vec q=\begin{bmatrix}2\\2\end{bmatrix},\qquad \vec w-\vec q=\begin{bmatrix}5\\-1\end{bmatrix},\qquad \lVert\vec w-\vec q\rVert=\sqrt{26}.

The projection has the shorter error. The picture shows the right triangle that explains why.

Image produced in Jupyter

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 ℓ\ell has the form

q⃗t=t[11],t∈R.\vec q_t=t\begin{bmatrix}1\\1\end{bmatrix},\qquad t\in\mathbb R.

The squared error length is

∥w⃗−q⃗t∥2=(7−t)2+(1−t)2=2t2−16t+50=2(t−4)2+18.\begin{aligned} \lVert\vec w-\vec q_t\rVert^2 &=(7-t)^2+(1-t)^2\\ &=2t^2-16t+50\\ &=2(t-4)^2+18. \end{aligned}

The square is smallest when t=4t=4. At that value, the squared error is 18, the error length is 323\sqrt2, and the candidate is exactly the projection p⃗\vec p.

Why this always works

For any other vector q⃗\vec q on ℓ\ell, the difference p⃗−q⃗\vec p-\vec q lies along the line, while w⃗−p⃗\vec w-\vec p is perpendicular to it. The Pythagorean theorem gives

∥w⃗−q⃗∥2=∥w⃗−p⃗∥2+∥p⃗−q⃗∥2≥∥w⃗−p⃗∥2.\lVert\vec w-\vec q\rVert^2 =\lVert\vec w-\vec p\rVert^2+\lVert\vec p-\vec q\rVert^2 \geq\lVert\vec w-\vec p\rVert^2.

Equality holds only when q⃗=p⃗\vec q=\vec p. Moving away from the projection along the line makes the error longer.