Main content

### Course: Multivariable calculus > Unit 1

Lesson 2: Vectors and matrices# Dot products

Learn about the dot product and how it measures the relative direction of two vectors.

The dot product is a fundamental way we can combine two vectors. Intuitively, it tells us something about how much two vectors point in the same direction.

## Definition and intuition

We write the dot product with a little dot $\cdot $ between the two vectors (pronounced "a dot b"):

If we break this down factor by factor, the first two are $\Vert \overrightarrow{a}\Vert $ and $\Vert \overrightarrow{b}\Vert $ . These are the magnitudes of $\overrightarrow{a}$ and $\overrightarrow{b}$ , so the dot product takes into account how long vectors are. The final factor is $\mathrm{cos}(\theta )$ , where $\theta $ is the angle between $\overrightarrow{a}$ and $\overrightarrow{b}$ . This tells us the dot product has to do with direction.

Specifically, when $\theta =0$ , the two vectors point in exactly the same direction. Not accounting for vector magnitudes, this is when the dot product is at its largest, because $\mathrm{cos}(0)=1$ . In general, the more two vectors point in the same direction, the bigger the dot product between them will be.

When $\theta ={\displaystyle \frac{\pi}{2}}$ , the two vectors are precisely perpendicular to each other. This corresponds to the dot product between them being $0$ , because $\mathrm{cos}\left({\displaystyle \frac{\pi}{2}}\right)=0$ .

It's also possible for a dot product to be negative if the two vectors are pointing in opposite directions, which is when $\frac{\pi}{2}}<\theta <{\displaystyle \frac{3\pi}{2}$ .

Another way to think about $\theta $ is to imagine one vector dropping a shadow on to the other. When the angle is small, the shadow lands far from the origin and the dot product is large.

When $\theta $ is close to $\frac{\pi}{2}$ , the shadow lands close to the origin and the dot product is small.

Keep in mind that the dot product of two vectors is a number, not a vector. That means, for example, that it doesn't make sense to ask what $\overrightarrow{a}\cdot \overrightarrow{b}\cdot \overrightarrow{c}$ equals. Once we evaluated $\overrightarrow{a}\cdot \overrightarrow{b}$ to be some number, we would end up trying to take the dot product between a number and a vector, which isn't how the dot product works.

## A better way to compute the dot product

When we need to find a dot product in multivariable calculus, we typically have only the coordinates of $\overrightarrow{a}$ and $\overrightarrow{b}$ . Calculating $\Vert \overrightarrow{a}\Vert \Vert \overrightarrow{b}\Vert \mathrm{cos}(\theta )$ would force us to find two square roots and a cosine, which is a lot of work! Luckily, there is an easier way. Just multiply corresponding components and then add:

Although the example above features 3D vectors, this formula extends for vectors of any length.

This makes calculating dot products straightforward if you know the components of each vector.

Let's try an example.

Even though we now have a nice formula in terms of coordinates, the intuition behind the dot product remains how it measures relative direction. Try to predict the sign of the dot product based on just a picture.

That's all we'll need to know about dot products for now. If you want to learn more, check out this video.

## What's next

Now that we've covered the dot product, there's just one more vector operation to learn about: the cross product. As we'll see, the cross product nicely complements the dot product but is slightly more limited.

## Want to join the conversation?

*why do we use dot products? what can it be used for, like in computers or something?*(21 votes)- It can also be used in physics; like the mathematical definition of "Work" is the dot product of force * displacement (change in position AKA distance)

If you're wondering about cross products too, then a good example is that torque is the cross product of the force vector and the displacement vector from the point at which the axis is (the center of rotation) and the point and which force is applied.

Hope this helps!(5 votes)

- Any further hint about the proof of why is the dot product the sum of the product of the components? Can't really crack this nut.(6 votes)
- Hi Michele, here's an idea.

Referring to the diagram in the hint, expand out each norm as v*v = v_1*v_1 + ... + v_n*v_n. Note that this follows from the Pythagorean theorem, so it is not circular logic! (Make sure to square everything to get rid of nasty square roots.) When you get to the norm ||a-b||^2, you will get many terms because (a-b)*(a-b) expands out linearly into four dot products. Some of these will cancel out however...

Now write out what the Law of Cosines tells you: ||b-a||^2 = ||a||^2 + ||b||^2 - 2*||a||*||b||*cos(theta). Using your simplified expansions for ||b-a||^2, ||a||^2, and ||b||^2, cancel any remaining terms and move everything else to one side of the equation. Divide by 2 to find a new expression for ||a||*||b||*cos(theta).

What do you find?(11 votes)

- if the dot product is about how much two vector point in the same direction, why is the magnitude of the vectors a factor of the dot product? Shouldn't the angle between the two vectors be enough to decide whether they point in the similar direction or not. And when taking the dot product, how do you know whether to take the bigger angle or the smaller angle between the two vectors?(5 votes)
- cos(x)=cos(2pi-x) so it doesn't matter if you take the bigger angle or the smaller angle.(2 votes)

- Hello, everyone!

I get that dot products are scalars and thus have no direction, but are they just plain old numbers or do they have units? If they do, what kind of units do they have? If they don't, at what point in the process do they lose their units?

Thank you for any replies!(3 votes)- The units for the dot product of two vectors is the product of the common unit used for all components of the first vector, and the common unit used for all components of the second vector.

For example, the dot product of a force vector with the common unit Newtons for all components, and a displacement vector with the common unit meters for all components, would have units Newton-meters.(4 votes)

- dude i still can not understand how ||a||*||b||*cos(theta)=a1*b1+a2*b2...(3 votes)
- First, note that dot product is distributive over vector addition and subtraction, and dot product is commutative. So we can take dot products of sums and/or differences of vectors, just like we multiply binomials. Furthermore, it follows from the definition of dot product and the Pythagorean theorem that the dot product of a vector and itself is the square of its length.

The idea is to use the Law of Cosines. Consider any triangle with two sides generated by vectors a and b that form included angle theta. Then the third side is generated by the vector b-a.

From the Law of Cosines, we have

||b-a||^2 = ||a||^2 + ||b^2|| - 2||a|| ||b|| cos(theta)

(b-a) dot (b-a) = (a dot a) + (b dot b) - 2||a|| ||b|| cos(theta)

(b dot b) - 2(a dot b) + (a dot a) = (a dot a) + (b dot b) - 2||a|| ||b|| cos(theta)

-2(a dot b) = -2||a|| ||b|| cos(theta)

a dot b = ||a|| ||b|| cos(theta).(1 vote)