Skip to main content

Linear Algebra

Module 5 Projections & Vector Components

In this module you will learn
  • The definition of the projection of a vector onto a set and the definition of the vector component of one vector in the direction of another.
  • The relationship between projection, orthogonality, and vector components.
  • How to project a vector onto a line.
Consider the following situation: you’re designing a 3d video game, but your users only have 2d screens. Or, you have a 900-dimensional dataset, but you want to visualize it on a continuum (i.e., as a line). Each of these is an example of finding the best approximation to particular points given restrictions. In general, this operation is called a projection
 1 
What we define as a projection is sometimes called the orthogonal projection to distinguish it from other types of projections.
, and in the world of linear algebra, it has a very particular meaning.

Definition 5.0.1. Projection.

Let \(X\subseteq \R^{n}\) be a set. The projection of the vector \(\vec v\in\R^{n}\) onto \(X\text{,}\) written \(\Proj_{X}\vec v\text{,}\) is the closest point in \(X\) to \(\vec v\text{.}\)
Let \(\mathcal{P}_{xy}\subseteq\R^{3}\) be the \(xy\)-plane in \(\R^{3}\) and let \(\vec v=\mat{1\\2\\3}\text{.}\) Intuitively, \(\Proj_{\mathcal{P}_{xy}}\!\!\vec v\) is the “shadow” that \(\vec v\) would cast on \({\mathcal{P}_{xy}}\) if the sun were directly overhead. Upon drawing a picture, we conclude \(\Proj_{\mathcal{P}_{xy}}\vec v=\mat{1\\2\\0}.\)
Figure 5.0.2.
Continuing, let \(\ell_{y}\subseteq \R^{3}\) be the \(y\)-axis in \(\R^{3}\text{.}\) It’s a little bit harder to visualize what \(\Proj_{\ell_y}\vec v\) is, so let’s appeal to some definitions.
By definition, every vector in \(\ell_{y}\) takes the form \(\vec u_{t}=\mat{0\\t\\0}\) for some \(t\in \R\text{.}\) The distance between \(\vec u_{t}\) and \(\vec v\) is
\begin{equation*} \Norm{\vec u_t-\vec v}=\Norm{\mat{0\\t\\0}-\mat{1\\2\\3}}= \sqrt{1^{2}+(t-2)^{2}+3^{2}}. \end{equation*}
Since \((t-2)^{2}\) is always positive, the quantity \(\sqrt{1^{2}+(t-2)^{2}+3^{2}}\) is minimized when \((t-2)^{2}=0\text{;}\) that is, when \(t=2\text{.}\) Thus, we see \(\vec u_{2}\) is the closest vector in \(\ell_{y}\) to \(\vec v\) and so,
\begin{equation*} \Proj_{\ell_y}\vec v=\vec u_{2}=\mat{0\\2\\0}. \end{equation*}

Example 5.0.3.

Let \(\ell\subseteq \R^{2}\) be the line given in vector form by \(\vec x=t\mat{1\\1}+\mat{3\\-2}\text{,}\) and let \(\vec v=\mat{-1\\-1}\text{.}\) Use the definition of projection to find \(\Proj_{\ell} \vec v\text{.}\)

Solution.

Let \(\vec u_{t}=t\mat{1\\1}+\mat{3\\-2}\in\ell\text{.}\) By definition, the distance between \(\vec v\) and \(\vec u_{t}\) is given by
\begin{equation*} \Norm{\vec u_t-\vec v}=\Norm{\left(t\mat{1\\1}+\mat{3\\-2}\right)-\mat{-1\\-1}}= \Norm{\mat{t+4\\t-1}}=\sqrt{2t^{2}+6t+17}. \end{equation*}
The quantity \(2t^{2}+6t+17\) is minimized when \(t=-\frac{3}{2}\text{,}\) and so the closest point in \(\ell\) to \(\vec v\) is \(\vec u_{-3/2}\text{.}\) Thus,
\begin{equation*} \Proj_{\ell} \vec v=-\tfrac{3}{2}\mat{1\\1}+\mat{3\\-2}=\mat{3/2\\-7/2}. \end{equation*}
Every example of a projection so far shares a geometric property. In the case of lines and planes, the vector from the projection to the original point is a normal vector for the line or plane (provided it’s non-zero).
Figure 5.0.4.
Stated precisely, if \(X\) is a line or plane and \(\vec v\notin X\) is a vector, then \(\vec v-\Proj_{X}\vec v\) is a normal vector for \(X\text{.}\) Using this fact, we can find projections onto lines and planes without needing to compute any distances!

Example 5.0.5.

Let \(\ell\subseteq \R^{2}\) be the line given in vector form by \(\vec x=t\mat{1\\1}+\mat{3\\-2}\text{,}\) and let \(\vec v=\mat{-1\\-1}\text{.}\) Use the fact that \(\vec v-\Proj_{\ell}\vec v\) is a normal vector to \(\ell\) to find \(\Proj_{\ell} \vec v\text{.}\)

Solution.

Since \(\vec v-\Proj_{\ell}\vec v\) is a normal vector to \(\ell\text{,}\) we know \(\vec v-\Proj_{\ell}\vec v\) is orthogonal to \(\vec d=\mat{1\\1}\text{.}\) Let \(\mat{x\\y}=\Proj_{\ell}\vec v\) for some unknown \(x,y\in\R\text{.}\) We now know
\begin{equation*} (\vec v-\Proj_{\ell}\vec v)\cdot\vec d=\left(\mat{-1\\-1}-\mat{x\\y}\right)\cdot\mat{1\\1}=\mat{-1-x\\-1-y}\cdot \mat{1\\1}=-2-x-y=0. \end{equation*}
That is,
\begin{equation} x+y=-2.\tag{5.0.1} \end{equation}
Also, since \(\Proj_{\ell}\vec v\in\ell\text{,}\) we know
\begin{equation*} \Proj_{\ell}\vec v = \mat{x\\y}=t\mat{1\\1}+\mat{3\\-2}=\mat{t+3\\t-2}. \end{equation*}
From this, we have that \(x-t=3\) and \(y-t=-2\text{.}\) Combined with Equation (5.0.1), we have three equations and three unknowns which produce the following system of linear equations.
\begin{equation*} \left\{\begin{array}{crcrcrl}&&&x&+&y&=-2\\-&t&+&x&&&=3\\-&t&&&+&y&=-2\end{array}\right. \end{equation*}
Solving this system, we conclude that \(x=3/2\) and \(y=-7/2\) (we don’t care about the value of \(t\)). Therefore \(\Proj_{\ell}\vec v = \mat{3/2\\-7/2}\text{.}\)

Takeaway 5.0.6.

When projecting onto lines and planes, right angles appear in key places.

Section 5.1 Projections Onto Other Sets

For projections onto lines and planes, we can use what we know about normal vectors to simplify our life. The same is true when projecting onto other sets, but we must always keep the definition in mind.

Example 5.1.1.

Let \(\mathcal{T}\subseteq \R^{2}\) be the filled in triangle with vertices \(\mat{0\\0}\text{,}\) \(\mat{1\\0}\text{,}\) and \(\mat{0\\2}\text{,}\) and let
\begin{equation*} \vec a=\mat{1/4\\1/4}\qquad \vec b=\mat{1\\1}\qquad \vec c=\matc{3\\1/2}. \end{equation*}
Find \(\Proj_{\mathcal{T}}\vec a\text{,}\) \(\Proj_{\mathcal{T}}\vec b\text{,}\) and \(\Proj_{\mathcal{T}}\vec c\text{.}\)

Solution.

We’ll start by drawing a picture.
Figure 5.1.2.
From the picture, we see that \(\vec a\in \mathcal{T}\) and so
\begin{equation*} \Proj_{\mathcal{T}}\vec a=\vec a. \end{equation*}
We also see that \(\vec b\) is closest to the hypotenuse of \(\mathcal{T}\text{,}\) and so \(\Proj_{\mathcal{T}}\vec b\) is the same as the projection of \(\vec b\) onto the line \(y=-2x+2\text{.}\) Computing, we find
\begin{equation*} \Proj_{\mathcal{T}}\vec b=\mat{3/5\\4/5}. \end{equation*}
Finally, drawing concentric circles centered at \(\vec c\text{,}\) we see that the lower-right corner of \(\mathcal{T}\) is the closest point in \(\mathcal{T}\) to \(\vec c\text{.}\)
Figure 5.1.3.
And so,
\begin{equation*} \Proj_{\mathcal{T}}\vec c =\mat{1\\0}. \end{equation*}

Section 5.2 Subtleties of Projections

You might be wondering, what is \(\Proj_{X}\vec v\) if \(\vec v\) is equidistant from two closest points in \(X\text{?}\) Or, what if \(X\) is an open set (for example, an open interval in \(\R^{1}\))? Then there might not be a closest point in \(X\) to \(\vec v\text{.}\) In both these cases, we say \(\Proj_{X}\vec v\) is undefined.
Formally, for a fixed set \(X\text{,}\) we consider \(P(\vec v)=\Proj_{X}\vec v\) as a function that inputs and outputs vectors. And, as a function, \(P\) has a domain consisting of exactly the vectors \(\vec v\) for which \(P(\vec v)\) is defined. As it happens, if \(X\) is a line or a plane in \(\R^{n}\text{,}\) the domain of \(P\) is all of \(\R^{n}\text{,}\) and in this text, we will be sensible and only ask about projections that exist.

Section 5.3 Vector Components

We’ve seen before that dot products can be used to measure how much one vector points in the direction of another. But, we can go further. Suppose \(\vec v\neq \vec 0\) and \(\vec u\) are vectors. We might want to decompose \(\vec u\) into the sum of two vectors, one which is in the direction of \(\vec v\) and the other which is orthogonal to \(\vec v\text{.}\) The tool that does this is the vector component.

Definition 5.3.1. Vector Components.

Let \(\vec u\) and \(\vec v\neq \vec 0\) be vectors. The vector component of \(\vec u\) in the \(\vec v\) direction, written \(\Comp_{\vec v}\vec u\text{,}\) is the vector in the direction of \(\vec v\) so that \(\vec u-\Comp_{\vec v}\vec u\) is orthogonal to \(\vec v\text{.}\)
Figure 5.3.2.
From the definition, it’s obvious that
\begin{equation*} \vec u=\Vcomp_{\vec v}\vec u + (\vec u-\Vcomp_{\vec v}\vec u) \end{equation*}
is a decomposition of \(\vec u\) into the sum of two vectors, one (\(\Vcomp_{\vec v}\vec u\)) is in the direction of \(\vec v\text{,}\) and the other (\(\vec u-\Vcomp_{\vec v}\vec u\)) is orthogonal to \(\vec v\text{.}\)

Example 5.3.3.

Find the vector component of \(\vec a=\mat{1\\2}\) in the direction of \(\vec b=\mat{1\\1}\text{.}\)

Solution.

Since \(\Vcomp_{\vec b}\vec a\) is a vector in the direction of \(\vec b\text{,}\) we know
\begin{equation*} \Vcomp_{\vec b}\vec a = k\vec b \end{equation*}
for some \(k\in \R\text{.}\) Since \(\vec a-\Vcomp_{\vec b}\vec a\) is orthogonal to \(\vec b\text{,}\) we know
\begin{equation*} (\vec a-\Vcomp_{\vec b}\vec a)\cdot \vec b=0. \end{equation*}
Combining these facts, we see
\begin{equation*} (\vec a-\Vcomp_{\vec b}\vec a)\cdot \vec b = \bigg(\underbrace{\mat{1\\2}}_{\vec a}-\underbrace{\mat{k\\k}}_{k\vec b}\bigg)\cdot \underbrace{\mat{1\\1}}_{\vec b}=(1-k)+(2-k)=3-2k=0, \end{equation*}
and so \(k=3/2\text{.}\) Therefore
\begin{equation*} \Vcomp_{\vec b}\vec a=k\vec b=\mat{3/2\\3/2}. \end{equation*}
Since we’ll be computing vector components often, let’s try to find a formula for \(\Vcomp_{\vec v}\vec u\text{.}\)
By definition, \(\Vcomp_{\vec v}\vec u\) is a vector in the direction of \(\vec v\text{,}\) so
\begin{equation*} \Vcomp_{\vec v}\vec u = k\vec v. \end{equation*}
Further, from the definition \(\vec u-\Vcomp_{\vec v}\vec u\) is orthogonal to \(\vec v\text{,}\) and so
\begin{equation*} \vec v\cdot (\vec u-\Vcomp_{\vec v}\vec u) = \vec v\cdot (\vec u-k\vec v)=\vec v\cdot \vec u-k\vec v\cdot \vec v=0. \end{equation*}
Because \(\vec v\neq \vec 0\text{,}\) we know \(\vec v\cdot \vec v\neq 0\text{.}\) Therefore, we may rearrange and solve for \(k\) to find
\begin{equation*} k=\frac{\vec v\cdot \vec u}{\vec v\cdot \vec v}, \end{equation*}
which means
\begin{equation*} \Vcomp_{\vec v}\vec u = \left(\frac{\vec v\cdot \vec u}{\vec v\cdot \vec v}\right)\vec v. \end{equation*}

Section 5.4 The Relationship Between Vector Components and Projections

Vector components and projections onto lines are closely related. So closely related that many textbooks use the single word projection to talk about both vector components and projections
 1 
We will not.
. Let’s take a moment to explore this relationship.
Let \(\vec v=\mat{2\\4}\) and \(\vec u=\mat{3\\1}\) and let \(\ell=\Span\Set{\vec v}\text{.}\) Drawing a picture of \(\ell\text{,}\) \(\vec u\text{,}\) and \(\Proj_{\ell}\vec u\text{,}\) we see that \(\Proj_{\ell}\vec u\) satisfies all the properties of \(\Vcomp_{\vec v}\vec u\text{.}\)
Figure 5.4.1.
Figure 5.4.2.
Since \(\ell=\Span\Set{\vec v}\) and \(\Proj_{\ell}\vec u\in\ell\text{,}\) we know that \(\Proj_{\ell}\vec u\) is in the direction of \(\vec v\text{.}\) Further, using geometric arguments, we know \(\vec u-\Proj_{\ell}\vec u\) is a normal vector for \(\ell\) and is therefore orthogonal to its direction vector \(\vec v\text{!}\) What’s more, we didn’t use anything in particular about \(\vec u\) and \(\vec v\) when making this argument (other than \(\vec v\neq \vec 0\)). This means, we have established a general fact.
This is great news because vector components are easy to compute using dot products while projections are usually hard to compute.

Example 5.4.4.

Compute the projection of \(\vec a=\mat{3\\7}\) onto \(L=\Span\Set{\mat{1\\-4}}\text{.}\)

Solution.

Let \(\vec b = \mat{1\\-4}\text{.}\) Since \(L=\Span\Set{\vec b}\) and \(\vec b\neq \vec 0\text{,}\) by the theorem above, we have
\begin{equation*} \Proj_{L} \vec a = \Vcomp_{\vec b}\vec a = \left(\frac{\vec b\cdot \vec a}{\vec b\cdot \vec b}\right)\vec b = \tfrac{3-28}{1+16}\mat{1\\-4}=\mat{-25/17\\100/17}. \end{equation*}
It’s worth noting, however, that vector components are equal to projections only in the case when you’re projecting onto a span. In general, projections and vector components are unrelated.

Example 5.4.5.

Let \(\vec a=\mat{3\\7}\) , \(\vec b=\mat{1\\-4}\text{,}\) and let \(D\) be the line given in vector form by \(\vec x=t\vec b+\vec a\text{.}\) Show that \(\Proj_{D}\vec a\neq \Vcomp_{\vec b}\vec a\text{.}\)

Solution.

By definition, \(\Proj_{D}\vec a\) is the closest point in \(D\) to \(\vec a\text{.}\) Since \(\vec a\in D\text{,}\) we must have
\begin{equation*} \Proj_{D}\vec a = \vec a = \mat{3\\7}. \end{equation*}
We already computed \(\Vcomp_{\vec b}\vec a=\mat{-25/17\\100/17}\) in the previous example, and so we see
\begin{equation*} \Vcomp_{\vec b}\vec a=\mat{-25/17\\100/17}\neq \mat{3\\7}=\Proj_{D}\vec a. \end{equation*}

Takeaway 5.4.6.

When projecting onto the span of a single vector, you can use vector components as a computational shortcut, but if the set isn’t a span, you cannot.

Exercises 5.5 Exercises

1.

Let \(T=\Set{\mat{0\\0}, \mat{-1\\2}, \mat{1\\-2}}\text{.}\) Find \(\Proj_{T}\mat{3 \\ 1}\text{.}\)
Solution.
The distances from \(\mat{ 3 \\ 1 }\) to \(\mat{0\\0}\text{,}\) \(\mat{-1\\2}\text{,}\) and \(\mat{1\\-2}\) are \(\sqrt{10}\text{,}\) \(\sqrt{17}\text{,}\) and \(\sqrt{13}\text{,}\) respectively. So \(\Proj_{T}\mat{3 \\ 1}= \mat{ 0 \\ 0}\text{.}\)

2.

Let \(C=\Set{ \vec v \in \R^2\given \norm{ \vec v} = 1}\) be the unit circle in \(\R^{2}\text{.}\) Find \(\Proj_{C}\mat{2 \\ 0}\text{.}\) Justify your answer.
Solution.
Suppose \(\vec v=\mat{x\\y}\in C\text{.}\) We would like to minimize \(\left \Vert \mat{ x \\ y }- \mat{ 2 \\ 0 }\right \Vert\text{,}\) or equivalently \(\left \Vert \mat{ x \\ y }- \mat{ 2 \\ 0 }\right \Vert^{2}\text{.}\) This expression can be rewritten as
\begin{equation*} \left \Vert \mat{ x \\ y }- \mat{ 2 \\ 0 }\right \Vert^{2}= (x-2)^{2}+y^{2}= (x^{2}+y^{2})-4x+4 \end{equation*}
\begin{equation*} = \left\Vert \vec v \right \Vert^{2}-4x+4 = 5 - 4x. \end{equation*}
Since \(x \leq 1\text{,}\) the above expression is minimized when \(x = 1\) (and thus \(y = 0\)). That is,
\begin{equation*} \Proj_{C}\mat{2 \\ 0}= \mat{ 1 \\ 0 }. \end{equation*}

3.

Let \(\ell=\Span \Set{ \mat{2 \\ 1}}\text{,}\) \(L=\Span \Set{ \mat{2 \\ 1}}+\Set{\mat{4\\0}}\text{,}\) and let \(S\) be the set of convex linear combinations of \(\mat{2 \\ 1}\) and \(\mat{4 \\ 2}\text{.}\) For \(\vec v = \mat{ 1 \\ 0}\text{,}\) find
  1. \(\Proj_{\ell}\vec v\text{.}\)
  2. \(\Proj_{L}\vec v\text{.}\)
  3. \(\Proj_{S}\vec v\text{.}\)
Solution.
  1. Let \(\vec u=\mat{ 2 \\ 1 }\text{.}\) Then \(\Proj_{\ell}\vec v=t\vec u\) for some \(t\in \R\) which minimizes
    \begin{equation*} \left \Vert \vec v - t \vec u \right \Vert^{2}= \left \Vert \vec u \right \Vert^{2}t^{2}- (2 \vec u \cdot \vec v) t + \left \Vert \vec v \right \Vert^{2}. \end{equation*}
    This quantity is minimized when \(t = \frac{\vec u \cdot \vec v}{\left \Vert \vec u \right \Vert^{2}}= \frac{2}{5}\text{,}\) so
    \begin{equation*} \Proj_{\ell}\vec v = \tfrac{2}{5}\vec u=\tfrac 15 \mat{4\\2}. \end{equation*}
  2. Let \(\vec u=\mat{ 2 \\ 1 }\text{.}\) Then \(\Proj_{L}\mat{ 1 \\ 0}=\mat{4\\0}+t\vec u\) for some \(t\in \R\) which minimizes
    \begin{equation*} \left \Vert \mat{ 1 \\ 0}- \mat{4\\0}-t \vec u \right \Vert^{2}= (-3-2t)^{2}+(0-t)^{2} \end{equation*}
    \begin{equation*} = 9+12t+5t^{2}. \end{equation*}
    The quantity \(9+12t+5t^{2}=5(t+\frac{6}{5} )^{2}+\frac{9}{5}\) is minimized when \(t = -\frac{6}{5}\text{,}\) so
    \begin{equation*} \Proj_{L}\vec v = \mat{4\\0}-\tfrac 65\vec u=\tfrac 15 \mat{8\\-6} \end{equation*}
  3. The set \(S\) is equal to \(\Set{t \vec u: 1 \leq t \leq 2}\) (check this), and so \(S\subseteq \ell\text{.}\) We found \(\Proj_{\ell}\vec v=\mat{4/5\\2/5}\) which is not in \(S\text{.}\) Therefore, \(\Proj_{S}\vec v\) must be one of the endpoints of \(S\text{.}\) Checking both endpoints, we conclude \(\Proj_{S}\vec v = \mat{2 \\ 1}\text{.}\)

4.

Let \(T\) be the set of convex linear combinations of \(\Set{\mat{1\\1}, \mat{-1\\1},\mat{-1\\-2}}\text{.}\) Find \(\Proj_{T}(\vec v)\text{,}\) for
  1. \(\displaystyle \vec v = \mat{3\\3}\)
  2. \(\displaystyle \vec v = \mat{0\\0}\)
  3. \(\displaystyle \vec v = \mat{1\\-2}\)
  4. \(\displaystyle \vec v = \mat{0\\-4}\)
Solution.
Geometrically, \(T\) is a filled in triangle with vertices \(\mat{1\\1}, \mat{-1\\1}\) and \(\mat{-1\\-2}\text{.}\) So for points outside the triangle, the closest point in \(T\) will be on the nearest side of \(T\text{,}\) and so we can project onto \(T\) by projecting onto line segments.
  1. \(\Proj_{T}\mat{3\\3}= \mat{1\\1}\text{;}\) since \(\mat{3\\3}\) is above \(T\text{,}\) the closest point will be on the line segment \(y=1\text{,}\) \(-1\leq x \leq 1\text{.}\)
  2. \(\Proj_{T}\mat{0\\0}= \mat{0\\0}\text{,}\) since \(\vec 0\in T\text{.}\)
  3. \(\Proj_{T}\mat{1\\-2}= \frac{1}{13}\mat{-5\\-14}\text{;}\) let \(\ell\) be the line segment \(\vec x= \mat{1\\1}+t\mat{-2\\-3}, 0\leq t \leq 1\text{.}\) Then \(\Proj_{T}\mat{1\\-2}= \Proj_{\ell}\mat{1\\-2}\text{,}\) and then either by minimizing the length function, or drawing a perpendicular line to \(\ell\text{,}\) we find the closest point is when \(t=\frac{9}{13}\text{.}\)
  4. \(\Proj_{T}\mat{0\\-4}= \mat{-1\\-2}\text{,}\) as in \((c)\text{,}\) but now the minimizer is at \(t>1\text{,}\) so the constraints \(0\leq t \leq 1\) force us to take the closest point on the line segment.

5.

Explain in your own words how to find \(\Proj_{\ell}(\vec v)\) when \(\ell=\Span\Set{\vec d}\) for some \(\vec d \neq \vec 0\text{.}\)

6.

Let \(\vec e_{1}=\mat{1 \\ 0}\text{,}\) \(\vec e_{2}=\mat{0 \\ 1}\text{,}\) and \(\vec u = \mat{2 \\ 3}\text{.}\)
  1. Draw \(\vec e_{1}\text{,}\) \(\vec e_{2}\text{,}\) \(\vec u\text{,}\) \(\Comp_{\vec e_1}\vec u\text{,}\) and \(\Comp_{\vec e_2}\vec u\) on the same grid.
  2. Write down two characterizing properties for \(\Comp_{\vec e_2}\vec u\text{.}\)
  3. Check that \(\vec u - \Comp_{\vec e_1}\vec u\) satisfies the above properties.
  4. \(\Comp_{\xhat}\vec u+\Comp_{\yhat}\vec u=\vec u\text{.}\) Does this always happen? Explain.

7.

In this problem, we will find the projection of a vector onto a plane in \(\R^{3}\text{.}\) Let \(\vec u=\mat{1\\2\\-2}\text{,}\) \(\vec v = \mat{0\\1\\1}\text{,}\) \(\vec a = \mat{6\\4\\-2}\text{,}\) and let \(\mathcal{P}=\Span\Set{\vec u,\vec v}\text{.}\)
  1. Find \(\Comp_{\vec u}(\vec a)\) and \(\Comp_{\vec v}(\vec a)\text{.}\)
  2. Show that \(\vec a-\Comp_{\vec u}(\vec a)-\Comp_{\vec v}(\vec a)\) is a normal vector for \(\mathcal{P}\text{.}\)
  3. Use 5.5.7.b to find \(\Proj_{\mathcal{P}}(\vec a)\text{.}\)
Solution.
  1. Using the formula for vector components, we have
    \begin{equation*} \Comp_{\vec u}(\vec a) = \frac{\vec a \cdot \vec u}{\vec u \cdot \vec u}\vec u = \frac{18}{9}\vec u = \mat{2\\4\\-4} \end{equation*}
    \begin{equation*} \Comp_{\vec v}(\vec a) = \frac{\vec a \cdot \vec v}{\vec v \cdot \vec v}\vec v = \frac{2}{2}\vec v = \mat{0\\1\\1}. \end{equation*}
  2. Let \(\vec b = \vec a-\Comp_{\vec u}(\vec a)-\Comp_{\vec v}(\vec a)\text{.}\) Directly computing, we have \(\vec b = \mat{ 4 \\-1 \\1 }\text{.}\)
    To show \(\vec b\) is orthogonal to \(P\text{,}\) we need to check that
    \begin{equation*} \vec b \cdot \vec u = 4-2-2 = 0 \end{equation*}
    and
    \begin{equation*} \vec b \cdot \vec v = 0-1+1 = 0. \end{equation*}
    Hence \(\vec b\) is a normal vector to \(P\text{.}\) (Note that this only worked because \(\vec u\cdot \vec v = 0\text{.}\) Subtracting each vector component from \(\vec a\) will not produce a normal vector in general.)
  3. Since \(\vec b\) is orthogonal to \(P\) and \(\vec a - \vec b\) is a linear combination of \(\vec u\) and \(\vec v\text{,}\) the vector \(\vec a - \vec b=\mat{2\\5\\-3}\) is the closest point to \(\vec a\) on \(P\text{.}\)