Skip to main content

Section 8.1 The dot product

In this section, we introduce a simple algebraic operation, known as the dot product, that helps us measure the length of vectors and the angle formed by a pair of vectors. For two-dimensional vectors \(\vvec\) and \(\wvec\text{,}\) their dot product \(\vvec\cdot\wvec\) is the scalar defined to be
\begin{equation*} \vvec\cdot\wvec = \twovec{v_1}{v_2}\cdot\twovec{w_1}{w_2} = v_1w_1 + v_2w_2\text{.} \end{equation*}
For instance,
\begin{equation*} \twovec{2}{-3}\cdot\twovec{4}{1} = 2\cdot 4 + (-3)\cdot 1 = 5. \end{equation*}

Exploration 8.1.1.

  1. Compute the dot product
    \begin{equation*} \twovec{3}{4}\cdot\twovec{2}{-2}\text{.} \end{equation*}
  2. Sketch the vector \(\vvec=\twovec{3}{4}\) below. Then use the Pythagorean theorem to find the length of \(\vvec\text{.}\)
    Figure 8.1.1. Sketch the vector \(\vvec\) and find its length.
  3. Compute the dot product \(\vvec\cdot\vvec\text{.}\) How is the dot product related to the length of \(\vvec\text{?}\)
  4. Remember that the matrix \(\mattwo0{-1}10\) represents the matrix transformation that rotates vectors counterclockwise by \(90^\circ\text{.}\) Beginning with the vector \(\vvec = \twovec34\text{,}\) find \(\wvec\text{,}\) the result of rotating \(\vvec\) by \(90^\circ\text{,}\) and sketch it above.
  5. What is the dot product \(\vvec\cdot\wvec\text{?}\)
  6. Suppose that \(\vvec=\twovec ab\text{.}\) Find the vector \(\wvec\) that results from rotating \(\vvec\) by \(90^\circ\) and find the dot product \(\vvec\cdot\wvec\text{.}\)
  7. Suppose that \(\vvec\) and \(\wvec\) are two perpendicular vectors. What do you think their dot product \(\vvec\cdot\wvec\) is?
Solution.
  1. \(\twovec34\cdot\twovec2{-2} = 3\cdot2+4\cdot(-2) = -2\text{.}\)
  2. The length of \(\vvec\) is 5.
  3. \(\vvec\cdot\vvec = 25\text{,}\) which is the square of the length of \(\vvec\text{.}\)
  4. \(\displaystyle \wvec=\twovec{-4}3\)
  5. \(\vvec\cdot\wvec=0\text{.}\)
  6. \(\vvec\cdot\wvec=0\text{.}\)
  7. The dot product should be zero.

Subsection 8.1.1 The geometry of the dot product

The dot product is defined, more generally, for any two \(m\)-dimensional vectors:
\begin{equation*} \vvec\cdot\wvec = \left[ \begin{array}{c} v_1 \\ v_2 \\ \vdots \\ v_m \\ \end{array} \right] \cdot \left[ \begin{array}{c} w_1 \\ w_2 \\ \vdots \\ w_m \\ \end{array} \right] = v_1w_1 + v_2w_2 + \ldots + v_mw_m\text{.} \end{equation*}
The important thing to remember is that the dot product will produce a scalar. In other words, the two vectors are combined in such a way as to create a number, and, as we’ll see, this number conveys useful geometric information.

Example 8.1.2.

We compute the dot product between two four-dimensional vectors as
\begin{equation*} \left[ \begin{array}{c} 2 \\ 0 \\ -3 \\ 1 \\ \end{array} \right] \cdot \left[ \begin{array}{c} -1 \\ 3 \\ 1 \\ 2 \\ \end{array} \right] = 2(-1) + 0(3) + (-3)(1) + 1(2) = -3\text{.} \end{equation*}

Properties of dot products.

As with ordinary multiplication, the dot product enjoys some familiar algebraic properties, such as commutativity and distributivity. More specifically, it doesn’t matter in which order we compute the dot product of two vectors:
\begin{equation*} \vvec\cdot\wvec = \wvec\cdot\vvec\text{.} \end{equation*}
If \(s\) is a scalar, we have
\begin{equation*} (s\vvec)\cdot\wvec = s(\vvec\cdot\wvec)\text{.} \end{equation*}
We may also distribute the dot product across linear combinations:
\begin{equation*} (c_1\vvec_1+c_2\vvec_2)\cdot\wvec = c_1\vvec_1\cdot\wvec + c_2\vvec_2\cdot\wvec\text{.} \end{equation*}

Example 8.1.3.

Suppose that \(\vvec_1\cdot\wvec = 4\) and \(\vvec_2\cdot\wvec = -7\text{.}\) Then
\begin{equation*} \begin{aligned} (2\vvec_1)\cdot\wvec \amp {}={} 2(\vvec_1\cdot\wvec) = 2(4) = 8 \\ (-3\vvec_1+ 2\vvec_2)\cdot\wvec \amp {}={} -3(\vvec_1\cdot\wvec) + 2(\vvec_2\cdot\wvec) = -3(4)+2(-7) = -26\text{.} \end{aligned} \end{equation*}
The most important property of the dot product, and the real reason for our interest in it, is that it gives us geometric information about vectors and their relationship to one another. Let’s first think about the length of a vector by looking at the vector \(\vvec = \twovec32\) as shown in Figure 1.3.4
Figure 8.1.4. The vector \(\vvec=\twovec32\text{.}\)
We may find the length of this vector using the Pythagorean theorem since the vector forms the hypotenuse of a right triangle having a horizontal leg of length 3 and a vertical leg of length 2. The length of \(\vvec\text{,}\) which we denote as \(\len{\vvec}\text{,}\) is therefore \(\len{\vvec} = \sqrt{3^2 + 2^2} = \sqrt{13}\text{.}\) Now notice that the dot product of \(\vvec\) with itself is
\begin{equation*} \vvec\cdot\vvec = 3(3) + 2(2) = 13 = \len{\vvec}^2\text{.} \end{equation*}
This is true in general; that is, we have
\begin{equation*} \vvec\cdot\vvec = \len{\vvec}^2\text{.} \end{equation*}
More than that, the dot product of two vectors records information about the angle between them. Consider Figure 8.1.5.
Figure 8.1.5. The dot product \(\vvec\cdot\wvec\) measures the angle \(\theta\text{.}\)
To see this, we will apply the Law of Cosines, which says that
\begin{equation*} \begin{aligned} \len{\wvec-\vvec}^2 \amp = \len{\vvec}^2 + \len{\wvec}^2 - 2\len{\vvec}\len{\wvec}\cos\theta \\ (\wvec-\vvec)\cdot(\wvec-\vvec) \amp = \vvec\cdot\vvec + \wvec\cdot\wvec - 2\len{\vvec}\len{\wvec}\cos\theta \\ \wvec\cdot\wvec + \vvec\cdot\vvec- 2\vvec\cdot\wvec \amp = \vvec\cdot\vvec + \wvec\cdot\wvec - 2\len{\vvec}\len{\wvec}\cos\theta \\ -2\vvec\cdot\wvec \amp = -2\len{\vvec}\len{\wvec}\cos\theta \\ \vvec\cdot\wvec \amp = \len{\vvec}\len{\wvec}\cos\theta \\ \end{aligned} \end{equation*}
The upshot of this reasoning is that
\begin{equation*} \vvec\cdot\wvec = \len{\vvec}\len{\wvec}\cos\theta\text{.} \end{equation*}
To summarize:

Geometric properties of the dot product.

The dot product gives us the following geometric information:
\begin{equation*} \begin{aligned} \vvec\cdot\vvec\amp = \len{\vvec}^2 \\ \vvec\cdot\wvec\amp = \len{\vvec}\len{\wvec}\cos\theta \\ \end{aligned} \end{equation*}
where \(\theta\) is the angle between \(\vvec\) and \(\wvec\text{.}\)
As we move forward, it will be important for us to recognize when vectors are perpendicular to one another. For instance, when vectors \(\vvec\) and \(\wvec\) are perpendicular, the angle between them \(\theta=90^\circ\) and we have
\begin{equation*} \vvec\cdot\wvec=\len{\vvec}\len{\wvec}\cos\theta = \len{\vvec}\len{\wvec}\cos90^\circ = 0\text{.} \end{equation*}
Therefore, the dot product between perpendicular vectors must be zero. This leads to the following definition.

Definition 8.1.6.

We say that vectors \(\vvec\) and \(\wvec\) are orthogonal if \(\vvec\cdot\wvec=0\text{.}\)
Let’s consider a problem where we have a line \(L\) in \(\real^2\text{,}\) defined by the vector \(\wvec\text{,}\) and another vector \(\bvec\) that is not on the line, as shown on the left of Figure 8.1.7. We wish to find \(\bhat\text{,}\) the vector on the line that is closest to \(\bvec\text{,}\) as illustrated in the right of Figure 8.1.7.
Figure 8.1.7. Given a line \(L\) and a vector \(\bvec\text{,}\) we seek the vector \(\bhat\) on \(L\) that is closest to \(\bvec\text{.}\)
To find \(\bhat\text{,}\) we require that \(\bvec-\bhat\) be orthogonal to \(L\text{.}\) For instance, if \(\yvec\) is another vector on the line, as shown in Figure 8.1.8, then the Pythagorean theorem implies that
\begin{equation*} \len{\bvec-\yvec}^2 = |\bvec-\bhat|^2 + |\bhat-\yvec|^2 \end{equation*}
which means that \(\len{\bvec-\yvec}\geq|\bvec-\bhat|\text{.}\) Therefore, \(\bhat\) is closer to \(\bvec\) than any other vector on the line \(L\text{.}\)
Figure 8.1.8. The vector \(\bhat\) is closer to \(\bvec\) than \(\yvec\) because \(\bvec-\bhat\) is orthogonal to \(L\text{.}\)

Activity 8.1.2.

This activity demonstrates how to determine the orthogonal projection of a vector onto a subspace of \(\real^m\text{.}\)
  1. Let’s begin by considering a line \(L\text{,}\) defined by the vector \(\wvec=\twovec21\text{,}\) and a vector \(\bvec=\twovec24\) not on \(L\text{,}\) as illustrated in Figure 8.1.9.
    Figure 8.1.9. Finding the orthogonal projection of \(\bvec\) onto the line defined by \(\wvec\text{.}\)
    1. To find \(\bhat\text{,}\) first notice that \(\bhat = s\wvec\) for some scalar \(s\text{.}\) Since \(\bvec-\bhat = \bvec - s\wvec\) is orthogonal to \(\wvec\text{,}\) what do we know about the dot product
      \begin{equation*} (\bvec-s\wvec)\cdot\wvec\text{?} \end{equation*}
    2. Apply the distributive property of dot products to find the scalar \(s\text{.}\) What is the vector \(\bhat\text{,}\) the orthogonal projection of \(\bvec\) onto \(L\text{?}\)
    3. More generally, explain why the orthogonal projection of \(\bvec\) onto the line defined by \(\wvec\) is
      \begin{equation*} \bhat= \frac{\bvec\cdot\wvec}{\wvec\cdot\wvec}~\wvec\text{.} \end{equation*}
Solution.
    1. This dot product should be 0 since the vectors are orthogonal.
    2. \(\bhat=\frac{b\cdot\wvec}{\wvec\cdot\wvec}\wvec = \twovec{16/5}{8/5}\text{.}\)
    3. As before, \(\bhat= \frac{\bvec\cdot\wvec}{\wvec\cdot\wvec}\wvec\)