# The dot product

#### Prerequisites

The dot product is useful when only one part of a vector plays a physical role — the part that is in the same direction as another vector. One example is the work. That's basically how a force changes the magnitude (rather than the direction) of an object's velocity. We can get that by taking the part of the force in the direction of the velocity (dot producting the force with the displacement). We can figure out the math of this product either geometrically or algebraically.

## Geometrical approach

The dot product is defined to give the product of two vectors projected on one another. That is, if we want to take the dot product of two vectors, $\overrightarrow{A}$ and $\overrightarrow{B}$** **, we can take the part of $\overrightarrow{A}$ that is in the direction of $\overrightarrow{B}$ and multiply it by the length of$\overrightarrow{B}$

*;*or we can take the part of $\overrightarrow{B}$ that is in the direction of $\overrightarrow{A}$ and multiply it by the length of $\overrightarrow{A}$.

A carefully drawn figure can help us see how this works.

Decomposing using the left diagram gives us the part of $\overrightarrow{A}$ parallel to $\overrightarrow{B}$ times the length of $\overrightarrow{B}$, or $A_{||}\times B$. Decomposing the $\overrightarrow{B}$ vector along or perpendicular to $\overrightarrow{A}$ gives us the right diagram, and the length of $\overrightarrow{A}$ times the part of $\overrightarrow{B}$ in the same direction as $\overrightarrow{A}$: $A\times B_{||}$

Since $A_{||} = A \cos{\theta}$ and since $B_{||} = B \cos{\theta}$, our dot product in either case is

$$\overrightarrow{A}\cdot\overrightarrow{B} = AB \cos{\theta}$$

where $\theta$* *is the angle between the two vectors.

## Algebraic approach

Instead of using geometry to get the dot product, we can use algebra. Since we want the dot product to be the parts of two vectors that are in the same direction, we define the dot product of the basic vectors, $\hat{i}, \hat{j}$ (and $\hat{k}$ if we are in 3D rather than 2D) as being 1 if they are the same and 0 if they are different. So we define the dot product between two vectors by the rules:

$$\hat{i}\cdot\hat{i} = \hat{j}\cdot\hat{j} = 1$$

$$\hat{i}\cdot\hat{j} = \hat{j}\cdot\hat{i} = 0$$

Since dot products are products of vectors — not numbers — any numbers multiplying them don't do anything special. So we can work this all out just multiplying as usual using the distributive rule and noting that for any vector, $\overrightarrow{A}$, the dot product with the unit vectors are the vector's components:

$$\overrightarrow{A}\cdot\hat{i} = A_x \;\;\;\;\;\overrightarrow{A}\cdot\hat{j} = A_y$$

Then we can take the dot products of two vectors with each other by just multiplying them out and using the distributive rule.

$$\overrightarrow{A}=A_x\hat{i}+A_y\hat{j} \;\;\;\;\; \overrightarrow{B}=B_x\hat{i}+B_y\hat{j}$$

$$\overrightarrow{A}\cdot\overrightarrow{B}= (A_x\hat{i}+A_y\hat{j})\cdot(B_x\hat{i}+B_y\hat{j})$$

$$\overrightarrow{A}\cdot\overrightarrow{B}=A_x\hat{i}\cdot(B_x\hat{i}+B_y\hat{j} + A_y\hat{j}\cdot(B_x\hat{i}+B_y\hat{j})$$

$$\overrightarrow{A}\cdot\overrightarrow{B}=A_xB_x\hat{i}\cdot \hat{i} + A_xB_y\hat{i}\cdot \hat{j} +A_yB_x\hat{j}\cdot \hat{i} + A_yB_y\hat{j}\cdot \hat{j}$$

Well that's a royal mess! But it kind of makes sense. It's all possible products of the components of $\overrightarrow{A}$ with those of $\overrightarrow{B}$ multiplied by the dot products of the appropriate directions.

The result, using our rules for the dot products of the basic $\hat{i}$ and $\hat{j}$ vectors now collapses everything! All the terms with both an $\hat{i}$ and a $\hat{j}$ drop out and the other terms just become 1. The result is rather simple and elegant:

$$\overrightarrow{A}\cdot\overrightarrow{B}=A_xB_x + A_yB_y$$

You can imagine what the result would be if we were in 3D — you just keep the z-terms as well (as shown in our overview page, Multiplying vectors).

Showing that this result is the same as what we got by our geometrical argument is an exercise in trigonometric identities so we won't go through it here, but you're welcome to try! (Since the dot product is a scalar, it doesn't matter what x-y coordinate system you use so just pick the one with the +x-axis aligned along $\overrightarrow{A}$. Then it's easy!)

Joe Redish 11/6/11