
# 11.9: The Dot Product and Projection


In Section \ref{Vectors}, we learned how add and subtract vectors and how to multiply vectors by scalars. In this section, we define a product of vectors. We begin with the following definition.

Definition: dot product

Suppose $$\vec{v}$$ and $$\vec{w}$$ are vectors whose component forms are $$\vec{v} = \left<v_{1},v_{2}\right>$$ and $$\vec{w} = \left<w_{1},w_{2}\right>$$. The dot product of $$\vec{v}$$ and $$\vec{w}$$ is given by

\begin{align} \vec{v} \cdot \vec{w} &= \left<v_{1},v_{2}\right> \cdot \left<w_{1},w_{2}\right> \\[4pt] &= v_{1}w_{1} + v_{2}w_{2} \end{align}

For example, let $$\vec{v} = \left<3,4\right>$$ and $$\vec{w} = \left<1,-2\right>$$. Then $$\vec{v} \cdot \vec{w} = \left<3,4\right> \cdot \left<1,-2\right> = (3)(1) + (4)(-2) = -5$$. Note that the dot product takes two vectors and produces a scalar. For that reason, the quantity $$\vec{v} \cdot \vec{w}$$ is often called the scalar product of $$\vec{v}$$ and $$\vec{w}$$. The dot product enjoys the following properties.

Properties of the Dot Product

• Commutative Property: For all vectors $$\vec{v}$$ and $$\vec{w}$$: $\vec{v} \cdot \vec{w} = \vec{w} \cdot \vec{v}.$
• Distributive Property: For all vectors $$\vec{u}$$, $$\vec{v}$$ and $$\vec{w}$$: $\vec{u} \cdot \left(\vec{v} + \vec{w}\right) = \vec{u} \cdot \vec{v} + \vec{u} \cdot \vec{w}.$
• Scalar Property: For all vectors $$\vec{v}$$ and $$\vec{w}$$ and scalars $$k$$, $(k \vec{v}) \cdot \vec{w} = k(\vec{v} \cdot \vec{w}) = \vec{v} \cdot (k \vec{w}).$
• Relation to Magnitude: For all vectors $$\vec{v}$$: $\vec{v} \cdot \vec{v} = \| \vec{v} \|^2.$

Like most of the theorems involving vectors, the proof of Theorem \ref{dotprodprops} amounts to using the definition of the dot product and properties of real number arithmetic. To show the commutative property for instance, let $$\vec{v} = \left<v_{1},v_{2}\right>$$ and $$\vec{w} = \left<w_{1},w_{2}\right>$$. Then

$\begin{array}{rcll} \vec{v} \cdot \vec{w} & = & \left<v_{1},v_{2}\right> \cdot \left<w_{1},w_{2}\right> & \\ & = & v_{1}w_{1} + v_{2}w_{2} & \text{Definition of Dot Product} \\ & = & w_{1}v_{1} + w_{2}v_{2} & \text{Commutativity of Real Number Multiplication} \\ & = & \left<w_{1},w_{2}\right> \cdot \left<v_{1},v_{2}\right> & \text{Definition of Dot Product} \\ & = & \vec{w} \cdot \vec{v} & \\ \end{array}$

The distributive property is proved similarly and is left as an exercise.

For the scalar property, assume that $$\vec{v} = \left<v_{1},v_{2}\right>$$ and $$\vec{w} = \left<w_{1},w_{2}\right>$$ and $$k$$ is a scalar. Then

$\begin{array}{rcll} (k\vec{v}) \cdot \vec{w} & = & \left(k \left<v_{1},v_{2}\right> \right) \cdot \left<w_{1},w_{2}\right> & \\ & = & \left<kv_{1},kv_{2}\right> \cdot \left<w_{1},w_{2}\right> & \text{Definition of Scalar Multiplication} \\ & = & (kv_{1})(w_{1}) + (kv_{2})(w_{2}) & \text{Definition of Dot Product} \\ & = & k(v_{1}w_{1}) + k(v_{2}w_{2}) & \text{Associativity of Real Number Multiplication} \\ & = & k(v_{1}w_{1} + v_{2}w_{2}) & \text{Distributive Law of Real Numbers} \\ & = & k \left<v_{1},v_{2}\right> \cdot \left<w_{1},w_{2}\right> & \text{Definition of Dot Product} \\ & = & k (\vec{v} \cdot \vec{w}) & \\ \end{array}$

We leave the proof of $$k(\vec{v} \cdot \vec{w}) = \vec{v} \cdot (k \vec{w})$$ as an exercise.

For the last property, we note that if $$\vec{v} = \left<v_{1},v_{2}\right>$$, then $$\vec{v} \cdot \vec{v} = \left<v_{1},v_{2}\right> \cdot \left<v_{1},v_{2}\right> = v_{1}^2 + v_{2}^2 = \|\vec{v}\|^2$$, where the last equality comes courtesy of Definition \ref{polarformvector}.

The following example puts Theorem \ref{dotprodprops} to good use. As in Example \ref{vectoreqnex}, we work out the problem in great detail and encourage the reader to supply the justification for each step.

Example $$\PageIndex{1}$$:dot product properties

Prove the identity: $$\| \vec{v} - \vec{w} \|^2 = \|\vec{v}\|^2 -2 (\vec{v}\cdot\vec{w}) + \|\vec{w}\|^2$$.

Solution

We begin by rewriting $$\| \vec{v} - \vec{w} \|^2$$ in terms of the dot product using Theorem \ref{dotprodprops}.

$\begin{array}{rcl} \| \vec{v} - \vec{w} \|^2 & = & (\vec{v} - \vec{w}) \cdot (\vec{v} - \vec{w}) \\ & = & (\vec{v} + [-\vec{w}]) \cdot (\vec{v} + [-\vec{w}]) \\ & = & (\vec{v} + [-\vec{w}]) \cdot \vec{v} +(\vec{v} + [-\vec{w}]) \cdot [-\vec{w}] \\ & = & \vec{v} \cdot (\vec{v} + [-\vec{w}]) + [-\vec{w}] \cdot (\vec{v} + [-\vec{w}]) \\ & = & \vec{v} \cdot \vec{v} + \vec{v} \cdot [-\vec{w}] + [-\vec{w}]\cdot \vec{v} + [-\vec{w}]\cdot[-\vec{w}] \\ & = & \vec{v} \cdot \vec{v} + \vec{v} \cdot [(-1)\vec{w}] + [(-1)\vec{w}]\cdot \vec{v} + [(-1)\vec{w}]\cdot[(-1)\vec{w}] \\ & = & \vec{v} \cdot \vec{v} + (-1)(\vec{v} \cdot \vec{w}) + (-1)(\vec{w} \cdot \vec{v}) + [(-1)(-1)](\vec{w}\cdot\vec{w}) \\ & = & \vec{v} \cdot \vec{v} + (-1)(\vec{v} \cdot \vec{w}) + (-1)(\vec{v} \cdot \vec{w}) + \vec{w}\cdot\vec{w} \\ & = & \vec{v} \cdot \vec{v} -2(\vec{v} \cdot \vec{w}) + \vec{w}\cdot\vec{w} \\ & = & \|\vec{v}\|^2-2(\vec{v} \cdot \vec{w}) + \|\vec{w}\|^2 \\ \end{array}$

Hence, $$\| \vec{v} - \vec{w} \|^2 = \|\vec{v}\|^2 -2 (\vec{v}\cdot\vec{w}) + \|\vec{w}\|^2$$ as required.

If we take a step back from the pedantry in Example \ref{dotprodpropex}, we see that the bulk of the work is needed to show that $$(\vec{v} - \vec{w}) \cdot (\vec{v} - \vec{w}) = \vec{v} \cdot \vec{v} -2(\vec{v} \cdot \vec{w}) + \vec{w}\cdot\vec{w}$$. If this looks familiar, it should. Since the dot product enjoys many of the same properties enjoyed by real numbers, the machinations required to expand $$(\vec{v} - \vec{w}) \cdot (\vec{v} - \vec{w})$$ for vectors $$\vec{v}$$ and $$\vec{w}$$ match those required to expand $$(v-w)(v-w)$$ for real numbers $$v$$ and $$w$$, and hence we get similar looking results. The identity verified in Example \ref{dotprodpropex} plays a large role in the development of the geometric properties of the dot product, which we now explore.

Suppose $$\vec{v}$$ and $$\vec{w}$$ are two nonzero vectors. If we draw $$\vec{v}$$ and $$\vec{w}$$ with the same initial point, we define the \textbf{angle between}\index{vector ! angle between two}\index{angle ! between two vectors} $$\vec{v}$$ and $$\vec{w}$$ to be the angle $$\theta$$ determined by the rays containing the vectors $$\vec{v}$$ and $$\vec{w}$$, as illustrated below. We require $$0 \leq \theta \leq \pi$$. (Think about why this is needed in the definition.)

The following theorem gives us some insight into the geometric role the dot product plays.

Geometric Interpretation of Dot Product

If $$\vec{v}$$ and $$\vec{w}$$ are nonzero vectors then $$\vec{v} \cdot \vec{w} = \|\vec{v}\| \|\vec{w}\| \cos(\theta)$$, where $$\theta$$ is the angle between $$\vec{v}$$ and $$\vec{w}$$.

We prove Theorem \ref{dotproductgeo} in cases. If $$\theta = 0$$, then $$\vec{v}$$ and $$\vec{w}$$ have the same direction. Since $$\vec{v} = \| \vec{v} \| \hat{v}$$ and $$\vec{w} = \| \vec{w} \| \hat{w}$$, if $$\hat{v} = \hat{w}$$ then

$\vec{w} = \|\vec{w}\| \hat{v} = \frac{\| \vec{w} \|}{\| \vec{v} \|} (\| \vec{v} \| \hat{v}) = \frac{\| \vec{w} \|}{\| \vec{v} \|} \vec{v}.$

In this case,

$k = \frac{\| \vec{w} \|}{\| \vec{v} \|} > 0.$

It follows, that there is a real number $$k > 0$$ so that $$\vec{w} = k \vec{v}$$]

Hence,

$\vec{v} \cdot \vec{w} = \vec{v} \cdot (k \vec{v}) = k (\vec{v} \cdot \vec{v}) = k \|\vec{v} \|^2 = k \| \vec{v} \| \|\vec{v}\|.$

Since $$k > 0$$, $$k = |k|$$, so

$k \|\vec{v}\| = |k| \|\vec{v}\| = \| k \vec{v} \|$

by Theorem \ref{magdirprops}. Hence,

$k \| \vec{v} \| \|\vec{v}\| = \| \vec{v} \| (k\|\vec{v}\|) = \|\vec{v}\| \|k\vec{v}\| = \|\vec{v}\| \|\vec{w}\|.$

Since $$\cos(0) = 1$$, we get $$\vec{v} \cdot \vec{w} = k \| \vec{v}\| \| \vec{v} \| = \|\vec{v} \| \|\vec{w}\| = \|\vec{v} \| \|\vec{w}\| \cos(0)$$, proving that the formula holds for $$\theta = 0$$. If $$\theta = \pi$$, we repeat the argument with the difference being $$\vec{w} = k \vec{v}$$ where $$k < 0$$. In this case, $$|k| = -k$$, so

$k\|\vec{v}\| = -|k| \| \vec{v}\| = -\|k\vec{v}\| = -\| \vec{w}\|.$

Since $$\cos(\pi) = -1$$, we get

$\vec{v} \cdot \vec{w} = -\|\vec{v}\| \|\vec{w} \| = \|\vec{v}\| \|\vec{w}\| \cos(\pi),$

as required. Next, if $$0 < \theta < \pi$$, the vectors $$\vec{v}$$, $$\vec{w}$$ and $$\vec{v} - \vec{w}$$ determine a triangle with side lengths $$\| \vec{v} \|$$, $$\| \vec{w} \|$$ and $$\| \vec{v} - \vec{w} \|$$, respectively, as seen below.

The Law of Cosines yields

$\| \vec{v} - \vec{w} \|^2 = \|\vec{v}\|^2 + \|\vec{w}\|^2 - 2\|\vec{v}\| \|\vec{w}\| \cos(\theta).$

From Example \ref{dotprodpropex}, we know

$\|\vec{v} - \vec{w}\|^2 = \|\vec{v}\|^2 -2 (\vec{v} \cdot \vec{w}) + \|\vec{w}\|^2.$

Equating these two expressions for

$\| \vec{v} - \vec{w} \|^2$

gives

$\|\vec{v}\|^2 + \|\vec{w}\|^2 - 2\|\vec{v}\| \|\vec{w}\| \cos(\theta) = \|\vec{v}\|^2 -2 (\vec{v} \cdot \vec{w}) + \|\vec{w}\|^2$

which reduces to

$- 2\|\vec{v}\| \|\vec{w}\| \cos(\theta) = -2 (\vec{v} \cdot \vec{w})$

or

$\vec{v} \cdot \vec{w} = \|\vec{v}\| \|\vec{w}\| \cos(\theta),$

as required. An immediate consequence of Theorem \ref{dotproductgeo} is the following.

Theorem: angle between vectors

Let $$\vec{v}$$ and $$\vec{w}$$ be nonzero vectors and let $$\theta$$ the angle between $$\vec{v}$$ and $$\vec{w}$$. Then

$\theta = \arccos\left( \dfrac{\vec{v} \cdot \vec{w}}{\| \vec{v} \| \|\vec{w} \|}\right) = \arccos(\hat{v} \cdot \hat{w})$

We obtain the formula in Theorem \ref{anglebetweenvectorthm} by solving the equation given in Theorem \ref{dotproductgeo} for $$\theta$$. Since $$\vec{v}$$ and $$\vec{w}$$ are nonzero, so are $$\| \vec{v} \|$$ and $$\|\vec{w}\|$$. Hence, we may divide both sides of

$\vec{v} \cdot \vec{w} = \| \vec{v} \| \|\vec{w} \| \cos(\theta)$

by

$\| \vec{v} \| \|\vec{w} \|$

to get

$\cos(\theta) = \frac{\vec{v} \cdot \vec{w}}{\| \vec{v} \| \|\vec{w} \|}.$

Since $$0 \leq \theta \leq \pi$$ by definition, the values of $$\theta$$ exactly match the range of the arccosine function. Hence,

$\theta = \arccos\left( \frac{\vec{v} \cdot \vec{w}}{\| \vec{v} \| \|\vec{w} \|}\right).$

Using Theorem \ref{dotprodprops}, we can rewrite

$\frac{\vec{v} \cdot \vec{w}}{\| \vec{v} \| \|\vec{w} \|} = \left(\frac{1}{\|\vec{v}\|} \vec{v}\right) \cdot \left(\frac{1}{\|\vec{w}\|} \vec{w}\right) = \hat{v} \cdot \hat{w}.$

giving us the alternative formula

$\theta = \arccos(\hat{v} \cdot \hat{w}).$

We are overdue for an example.

Example $$\PageIndex{1}$$: Angle Between Vectorex

Find the angle between the following pairs of vectors.

1. $$\vec{v} = \left< 3, -3\sqrt{3} \right>$$, and $$\vec{w} = \left<-\sqrt{3}, 1 \right>$$
2. $$\vec{v} = \left< 2, 2 \right>$$, and $$\vec{w} = \left<5, -5\right>$$
3. $$\vec{v} = \left< 3, -4 \right>$$, and $$\vec{w} = \left<2, 1\right>$$

Solution

We use the formula $$\theta = \arccos\left( \frac{\vec{v} \cdot \vec{w}}{\| \vec{v} \| \|\vec{w} \|}\right)$$ from Theorem \ref{anglebetweenvectorthm} in each case below.

1. We have $$\vec{v} \cdot \vec{w} = \left< 3, -3\sqrt{3} \right> \cdot \left<-\sqrt{3}, 1 \right> = -3\sqrt{3} - 3\sqrt{3} = -6\sqrt{3}$$. Since $$\| \vec{v} \| = \sqrt{3^2+(-3\sqrt{3})^2} = \sqrt{36} =6$$ and $$\| \vec{w}\| = \sqrt{(-\sqrt{3})^2+1^2} = \sqrt{4} =2$$, $$\theta = \arccos\left(\frac{-6\sqrt{3}}{12}\right) = \arccos\left(-\frac{\sqrt{3}}{2}\right) = \frac{5\pi}{6}$$.
2. For $$\vec{v} = \left< 2, 2 \right>$$ and $$\vec{w} = \left<5, -5\right>$$, we find $$\vec{v} \cdot \vec{w} = \left< 2, 2 \right> \cdot \left<5, -5\right> = 10-10 = 0$$. Hence, it doesn't matter what $$\| \vec{v} \|$$ and $$\| \vec{w} \|$$ are,\footnote{Note that there is no zero product property' for the dot product since neither $$\vec{v}$$ nor $$\vec{w}$$ is $$\vec{0}$$, yet $$\vec{v} \cdot \vec{w} = 0$$.} $$\theta = \arccos\left( \frac{\vec{v} \cdot \vec{w}}{\| \vec{v} \| \|\vec{w} \|}\right) = \arccos(0) = \frac{\pi}{2}$$.
3. We find $$\vec{v} \cdot \vec{w} = \left< 3, -4 \right> \cdot \left<2, 1\right> = 6 - 4 = 2$$. Also $$\| \vec{v} \| = \sqrt{3^2+(-4)^2} = \sqrt{25} = 5$$ and $$\vec{w} = \sqrt{2^2+1^2} = \sqrt{5}$$, so $$\theta = \arccos\left(\frac{2}{5\sqrt{5}}\right) = \arccos\left(\frac{2\sqrt{5}}{25} \right)$$. Since $$\frac{2\sqrt{5}}{25}$$ isn't the cosine of one of the common angles, we leave our answer as $$\theta = \arccos\left(\frac{2\sqrt{5}}{25} \right)$$. \qed

The vectors $$\vec{v} = \left< 2, 2 \right>$$, and $$\vec{w} = \left<5, -5\right>$$ in Example \ref{anglebetweenvectorex} are called orthogonal and we write $$\vec{v} \perp \vec{w}$$, because the angle between them is $$\frac{\pi}{2} \mbox{ radians} = 90^{\circ}$$. Geometrically, when orthogonal vectors are sketched with the same initial point, the lines containing the vectors are perpendicular.

We state the relationship between orthogonal vectors and their dot product in the following theorem.

The Dot Product Detects Orthogonality:

Let $$\vec{v}$$ and $$\vec{w}$$ be nonzero vectors. Then $$\vec{v} \perp \vec{w}$$ if and only if $$\vec{v} \cdot \vec{w} = 0$$. \index{vector ! dot product ! relation to orthogonality} \index{dot product ! relation to orthogonality}

To prove Theorem \ref{dotprodorththm}, we first assume $$\vec{v}$$ and $$\vec{w}$$ are nonzero vectors with $$\vec{v} \perp \vec{w}$$. By definition, the angle between $$\vec{v}$$ and $$\vec{w}$$ is $$\frac{\pi}{2}$$. By Theorem \ref{dotproductgeo},

$\vec{v} \cdot \vec{w} = \| \vec{v} \| \| \vec{w} \| \cos\left(\frac{\pi}{2}\right) = 0.$

Conversely, if $$\vec{v}$$ and $$\vec{w}$$ are nonzero vectors and $$\vec{v} \cdot \vec{w} = 0$$, then Theorem \ref{anglebetweenvectorthm} gives

$\theta = \arccos\left( \frac{\vec{v} \cdot \vec{w}}{\| \vec{v} \| \|\vec{w} \|}\right) = \arccos\left( \frac{0}{\| \vec{v} \| \|\vec{w} \|}\right) = \arccos(0) = \frac{\pi}{2}\), so $$\vec{v} \perp \vec{w}.$ We can use Theorem \ref{dotprodorththm} in the following example to provide a different proof about the relationship between the slopes of perpendicular lines.\footnote{See Exercise \ref{perpendicularlines} in Section \ref{LinearFunctions}.} Example \(\PageIndex{1}$$:perpendicular lines

Let $$L_{1}$$ be the line $$y = m_{1}x + b_{1}$$ and let $$L_{2}$$ be the line $$y = m_{2}x + b_{2}$$. Prove that $$L_{1}$$ is perpendicular to $$L_{2}$$ if and only if $$m_{1} \cdot m_{2} = -1$$.

Solution

Our strategy is to find two vectors: $$\vec{v_{1}}$$, which has the same direction as $$L_{1}$$, and $$\vec{v_{2}}$$, which has the same direction as $$L_{2}$$ and show $$\vec{v_{1}} \perp \vec{v_{2}}$$ if and only if $$m_{1} m_{2} = -1$$. To that end, we substitute $$x=0$$ and $$x=1$$ into $$y = m_{1}x + b_{1}$$ to find two points which lie on $$L_{1}$$, namely $$P(0, b_{1})$$ and $$Q(1, m_{1} + b_{1})$$. We let $$\vec{v_{1}} = \overrightarrow{PQ} = \left<1-0,(m_{1}+b_{1}) - b_{1}\right>=\left<1,m_{1}\right>$$, and note that since $$\vec{v_{1}}$$ is determined by two points on $$L_{1}$$, it may be viewed as lying on $$L_{1}$$. Hence it has the same direction as $$L_{1}$$. Similarly, we get the vector $$\vec{v_{2}} = \left<1,m_{2}\right>$$ which has the same direction as the line

\)L_{2}\). Hence, $$L_{1}$$ and $$L_{2}$$ are perpendicular if and only if $$\vec{v_{1}} \perp \vec{v_{2}}$$. According to Theorem \ref{dotprodorththm}, $$\vec{v_{1}} \perp \vec{v_{2}}$$ if and only if $$\vec{v_{1}} \cdot \vec{v_{2}} = 0$$. Notice that $$\vec{v_{1}} \cdot \vec{v_{2}} = \left<1,m_{1}\right> \cdot \left<1,m_{2}\right> = 1 + m_{1}m_{2}$$. Hence, $$\vec{v_{1}} \cdot \vec{v_{2}} = 0$$ if and only if $$1 + m_{1}m_{2} =0$$, which is true if and only if $$m_{1} m_{2} = -1$$, as required. \qed

While Theorem \ref{dotprodorththm} certainly gives us some insight into what the dot product means geometrically, there is more to the story of the dot product. Consider the two nonzero vectors $$\vec{v}$$ and $$\vec{w}$$ drawn with a common initial point $$O$$ below. For the moment, assume that the angle between $$\vec{v}$$ and $$\vec{w}$$, which we'll denote $$\theta$$, is acute. We wish to develop a formula for the vector $$\vec{p}$$, indicated below, which is called the orthogonal projection of $$\vec{v}$$ onto $$\vec{w}$$}.\index{vector ! orthogonal projection}\index{projection ! orthogonal}\index{orthogonal projection} The vector $$\vec{p}$$ is obtained geometrically as follows: drop a perpendicular from the terminal point $$T$$ of $$\vec{v}$$ to the vector $$\vec{w}$$ and call the point of intersection $$R$$. The vector $$\vec{p}$$ is then defined as $$\vec{p} = \overrightarrow{OR}$$. Like any vector, $$\vec{p}$$ is determined by its magnitude $$\| \vec{p} \|$$ and its direction $$\hat{p}$$ according to the formula $$\vec{p} = \| \vec{p} \| \hat{p}$$. Since we want $$\hat{p}$$ to have the same direction as $$\vec{w}$$, we have $$\hat{p} = \hat{w}$$. To determine $$\| \vec{p} \|$$, we make use of Theorem \ref{cosinesinetriangle} as applied to the right triangle $$\triangle ORT$$. We find $$\cos(\theta) = \frac{\| \vec{p} \|}{\| \vec{v} \|}$$, or $$\| \vec{p} \| = \| \vec{v} \| \cos(\theta)$$. To get things in terms of just $$\vec{v}$$ and $$\vec{w}$$, we use Theorem \ref{dotproductgeo} to get

$\| \vec{p} \| = \| \vec{v} \| \cos(\theta) = \frac{ \| \vec{v} \| \| \vec{w} \| \cos(\theta)}{\| \vec{w} \|} = \frac{\vec{v} \cdot \vec{w}}{\|\vec{w}\|}.$

Using Theorem \ref{dotprodprops}, we rewrite $$\frac{\vec{v} \cdot \vec{w}}{\|\vec{w}\|} = \vec{v} \cdot \left(\frac{1}{\|\vec{w}\|} \vec{w}\right) = \vec{v} \cdot \hat{w}$$. Hence, $$\| \vec{p} \| = \vec{v} \cdot \hat{w}$$, and since $$\hat{p} = \hat{w}$$, we now have a formula for $$\vec{p}$$ completely in terms of $$\vec{v}$$ and $$\vec{w}$$, namely $$\vec{p} = \| \vec{p} \| \hat{p} = (\vec{v} \cdot \hat{w}) \hat{w}$$.

Now suppose that the angle $$\theta$$ between $$\vec{v}$$ and $$\vec{w}$$ is obtuse, and consider the diagram below. In this case, we see that $$\hat{p} = - \hat{w}$$ and using the triangle $$\triangle ORT$$, we find $$\| \vec{p} \| = \| \vec{v} \| \cos(\theta')$$. Since $$\theta + \theta' = \pi$$, it follows that $$\cos(\theta') = -\cos(\theta)$$, which means $$\| \vec{p} \| = \| \vec{v} \| \cos(\theta') = - \| \vec{v} \| \cos(\theta)$$. Rewriting this last equation in terms of $$\vec{v}$$ and $$\vec{w}$$ as before, we get $$\|\vec{p} \| = -(\vec{v} \cdot \hat{w})$$. Putting this together with $$\hat{p} = - \hat{w}$$, we get $$\vec{p} = \| \vec{p} \| \hat{p} = -(\vec{v} \cdot \hat{w}) (-\hat{w}) = (\vec{v} \cdot \hat{w}) \hat{w}$$ in this case as well.

If the angle between $$\vec{v}$$ and $$\vec{w}$$ is $$\frac{\pi}{2}$$ then it is easy to show\footnote{In this case, the point $$R$$ coincides with the point $$O$$, so $$\vec{p} = \overrightarrow{OR} = \overrightarrow{OO} = \vec{0}$$.} that $$\vec{p} = \vec{0}$$. Since $$\vec{v} \perp \vec{w}$$ in this case, $$\vec{v} \cdot \vec{w} = 0$$. It follows that $$\vec{v} \cdot \hat{w} = 0$$ and $$\vec{p} = \vec{0} = 0 \hat{w} = (\vec{v} \cdot \hat{w}) \hat{w}$$ in this case, too. This gives us

Definition: vector projection

Let $$\vec{v}$$ and $$\vec{w}$$ be nonzero vectors. The \textbf{orthogonal projection of $$\vec{v}$$ onto $$\vec{w}$$}, denoted $$\text{proj}_{\vec{w}}(\vec{v})$$ is given by $$\text{proj}_{\vec{w}}(\vec{v}) = (\vec{v} \cdot \hat{w}) \hat{w}$$.

Definition \ref{vectorproj} gives us a good idea what the dot product does. The scalar $$\vec{v} \cdot \hat{w}$$ is a measure of how much of the vector $$\vec{v}$$ is in the direction of the vector $$\vec{w}$$ and is thus called the scalar projection\index{scalar projection}\index{vector ! scalar projection} of $$\vec{v}$$ onto $$\vec{w}$$. While the formula given in Definition \ref{vectorproj} is theoretically appealing, because of the presence of the normalized unit vector $$\hat{w}$$, computing the projection using the formula $$\text{proj}_{\vec{w}}(\vec{v}) = (\vec{v} \cdot \hat{w}) \hat{w}$$ can be messy. We present two other formulas that are often used in practice.

Alternate Formulas for Vector Projections

If $$\vec{v}$$ and $$\vec{w}$$ are nonzero vectors then

$\text{proj}_{\vec{w}}(\vec{v}) = (\vec{v} \cdot \hat{w}) \hat{w} = \left(\dfrac{\vec{v} \cdot \vec{w}}{\| \vec{w}\|^2}\right) \vec{w} = \left(\dfrac{\vec{v} \cdot \vec{w}}{\vec{w} \cdot \vec{w}}\right) \vec{w}$

The proof of Theorem \ref{altprojformulas}, which we leave to the reader as an exercise, amounts to using the formula $$\hat{w} = \left(\frac{1}{\| \vec{w} \|}\right) \vec{w}$$ and properties of the dot product. It is time for an example.

Example $$\PageIndex{1}$$: projex

Let $$\vec{v} = \left<1,8\right>$$ and $$\vec{w} = \left<-1,2\right>$$. Find $$\vec{p} = \text{proj}_{\vec{w}}(\vec{v})$$, and plot $$\vec{v}$$, $$\vec{w}$$ and $$\vec{p}$$ in standard position.

Solution

We find $$\vec{v} \cdot \vec{w} = \left<1,8\right> \cdot \left<-1,2\right> = (-1) + 16 = 15$$ and $$\vec{w} \cdot \vec{w} = \left<-1,2\right> \cdot \left<-1,2\right> = 1 + 4 = 5$$. Hence, $$\vec{p} = \frac{\vec{v} \cdot \vec{w}}{\vec{w} \cdot \vec{w}} \vec{w} = \frac{15}{5} \left<-1,2\right> = \left<-3,6\right>$$. We plot $$\vec{v}$$, $$\vec{w}$$ and $$\vec{p}$$ below.

Suppose we wanted to verify that our answer $$\vec{p}$$ in Example \ref{projex} is indeed the orthogonal projection of $$\vec{v}$$ onto $$\vec{w}$$. We first note that since $$\vec{p}$$ is a scalar multiple of $$\vec{w}$$, it has the correct direction, so what remains to check is the orthogonality condition. Consider the vector $$\vec{q}$$ whose initial point is the terminal point of $$\vec{p}$$ and whose terminal point is the terminal point of $$\vec{v}$$.

From the definition of vector arithmetic, $$\vec{p} + \vec{q} = \vec{v}$$, so that $$\vec{q} = \vec{v} - \vec{p}$$. In the case of Example \ref{projex}, $$\vec{v} = \left<1,8\right>$$ and $$\vec{p} = \left<-3,6\right>$$, so $$\vec{q} = \left<1,8\right> - \left<-3,6\right> = \left<4,2\right>$$. Then $$\vec{q} \cdot \vec{w} = \left<4,2\right> \cdot \left<-1,2\right> = (-4)+4 = 0$$, which shows $$\vec{q} \perp \vec{w}$$, as required. This result is generalized in the following theorem.

Generalized Decomposition Theorem

Let $$\vec{v}$$ and $$\vec{w}$$ be nonzero vectors. There are unique vectors $$\vec{p}$$ and $$\vec{q}$$ such that $$\vec{v} = \vec{p} + \vec{q}$$ where $$\vec{p} = k \vec{w}$$ for some scalar $$k$$, and $$\vec{q} \cdot \vec{w} = 0$$.

Note that if the vectors $$\vec{p}$$ and $$\vec{q}$$ in Theorem \ref{generalizeddecompthm} are nonzero, then we can say $$\vec{p}$$ is \textit{parallel}\footnote{See Exercise \ref{parallelvectorexercise} in Section \ref{Vectors}.} to $$\vec{w}$$ and $$\vec{q}$$ is orthogonal to $$\vec{w}$$. In this case, the vector $$\vec{p}$$ is sometimes called the vector component of $$\vec{v}$$ parallel to $$\vec{w}$$' and $$\vec{q}$$ is called the `vector component of $$\vec{v}$$ orthogonal to $$\vec{w}$$.' To prove Theorem \ref{generalizeddecompthm}, we take $$\vec{p} = \text{proj}_{\vec{w}}(\vec{v})$$ and $$\vec{q} = \vec{v} - \vec{p}$$. Then $$\vec{p}$$ is, by definition, a scalar multiple of $$\vec{w}$$. Next, we compute $$\vec{q} \cdot \vec{w}$$.

$\begin{array}{rcll} \vec{q} \cdot \vec{w} & = & (\vec{v} - \vec{p}) \cdot \vec{w}& \text{Definition of $$\vec{q}$$.} \\ & = & \vec{v} \cdot \vec{w} - \vec{p} \cdot \vec{w} & \text{Properties of Dot Product} \\ & = & \vec{v} \cdot \vec{w} - \left(\dfrac{\vec{v} \cdot \vec{w}}{\vec{w} \cdot \vec{w}} \vec{w}\right) \cdot \vec{w} & \text{Since $$\vec{p} = \text{proj}_{\vec{w}}(\vec{v})$$.} \\ & = & \vec{v} \cdot \vec{w} - \left(\dfrac{\vec{v} \cdot \vec{w}}{\vec{w} \cdot \vec{w}}\right) (\vec{w} \cdot \vec{w}) & \text{Properties of Dot Product.} \\ & = & \vec{v} \cdot \vec{w} - \vec{v}\cdot \vec{w} & \\ & = & 0 & \end{array}$

Hence, $$\vec{q} \cdot \vec{w} = 0$$, as required. At this point, we have shown that the vectors $$\vec{p}$$ and $$\vec{q}$$ guaranteed by Theorem \ref{generalizeddecompthm} exist. Now we need to show that they are \textit{unique}. Suppose

$\vec{v} = \vec{p} + \vec{q} = \vec{p} \,' + \vec{q} \,'$

where the vectors $$\vec{p} \,'$$ and $$\vec{q} \,'$$ satisfy the same properties described in Theorem \ref{generalizeddecompthm} as $$\vec{p}$$ and $$\vec{q}$$. Then

$\vec{p} - \vec{p} \,' = \vec{q} \,' - \vec{q}$

so

$\vec{w} \cdot (\vec{p} - \vec{p} \,') = \vec{w} \cdot (\vec{q} \,' - \vec{q}) = \vec{w} \cdot \vec{q} \,' - \vec{w} \cdot \vec{q} = 0 - 0 = 0.$

Hence, $$\vec{w} \cdot (\vec{p} - \vec{p} \,') = 0$$. Now there are scalars $$k$$ and $$k \,'$$ so that $$\vec{p} = k \vec{w}$$ and $$\vec{p} \,' = k\,'\vec{w}$$. This means $$\vec{w} \cdot (\vec{p} - \vec{p} \,') = \vec{w} \cdot ( k \vec{w} - k \,' \vec{w}) = \vec{w} \cdot ([k - k \,'] \vec{w}) = (k - k \,') (\vec{w} \cdot \vec{w}) = (k - k \,') \| \vec{w} \|^2$$. Since $$\vec{w} \neq \vec{0}$$, $$\| \vec{w} \|^2 \neq 0$$, which means the only way

$\vec{w} \cdot (\vec{p} - \vec{p} \,') = (k - k \,') \| \vec{w} \|^2 = 0$

is for $$k - k \,' = 0$$, or $$k = k \,'$$. This means $$\vec{p} = k \vec{w} = k \,' \vec{w} = \vec{p} \,'$$. With $$\vec{q} \,' - \vec{q} = \vec{p} - \vec{p} \,' = \vec{p} - \vec{p} = \vec{0}$$, it must be that $$\vec{q} \,' = \vec{q}$$ as well. Hence, we have shown there is only one way to write $$\vec{v}$$ as a sum of vectors as described in Theorem \ref{generalizeddecompthm}.

## Work

We close this section with an application of the dot product. In Physics, if a constant force $$F$$ is exerted over a distance $$d$$, the \index{work} \textbf{work} $$W$$ done by the force is given by $$W = Fd$$. Here, we assume the force is being applied in the direction of the motion. If the force applied is not in the direction of the motion, we can use the dot product to find the work done. Consider the scenario below where the constant force $$\vec{F}$$ is applied to move an object from the point $$P$$ to the point $$Q$$.

To find the work $$W$$ done in this scenario, we need to find how much of the force $$\vec{F}$$ is in the \text{direction} of the motion $$\overrightarrow{PQ}$$. This is precisely what the dot product $$\vec{F} \cdot \widehat{PQ}$$ represents. Since the distance the object travels is $$\| \overrightarrow{PQ} \|$$, we get $$W = (\vec{F} \cdot \widehat{PQ}) \| \overrightarrow{PQ} \|$$. Since $$\overrightarrow{PQ} = \|\overrightarrow{PQ}\| \widehat{PQ}$$,

$W = (\vec{F} \cdot \widehat{PQ}) \| \overrightarrow{PQ} \| = \vec{F} \cdot ( \| \overrightarrow{PQ} \|\widehat{PQ} ) = \vec{F} \cdot \overrightarrow{PQ} = \| \vec{F} \| \| \overrightarrow{PQ} \| \cos(\theta)$

where $$\theta$$ is the angle between the applied force $$\vec{F}$$ and the trajectory of the motion $$\overrightarrow{PQ}$$. We have proved the following.

Work as a Dot Product

Suppose a constant force $$\vec{F}$$ is applied along the vector $$\overrightarrow{PQ}$$. The work $$W$$ done by $$\vec{F}$$ is given by

$W = \vec{F} \cdot \overrightarrow{PQ} = \| \vec{F} \| \| \overrightarrow{PQ} \| \cos(\theta),$

where $$\theta$$ is the angle between $$\vec{F}$$ and $$\overrightarrow{PQ}$$.

Example $$\PageIndex{1}$$:vectorworkex

Taylor exerts a force of $$10$$ pounds to pull her wagon a distance of $$50$$ feet over level ground. If the handle of the wagon makes a $$30^{\circ}$$ angle with the horizontal, how much work did Taylor do pulling the wagon? Assume Taylor exerts the force of $$10$$ pounds at a $$30^{\circ}$$ angle for the duration of the $$50$$ feet.

Solution

There are two ways to attack this problem. One way is to find the vectors $$\vec{F}$$ and $$\overrightarrow{PQ}$$ mentioned in Theorem \ref{vectorworkex} and compute $$W = \vec{F} \cdot \overrightarrow{PQ}$$. To do this, we assume the origin is at the point where the handle of the wagon meets the wagon and the positive $$x$$-axis lies along the dashed line in the figure above. Since the force applied is a constant 10 pounds, we have $$\|\vec{F}\| = 10$$. Since it is being applied at a constant angle of $$\theta = 30^{\circ}$$ with respect to the positive $$x$$-axis, Definition \ref{polarformvector} gives us $$\vec{F} = 10 \left<\cos(30^{\circ}, \sin(30^{\circ})\right> = \left<5\sqrt{3}, 5\right>$$. Since the wagon is being pulled along 50 feet in the positive direction, the displacement vector is $$\overrightarrow{PQ} = 50 \hat{\imath} = 50\left<1,0\right> = \left<50,0\right>$$. We get $$W = \vec{F} \cdot \overrightarrow{PQ} = \left<5\sqrt{3}, 5\right> \cdot \left<50,0\right> = 250\sqrt{3}$$. Since force is measured in pounds and distance is measured in feet, we get $$W = 250\sqrt{3}$$ foot-pounds. Alternatively, we can use the formulation $$W = \| \vec{F} \| \| \overrightarrow{PQ} \| \cos(\theta)$$ to get $$W = (10 \, \text{pounds})(50 \, \text{feet}) \cos\left(30^{\circ}\right) = 250 \sqrt{3}$$ foot-pounds of work.