Skip to main content

Section 5.7 Projections in \(\R^2\) and \(\R^n\)

Subsection 5.7.1 Projections in \(\R^2\)

Start with two nonzero vectors \(\vec u\) and \(\vec v\text{.}\) Drop a perpendicular from \(\vec u\) to the line through \(\vec v\text{,}\) and use the point where this perpendicular hits the line to be the end of a new vector. Suppose that \(\theta\) is the angle between the vectors \(\vec u\) and \(\vec v\text{.}\) The picture of the construction is slightly different for \(\theta\) obtuse and \(\theta\) acute (the new vector is shown in red):

In each case the new vector is called the projection of \(\vec u\) along \(\vec v\) and is denoted \(\textrm{proj}_{\vec v} \vec u\text{.}\)

Since \(\textrm{proj}_{\vec v} \vec u\) and \(\vec v\) are collinear, we may write \(\textrm{proj}_{\vec v} \vec u=k\vec v\) for some real number \(k\text{.}\) We next determine the value of \(k\text{.}\)

In the left picture, we have

\begin{align*} \|\textrm{proj}_{\vec v} \vec u\| \amp=\|\vec u\| \cos(\theta)\qquad \text{(Note that }\cos(\theta)\geq 0\text{)}\\\\ \|\textrm{proj}_{\vec v} \vec u\| \amp= |k|\|\vec v\| \end{align*}

and so

\begin{equation*} k = \frac{\|\vec u\|}{\|\vec v\|}\cos(\theta) \qquad \textrm{(Note that }k\geq 0\text{)}. \end{equation*}

In the right picture, \(\theta>\frac\pi2\text{,}\) and so \(\cos(\theta)\lt0\text{.}\) In addition, the direction of \(\textrm{proj}_{\vec v} \vec u\) implies that \(k\lt0\text{,}\) and \(|k|=-k\text{.}\) As a result, the equation is still valid:

\begin{equation*} k = \frac{\|\vec u\|}{\|\vec v\|}\cos(\theta) \end{equation*}

We have seen in TheoremĀ 5.2.20 that \(\vec u\cdot\vec v = \|\vec u\|\,\|\vec v\|\cos(\theta)\text{,}\) and so

\begin{equation*} k =\frac{\vec u\cdot\vec v}{\|\vec v\|^2} =\frac{\vec u\cdot\vec v}{\vec v\cdot\vec v} \end{equation*}

We compute the dot product:

\begin{align*} (\vec u - \textrm{proj}_{\vec v} \vec u)\cdot\vec v \amp= \vec u\cdot\vec v - \textrm{proj}_{\vec v} \vec u\cdot\vec v\\ \amp=\vec u \cdot \vec v - \left(\frac{\vec u\cdot\vec v}{\vec v\cdot\vec v} \vec v\right) \cdot\vec v\\ \amp=\vec u \cdot \vec v - \left(\frac{\vec u\cdot\vec v}{\vec v\cdot\vec v}\right) (\vec v \cdot\vec v)\\ \amp=\vec u \cdot \vec v -\vec u \cdot \vec v \\ \amp=0 \end{align*}

Subsection 5.7.2 Examples of projections in \(\R^2\)

  • Suppose that \(\vec v=(1,0)\) and \(\vec u=(u_1,u_2)\text{.}\) Then the line through \(\vec v\) is simply the \(x\)-axis, and \(\|\vec v\|=1\text{,}\) and so \(\textrm{proj}_{\vec v} \vec u =\left((u_1,u_2)\cdot(1,0) \right) \vec v = (u_1,0)\text{.}\) This means that the projection of \((x_1,x_2)\) onto the \(x\)-axis is \((x_1,0)\text{,}\) just as would be expected.

  • Suppose \(\vec v=(1,1)\) and \(\vec u=(u_1,u_2)\text{.}\) Then the line through \(\vec v\) has equation \(y=x\text{,}\) and \(\|\vec v\|=\sqrt2\text{.}\) We then have \(\textrm{proj}_{\vec v} \vec u=\frac{(u_1,u_2)\cdot(1,1)}2 \vec v =\left(\frac{(u_1+u_2)}2,\frac{(u_1+u_2)}2\right)\)

  • Suppose we want to drop a perpendicular from the point \(\vec u=(m,-1)\) to the line \(y=mx\text{.}\) The vector \(\vec v=(1,m)\) is on that line. It then follows that \(\textrm{proj}_{\vec v} \vec u =\frac{(m,-1)\cdot(1,m)}{\|\vec v\|^2} \vec v=0\vec v=\vec 0\text{.}\) This implies that the line joining \((m,-1)\) and \((0,0)\text{,}\) which has slope \(-\frac1m\text{,}\) is perpendicular to the line with equation \(y=mx\text{.}\) This implies that the product of the slopes of two orthogonal lines is \(-1\text{.}\)

  • Suppose we want to drop a perpendicular from the point \(\vec u=(u_1,u_2)\) to the line \(y=mx\text{.}\) The vector \(\vec v=(1,m)\) is on that line, and \(\|\vec v\|=\sqrt{1+m^2}\text{.}\) It then follows that \(\textrm{proj}_{\vec v} \vec u =\frac{(u_1,u_2)\cdot(1,m)}{1+m^2} \vec v =\frac1{1+m^2}(u_1+mu_2, m(u_1+mu_2)) =\left(\frac{u_1+mu_2}{1+m^2},\frac{mu_1+m^2u_2}{1+m^2}\right)\)

The following figure illustrates these examples (note that the first examples are just the special cases of the last one).

Figure 5.7.3.

Subsection 5.7.3 Application: distance from a point to a line

We want to compute the distance from a point \(\vec u\) to a line \(L\text{.}\) Let \(\vec u=(x_0,y_0)\text{,}\) the general equation of \(L\) be \(ax+by+c=0\) and \(D\) the desired distance. In addition, let \((x_1,y_1)\) and \((x_2,y_2)\) be two points on \(L\text{,}\) and \(\vec n=(x_1+a,y_1+b)\text{.}\) These are all included in the following figure:

Figure 5.7.4.

Since \((x_1,y_1)\) and \((x_2,y_2)\) are both on \(L\text{,}\) we know that \(ax_1+by_1+c=ax_2+by_2+c=0\text{.}\) In addition, if we consider the two displacement vectors \(\vec v\) from \((x_1,y_1)\) to \((x_2,y_2)\) and \(\vec n\) from \((x_1,y_1)\) to \((x_1+a,y_1+b)\text{,}\) then the dot product

\begin{equation*} \vec v\cdot\vec n =(x_2-x_1,y_2-y_1)\cdot (a,b) =ax_2+by_2-(ax_1+by_1)=-c+c=0 \end{equation*}

This implies that the quadrilateral with vertices \((x_1,y_1)\text{,}\) \(\proj_{\vec v}\vec u\text{,}\) \(\vec u\) and \(\proj_{\vec n}\vec u\) is in fact a rectangle, and so \(\|\proj_{\vec n}\vec u\|=D\text{.}\)

\begin{align*} \proj_{\vec n}\vec u \amp= \frac{\vec u\cdot\vec n}{\vec n\cdot\vec n} \vec n\\ \amp=\frac{\left((x_0,y_0)-(x_1,y_1)\right)\cdot(a,b)}{\vec n\cdot\vec n} \vec n\\ \amp= \frac{ax_0+by_0 -(ax_1+by_1)}{\vec n\cdot\vec n} \vec n\\ \amp= \frac{ax_0+by_0 +c}{\vec n\cdot\vec n} \vec n \end{align*}

and so

\begin{equation*} D=\|\proj_{\vec n}\vec u\|=\frac{|ax_0+by_0 +c|}{\sqrt{a^2+b^2}} \end{equation*}

Subsection 5.7.4 Projections in \(\R^3\) and \(\R^n\)

Projections in \(\R^3\) to a plane and in \(\R^n\) to a hyperplane are remarkably similar to those in \(\R^2\text{.}\)

Figure 5.7.6.

In \(\R^3\) the projection from the point \((x_0,y_0,z_0)\) to the plane \(ax+by+cz+d=0\) can be obtained by taking the line through \((x_0,y_0,z_0)\) orthogonal to the plane. Since the vector \(\vec n=(a,b,c)\) is orthogonal to the plane, the line consists of all points of the form \((x_0,y_0,z_))+t(a,b,c)\text{.}\) The value of \(t\) that give the point in the plane satisfies

\begin{align*} a(x_0+ta)+b(y_0+tb)+c(z_0+tc)+d \amp =ax_0+by_0+cz_0+d+t(a^2+b^2+c^2)\\ \amp =0 \end{align*}

and so

\begin{equation*} t=-\frac{ax_0+by_0+cz_0+d}{a^2+b^2+c^2}. \end{equation*}

The distance to the plane is now easy to compute. If \(\vec x=(x_0,y_0,z_0)\) and \(\vec n=(a,b,c)\) then the distance from \(\vec x\) to \(\vec x+ t\vec n\) satisfies

\begin{equation*} d(\vec x,\vec x+ t\vec n) =\|\vec x+ t\vec n-\vec x\| =|t|\|\vec n\| =\frac{|ax_0+by_0+cz_0+d|}{\|\vec n\|^2} \|\vec n\| \end{equation*}

and so the distance \(D\) from the point to the plane satisfies

\begin{equation*} D=\frac{|ax_0+by_0+cz_0+d|}{\|\vec n\|}. \end{equation*}

Compare this result with the one in \(\R^2\text{:}\) TheoremĀ 5.7.5

The distance from a point to a hyperplane in \(\R^n\) is computed analogously.