The dot product

#### Notes on notation

Textbooks vary in how they designate which things are vectors, some using bold font, and others using arrow $(\, \vec v \,)$ notation. I use arrows.

Publications are also split on how they write vector components, some using angle brackets like $\vec v = \langle 1, 2, 3\rangle$, and some just using parentheses like $\vec v = (1, 2, 3)$. I'll use the latter because it's usually clear in context when we mean to write a vector.

Many textbooks write the length of vector $\vec v_1$ as $||\vec v_1 ||$. In these pages, I'll stick to the single bars representation, $|\vec v_1 |$. When we're working in the context of vectors, it's difficult to confuse this notation with the absolute value – and simpler and cleaner to write.

### The angle between vectors

The dot product (also called the scalar product) gives us the angle between any two vectors. It's one of the most important relationships between vectors. In this section we'll define the dot product and show how it gives the angle between vectors for two- and three-dimensional vectors.

The dot product gives the angle between two vectors of any dimension. It's a tricky concept, but it's true. You can calculate the angle between 27-dimensional vectors.

Here's the definition of the dot product for two-dimensional vectors like $\vec v_1 = (x_1, y_1)$:

#### Dot product of 2-D vectors

\begin{align} \vec v_1 &= (x_1, y_1) \\[3pt] \vec v_2 &= (x_2, y_2) \\[5pt] \vec v_1 \cdot \vec v_2 &= x_1 x_2 + y_1 y_2 \end{align}

Notice the the result of the dot product is not another vector – it's just another number or a scalar. That's why we often call the dot product the scalar product. We can easily extend the definition of the dot product to vectors of any dimension, as long as the two have the same dimension.

#### Dot product of n-D vectors

\begin{align} \vec v_1 &= (a_1, a_2, \dots , a_n) \\[3pt] \vec v_2 &= (b_1, b_2, \dots , b_n) \\[5pt] \vec v_1 \cdot \vec v_2 &= a_1 b_1 + a_2 b_2 + \dots + a_n b_n \end{align}

Finally, the dot product can be thought of as a row vector (or a 1 × n matrix) multiplied by a column vector (an n × 1 matrix). Here's a picture of that for 2-D vectors:

\begin{align} v_1 &\cdot v_2 = (x_1, y_1)\left( \begin{matrix} x_2 \\ y_2 \end{matrix} \right) = x_1 x_2 + y_1 y_2 \\[5pt] &\phantom{0000000} \color{#E90F89}{(1 \times 2)(2 \times 1) = 1 \times 1 \; \text{(scalar)}} \end{align}

### Practice problems

Calculate the dot product of these vectors. Roll over or tap each problem for the solution.

### You can think of matrix multiplication like taking lots of dot products

If matrix multiplication gets the best of you, it might help to think of it like taking a bunch of dot products, row vectors from the left matrix with column vectors with the right-hand matrix. Here's a 3-D matrix multiplication problem:

We'll think of the matrix on the left as a vertical list of row vectors (a column vector of row vectors ... but that's confusing), called a, b and c. The matrix on the right is a horizontal list of column vectors, x, y and z.

Now if we multiply the two matrices, we're just taking a series of dot products like this:

$$= \begin{bmatrix} a \cdot x & a \cdot y & a \cdot z \\ b \cdot x & b \cdot y & b \cdot z \\ c \cdot x & c \cdot y & c \cdot z \end{bmatrix}$$

Now take a look at that matrix. The element in the second row, second column is just the dot product of the second row vector, b, and the second column vector, y. It's the same for each element in the result matrix. Here is the expanded result:

$$\begin{bmatrix} a_1x_1 + a_2x_2 + a_3x_3 & a_1y_1 + a_2y_2 + a_3y_3 & a_1z_1 + a_2z_2 + a_3z_3 \\ b_1x_1 + b_2x_2 + b_3x_3 & b_1y_1 + b_2y_2 + b_3y_3 & b_1z_1 + b_2z_2 + b_3z_3 \\ c_1x_1 + c_2x_2 + c_3x_3 & c_1y_1 + c_2y_2 + c_3y_3 & c_1z_1 + c_2z_2 + c_3z_3 \end{bmatrix}$$

#### The connection between the dot product and the angle between vectors

Consider two vectors, $\vec v_1$ and $\vec v_2$. Here they are:

The first thing we'll do is to translate them to the origin to make things easier. Remember that we can always do this because the only things about vectors that are important are their length and direction.

Now if we remember vector subtraction, we can construct the vector $\vec a - \vec b$. Let's also draw in angle $\theta$ between $\vec a$ and $\vec b$:

We begin with the law of cosines, where $|\vec v_1|$ is the length of vector $\vec v_1$, $|\vec v_2|$ is the length of vector $\vec v_2$, and so on:

$$|\vec v_1 - \vec v_2| = |\vec v_1|^2 + |\vec v_2|^2 - 2|\vec v_1||v_2| cos(\theta)$$

Now let's take a look at that left side, $\vec v_1 - \vec v_2|^2$. We can use the coordinates of the endpoints of $\vec v_1$ and $\vec v_2$, which are the coordinates of both ends of $\vec v_1 = \vec v_2$ to get

$$|\vec v_1 - \vec v_2|^2 = \left(\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}\right)^2$$

We're just using the distance formula with those coordinates. Now on the right we have the square of a square root, so the left side is just

$$= (x_2 - x_1)^2 + (y_2 - y_1)^2$$

Now for the right side of our original equation. If we remember that the square of the length of a vector is

$$|v_1|^2 = \left(\sqrt{x_1^2 + y_1^2} \right)^2$$

we get

$$= x_1^2 + y_1^2$$

So we have $|\vec v_1|^2 = x_1^2 + y_1^2$ and $|\vec v_2|^2 = x_2^2 + y_2^2$. Now we can rewrite both sides, and expand the binomials on the left to get:

\begin{align} (x_2 &- x_1)^2 + (y_2 - y_1)^2 \\ &= x_1^2 + y_1^2 + x_2^2 + y_2^2 - 2|\vec v_1||\vec v_2| cos(\theta) \end{align}

Notice that the squared terms containing purely x's or y's are represented on both sides of the equation, so we can eliminate them:

\require{cancel} \begin{align} \cancel{x_2^2} &- 2x_1x_2 + \cancel{x_1^2} + \cancel{y_2^2} - 2y_1y_2 + \cancel{y_1^2} \\ &= \cancel{x_1^2} + \cancel{y_1^2} + \cancel{x_2^2} + \cancel{y_2^2} - 2|\vec v_1||\vec v_2| cos(\theta) \end{align}

Finally, lots of those terms subtract to zero, and all of the remaining -2's can be divided away

$$\cancel{-2}x_1x_2 + \cancel{-2}y_1y_2 = \cancel{-2}|\vec v_1||\vec v_2| cos(\theta)$$

to give

$$x_1x_2 + y_1y_2 = |\vec v_1||\vec v_2| cos(\theta)$$

Now all that remains is to recognize that $x_1 x_2 + y_1 y_2$ is just the definition of the dot product, so we've arrived at the relationship between the dot product of two vectors and the angle between them:

$$\vec v_1 \cdot \vec v_2 = |\vec v_1||\vec v_2| cos(\theta)$$

### Properties of the dot product

Here are some key properties of the dot product that will come in handy when doing calculations. They can all be proved fairly easily using either the basic definition of the dot product, $\vec{a} \cdot \vec{b} = a_1 b_1 + a_2 b_2 + \dots + a_n + b_n,$ or the angle definition, $\vec{a} \cdot \vec{b} = |\vec{a}||\vec{b}| cos(\theta).$

Property Explanation
$\vec{a} \cdot \vec{a} = |\vec{a}|^2$ The dot product of a vector with itself is equal to the square of its length, because $cos(0) = 1$.
$\vec{0} \cdot \vec{a} = 0$ The dot product of a vector with the zero vector, $\vec{0} = (0, 0, \dots \ 0),$ is zero because the length of the zero vector is zero. That is, $(a_1, a_2, \dots a_n) \cdot (0, 0, \dots 0) = 0 + 0 + \dots + 0 = 0$.
$\vec{a} \cdot \vec{b} = \vec{b} \cdot \vec{a}$ The dot product is commutative because multiplication is commutative.
$\vec{a} \cdot (\vec{b} + \vec{c}) = \vec{a} \cdot \vec{b} + \vec{a} \cdot \vec{c}$ The dot product is distributive.
$(k \vec{a}) \cdot \vec{b} = k(\vec{a} \cdot \vec{b})$ ($k$ is a constant) Scalar multiplication and the dot product are commutative and associative.

### Example 1

Find the angle between vectors $v_1 = (-1, 2)$ and $v_2 = (2, 5)$

Solution: We begin by writing the dot-product equation and rearranging it to find the angle:

$$v_1 \cdot v_2 = |v_1||v_2| cos(\theta)$$

Solving for the angle, we get

$$\theta = cos^{-1} \left( \frac{v_1 \cdot v_2}{|v_1||v_2|} \right)$$

Now we just have to fill in the information. The dot product is the product of the x-coordinates plus the product of the y's:

$$v_1 \cdot v_2 = (-1)(2) + 2(5) = 8$$

The lengths of the vectors are found using the distance formula:

\begin{align} |v_1| &= ((-1)^2 + 2^2)^{1/2} = \sqrt{5} \\ |v_2| &= (2^2 + 5^2)^{1/2} = \sqrt{29} \end{align}

And finally the angle:

$$\theta = cos^{-1}\left( \frac{8}{\sqrt{5\cdot 29}} \right) = 48.4˚$$

### Example 2

Find a vector of length 1 that is perpendicular to $(1, 0, 1).$

Solution: This kind of problem will have two main steps. First we'll find one vector that is perpendicular to (1, 0, 1), but we'll have to remember that there are an infinite number of such vectors – all of different length. The second step will be to adjust the length of that vector to one – to make it a unit vector. Here's a picture of this 3-dimensional vector, which lives in the x-z plane:

Recall that the angle between perpendicular vectors (one known and one unknown in this case) has to be 90˚, and that the cosine of 90˚ is zero, so we'll start there:

$$cos(\theta) = \left( \frac{v_1 \cdot v_2}{|v_1||v_2|} \right)$$

We can get rid of the denominator because for this expression to equal zero, all that is required is that the dot product be zero:

$$\frac{v_1 \cdot v_2}{|v_1||v_2|} = 0$$

Now the dot product between v = (1, 0, 1) and an unknown vector (x, y, z) of the same dimension is:

\begin{align} 1(x) + 0(y) + 1(z) &= 0 \\ x + z &= 0 \\ x &= -z \end{align}

So all that is required of this vector is that y = 0 and x = -z.

$$v_{\perp} = (1, \, 0, \, -1)$$

The vectors (3, 0, -3) and (4.5, 0, 4.5) would work just as well. They differ only in length, but they're perpendicular to (1, 0, 1). What we need to do now is to adjust the length of (1, 0, 1) to 1. First we need to find its current length:

$$|(1, \; 0, \; -1)| = (1^2 + 0^2 + (-1)^2)^{1/2} = \sqrt{2}$$

Now to adjust the length we just divide each component of our vector by that length. You can check for yourself that the length of this new vector is 1.

$$v_{\perp} = \left( \frac{1}{\sqrt{2}}, \, 0, \, \frac{-1}{\sqrt{2}} \right)$$

The process of adjusting the length of a vector to 1, or making it a unit vector, is called normalization.

Finally, if (a, 0, -a) is perpendicular to (1, 0, 1), then so is (-a, 0, a). It also satisfies the requirement that x = -z, it just points in the opposite direction.

The diagram above shows our two vectors. They lie in the x-z plane. Notice that there are many other vectors perpendicular to (1, 0, 1) outside of that plane.

#### Normalization of a vector

To normalize a vector (set its length to one), calculate the length of the vector, then divide each component of the vector by that length.

### Example 3

Find a vector of length 1 orthogonal to vectors $v_1 = (1, -1, 2)$ and $v_2 = (-1, 2, 2).$

Solution: First, the word orthogonal replaces perpendicular when we're working in dimensions higher than three, and it's often used with three. It means the same thing: the angle between orthogonal vectors is 90˚, but we use a different word because it's difficult to visualize a 90˚ angle in higher dimensions.

Our vectors are

\begin{align} v_1 &= (1, \, -1, \, 2) \\ v_2 &= (-1, \, 2, \, 2) \end{align}

Here's a 3-D plot of these. The difference between this example and the last is that these vectors don't lie in one of the coordinate planes, so we'll have to approach finding orthogonal vectors differently.

Any two vectors can define a plane, as ours do. We seek a vector that's orthogonal to both, so we can write these two dot products:

\begin{align} (1, \, -1, \, 2) \cdot (a, \, b, \, c) &= 0 \\ a - b + 2c &= 0 \end{align}

and

\begin{align} (1, \, 2, \, 2) \cdot (a, \, b, \, c) &= 0 \\ -a + 2b + 2c &= 0 \end{align}

If we add those two equations we can eliminate a to find a relationship between b and c

$$\begin{matrix} \phantom{00} \cancel{a} - b + 2c = 0 \\[1pt] \underline{ -\cancel{a} + 2b + 2c = 0} \\[1pt] \phantom{0000000} b + 4c = 0 \end{matrix}$$

Now we have $b = -4c$, and we can plug that into either dot-product result to find $a = -6c$.

\begin{align} b &= -4c \\ a &= -6c \end{align}

If we let $c = 1$, we have one of many versions of our desired vector, differing in length.

$$(a, \, b, \, c) = (-6, \, -4, \, 1) \; or \; (6, \, 4, \, -1)$$

Notice that there are actually two vectors perpendicular to both $\vec v_1$ and $\vec v_2$, the negatives of each other.

Now we need to normalize our vectors, first by finding the length:

$$((-6)^2 + (-4)^2 + 1^2)^{1/2} = \sqrt{53}$$

... then by dividing by that length to find two vectors in the same directions, but of length 1:

$$(a, b, c) = \left( \frac{6}{\sqrt{53}}, \frac{4}{\sqrt{53}}, \frac{-1}{\sqrt{53}} \right)$$

Finally, here is our picture again with the two orthogonal unit vectors sketched in.

### Practice problems

For each problem calculate the unit vector orthogonal to each of the vectors given. Remember that a unit vector has a length of 1.

1. $(2, -2, 1)$ and $(1, 0, 0)$

Solution

\begin{align} 2x - 3y &= 0 \\[5pt] 2x &= 3y \\[5pt] x &= \frac{3}{2} y \end{align}

All we need is this relationship between x and y. They are not independent. Let $y = 1,$ then $x = \frac{3}{2},$ so one possible orthogonal vector is $v = \left(\frac{3}{2}, 1 \right).$ Now we need to normalize this vector. The first step is calculating its length:

$$|v| = \sqrt{\frac{9}{4} + 1} = \frac{\sqrt{13}}{2}$$

Now to normalize the vector, we divide each component by this length:

\begin{align} v_n &= \left( \frac{3}{2}\frac{2}{\sqrt{13}}, \frac{2}{\sqrt{13}} \right) \\[5pt] &= \left( \frac{3}{\sqrt{13}}, \frac{2}{\sqrt{13}} \right) \end{align}

You can check for yourself that the length of the normalized vector is 1, and that its dot product with (2, -3) is zero.

2. $(1, 1, -1)$ and $(1, -1, 1)$

Solution

In this case we'll need to set up and solve two equations for our three unknowns. They are

\begin{align} (1, 1, -1)\cdot (x, y, z) &= 0 \rightarrow x + y - z = 0 \\[5pt] (1, -1, 1) \cdot (x, y, z) &= 0 \rightarrow x - y + z = 0 \end{align}

If we add those two equations, we get $2x = 0,$ so $x = 0.$ Now plugging in x = 0 to the first equation gives $y - z = 0,$ so $y = z.$ If we let z = 1, then y = 1 and x = 0, so our "prototype" orthogonal vector is $(0, 1, 1).$

The length of this vector is

$$\sqrt{0^2 + 1^2 + 1^2} = \sqrt{2}.$$

Now dividing each component of $\vec{v}$ by $\sqrt{2}$ gives us our orthogonal unit vector:

$$v_n = \left( 1, \frac{\sqrt{2}}{2}, \frac{\sqrt{2}}{2} \right)$$

3. $(1, 2, -1)$ and $(-1, -1, 0)$

Solution

In this case we'll need to set up and solve two equations for our three unknowns. They are

\begin{align} (1, 2, -1) \cdot (x, y, z) &= 0 \rightarrow x + 2y - z = 0 \\[5pt] (-1, -1, 0) \cdot (x, y, z) &= 0 \rightarrow -x - y = 0 \end{align}

This system isn't too difficult to solve. We already have $x = -y,$ so if we let $y = 1,$ then $x = -1,$ and (from the first equation), $z = x + 2y = 1,$ so our orthogonal vector (or one of them) is $(-1, 1, 1).$

The length of this vector is $\sqrt{3},$ so our normalized orthogonal vector (one of a kind) is

$$v_n = \left( \frac{-\sqrt{3}}{3}, \frac{\sqrt{3}}{3}, \frac{\sqrt{3}}{3} \right)$$

You can confirm that the dot products of this vector with the original two are zero, and that its length is 1.

1. $(2, -2, 1)$ and $(1, 0, 0)$

Solution

In this case we'll need to set up and solve two equations for our three unknowns. They are

\begin{align} (2, -2, 1)\cdot (x, y, z) &= 0 \rightarrow 2x - 2y + z = 0 \\[5pt] (1, 0, 0) \cdot (x, y, z) &= 0 \rightarrow x = 0 \end{align}

Given that $x = 0,$ we have that $2y = z,$ or $y = \frac{1}{2}z,$ so if we let $z = 1,$ then our orthogonal vector is

$$v = (0, \frac{1}{2}, 1)$$

Now the length of this vector is $\sqrt{5}/2,$ so to normalize it, we divide all vector components by that length to get:

$$v = \left( 0, \frac{\sqrt{5}}{5}, \frac{2\sqrt{5}}{5} \right)$$

You can confirm that the dot products of this vector with the original two are zero, and that its length is 1.

2. $(1, -1, -2, 1), \; (-2, -1, 1, 2), \; (2, 3, 4, 1)$

Solution

In this case we'll need to set up and solve three equations for our four unknowns. They are

\begin{align} (1, -1, 2, 1)\cdot (w, x, y, z) &= 0 \rightarrow w - x + 2y + z = 0 \\[5pt] (2, 3, 4, 1)\cdot (w, x, y, z) &= 0 \rightarrow 2w + 3x + + 4y + z = 0 \\[5pt] (2, -1, 1, 2) \cdot (w, x, y, z) &= 0 \rightarrow 2w - x + y + 2z = 0 \end{align}

If we multiply the top equation by -2, we can set the three equations up to eliminate w:

\begin{align} -2w + 2x - 4y - 2z &= 0 \\[4pt] 2w + 3x + 4y + z &= 0 \\[4pt] 2w - x + y + 2z &= 0 \end{align}

Adding the first equation to the second and to the third gives two new equations, reduced a bit:

\begin{align} 5x - z = 0 \\[4pt] x - 3y = 0 \end{align}

Now we can find x, y and z in terms of one of those. It works out nicely if we let $y = 1,$ then $x = 3$ and $z = 5x = 15.$

Then w can be found from the first of the original equations:

\begin{align} w &= x - 2y - z = 0 \\[4pt] &= 3 - 2 - 15 = 15 \end{align}

So one version of our orthogonal vector (the differ only in length) is

$$v = (w, x, y, z) = (-14, 3, 1, 15)$$

In order to normalize this vector, we need its length:

$$|v| = \sqrt{14^2 + 3^2 + 1 + 15^2} = \sqrt{431}$$

Our normalized orghogonal vector is

$$v_n = \left( \frac{-14}{20.76}, \frac{3}{20.76}, \frac{1}{20.76}, \frac{15}{20.76},\right),$$

where $20.76 \approx \sqrt{431}.$

3. $(2, 1, -2, -1), \; (1, 1, -1, 2), \; (0, 1, 1, 1)$

Solution

In this case we'll need to set up and solve three equations for our four unknowns. They are

\begin{align} (2, 1, -2, -1)\cdot (w, x, y, z) &= 0 \rightarrow 2w + x - 2y - z = 0 \\[5pt] (1, 1, -1, 2)\cdot (w, x, y, z) &= 0 \rightarrow w + x - y + 2z = 0 \\[5pt] (0, 1, 1, 1) \cdot (w, x, y, z) &= 0 \rightarrow x + y + z = 0 \end{align}

Now let's use the last equation to eliminate z in the first two, adding it to the first, subtracting 2 × it from the second to get:

\begin{align} 2w + 2x - y &= 0 \\[5pt] -2w + 2x + 6y &= 0 \end{align}

Now add these to eliminate w and find a direct relationship between x and y:

$$4x + 5y = 0 \rightarrow x = \frac{-5}{4}$$

If we let $x = 1,$ then $y = \frac{-5}{4}.$

Now we can use one of the equations above to find w:

$$w = x + 3y = -\frac{5}{4} + 3 = \frac{7}{4}$$

Finally, we can use the last of our original equations to find z:

$$z = -x - y = \frac{5}{4} - 1 = \frac{1}{4},$$

So our vector is

$$v = \left( \frac{7}{4}, \frac{-5}{4}, 1, \frac{1}{4} \right)$$

Its length is $\sqrt{91}/4,$ so we obtain the normalized (unit length) vector by dividing each component of our orthogonal vector by this length.

\begin{align} v_n &= \left( \frac{7}{4}\frac{4}{\sqrt{91}}, \frac{-5}{4}\frac{4}{\sqrt{91}}, 1\frac{4}{\sqrt{91}}, \frac{1}{4}\frac{4}{\sqrt{91}} \right) \\[5pt] &= \left( \frac{7}{\sqrt{91}}, \frac{-5}{\sqrt{91}}, \frac{4}{\sqrt{91}}, \frac{1}{\sqrt{91}} \right) \end{align}

Calculate the angle (in degrees) between these pairs of vectors.

1. $(1, 2), \; (-1, 3)$

Solution

Let $a = (1, 2)$ and $b = (-1, 3).$ Then

$$\theta = cos^{-1}\left( \frac{a\cdot b}{|a||b|} \right)$$

\begin{align} |a| &= \sqrt{1^2 + 2^2} = \sqrt{5} \\[5pt] |b| &= \sqrt{(-1)^2 + 3^2} = \sqrt{10} \\[5pt] a \cdot b &= 1(-1) + 2(3) = 5 \\[5pt] \theta &= cos^{-1}\left( \frac{5}{\sqrt{5}\sqrt{10}} \right) \\[5pt] &= cos^{-1} \left( \frac{\sqrt{2}}{2} \right) = \frac{\pi}{4} \end{align}

So the angle is 45˚. Let me expand that last step a bit. It was a way of recognizing a familiar sine or cosine value:

$$\require{cancel} \frac{5}{\sqrt{5}\sqrt{10}} = \frac{\cancel{\sqrt{5}}\sqrt{5}}{\cancel{\sqrt{5}}\sqrt{10}} = \frac{\sqrt{5}}{\sqrt{10}} = \sqrt{\frac{1}{2}} = \frac{\sqrt{2}}{2}$$

2. $(1, -1), \; (-1, 1)$

Solution

Let $a = (1, 1)$ and $b = (1, -1).$ Then

$$\theta = cos^{-1}\left( \frac{a\cdot b}{|a||b|} \right)$$

These vectors both have length $|a| = |b| = \sqrt{2},$ and the dot product is $a \cdot b = 1(1) + 1(-1) = 0,$ so the angle is

$$\theta = cos^{-1} \left( \frac{0}{\sqrt{2}}\right) = \frac{\pi}{2}$$

So the angle is 90˚. That's pretty clear from a graph of these two vectors. But it's good to solve problems we already know the answers to at first; it helps us to learn the method.

1. $(1, 2, -1), \; (2, 2, -3)$

Solution

Let $a = (1, 2, -1)$ and $b = (2, 2, -3).$ Then

$$\theta = cos^{-1}\left( \frac{a\cdot b}{|a||b|} \right)$$

\begin{align} |a| &= \sqrt{1 + 4 + 1} = \sqrt{6} \\[5pt] |b| &= \sqrt{4 + 4 + 9} = \sqrt{17} \\[5pt] a \cdot b &= 1(2) + 2(2) + (-1)(-3) = 9 \\[5pt] \theta &= cos^{-1}\left( \frac{9}{\sqrt{6}\sqrt{17}} \right) \\[5pt] &= cos^{-1} \left( \frac{9}{\sqrt{102}} \right) \approx 27˚ \end{align}

2. $(1, 1, 2, 1), \; (-2, 1, -1, 1)$

Solution

Let $a = (1, 1, 2, 1)$ and $b = (-2, 1, -1, 1).$ Then

$$\theta = cos^{-1}\left( \frac{a\cdot b}{|a||b|} \right)$$

\begin{align} |a| &= \sqrt{1 + 1 + 4 + 1} = \sqrt{7} \\[5pt] |b| &= \sqrt{4 + 1 + 1 + 1} = \sqrt{7} \\[5pt] a \cdot b &= 1(-2) + 1(1) + 2(-1) + 1(1)= -2 \\[5pt] \theta &= cos^{-1}\left( \frac{-2}{\sqrt{7}\sqrt{7}} \right) \\[5pt] &= cos^{-1} \left( \frac{-2}{7} \right) \approx 107˚ \end{align}

It's difficult to visualize these vectors in a 4-dimensional space, but the angle between them is 107˚.

### Vector transpose approach

There is another very valuable way to approach the dot product. It's the matrix product of the transpose of a vector with the vector itself. First, the transpose:

The transpose $(\, {\vec v}^T \,)$ of a vector is obtained by rewriting a column vector as a row or a row vector as a column.

Here are some examples. Let $\vec a = (a_1, a_2)$ and $\vec b = \left(\begin{matrix} b_1 \\ b_2 \end{matrix} \right)$. $\vec a$ is a row vector and $\vec b$ is a column vector. We write the transposes of these vectors as $\vec a^T$ and $\vec b^T$. Then we have

\begin{align} \vec a = (a_1, a_2) \phantom{0000} \vec a^T &= \left( \begin{matrix} a_1 \\ a_2 \end{matrix} \right) \\[5pt] \vec b = \left(\begin{matrix} b_1 \\ b_2 \end{matrix} \right) \phantom{0000} \vec b^T &= (b_1, b_2) \end{align}

Just as an aside, we can write the transpose of a matrix, too. Just consider a matrix as a row of column vectors or a column of row vectors. Here's a 2×2 example:

$$A = \left( \begin{matrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{matrix} \right) \phantom{000} A^T = \left( \begin{matrix} a_{11} & a_{21} \\ a_{12} & a_{22} \end{matrix} \right)$$

Now we make two slight changes to our thinking about vectors and the dot product.

1. We write all vectors, by default, as column vectors. Let's let the column vector be our natural way to write any vector.
2. The dot product of vectors $\vec a$ and $\vec b$ is then $\vec a^T \vec b$.

That is, if $\vec a = \left( \begin{matrix} a_1 \\ a_2 \end{matrix} \right)$ and $\vec b = \left( \begin{matrix} b_1 \\ b_2 \end{matrix} \right)$, then the dot product $\vec a \cdot \vec b$ is

$$\vec a \cdot \vec b = \vec a^T \vec b = (a_1, a_2) \left( \begin{matrix} b_1 \\ b_2 \end{matrix} \right) = a_1 b_1 + a+2 b_2$$.

### Example 4

Calculate the dot product of the 3-space vectors $\vec x = \left( \begin{matrix} 1 \\ 2 \\ -3 \end{matrix} \right)$ and $\vec y = \left( \begin{matrix} -2 \\ 2 \\ 3 \end{matrix} \right)$

Solution: The dot product is $\vec x^T \vec y$,

$$= (1, 2, -3) \left( \begin{matrix} -2 \\ 2 \\ 3 \end{matrix} \right) = 1(-2) + 2(2) - 3(3) = -7$$

This form of the dot product works for any two vectors of any dimension as long as they're the same dimension.

Matrix multiplication works in the same way: we simply multiply each row vector in the left-side matrics by each column vector in the right-side matrix.

#### Vectors

Back up and review vectors, then come back and learn the dot product.

#### The cross product

The cross product is related to the dot product.

xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2012, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to jeff.cruzan@verizon.net.
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 27, "equation": 0, "x-ck12": 0, "texerror": 0}