If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

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"):
$\stackrel{\to }{a}\cdot \stackrel{\to }{b}=‖\stackrel{\to }{a}‖‖\stackrel{\to }{b}‖\mathrm{cos}\left(\theta \right)$
If we break this down factor by factor, the first two are $‖\stackrel{\to }{a}‖$ and $‖\stackrel{\to }{b}‖$. These are the magnitudes of $\stackrel{\to }{a}$ and $\stackrel{\to }{b}$, so the dot product takes into account how long vectors are. The final factor is $\mathrm{cos}\left(\theta \right)$, where $\theta$ is the angle between $\stackrel{\to }{a}$ and $\stackrel{\to }{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}\left(0\right)=1$. In general, the more two vectors point in the same direction, the bigger the dot product between them will be.
When $\theta =\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(\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 <\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 $\stackrel{\to }{a}\cdot \stackrel{\to }{b}\cdot \stackrel{\to }{c}$ equals. Once we evaluated $\stackrel{\to }{a}\cdot \stackrel{\to }{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 $\stackrel{\to }{a}$ and $\stackrel{\to }{b}$. Calculating $‖\stackrel{\to }{a}‖‖\stackrel{\to }{b}‖\mathrm{cos}\left(\theta \right)$ 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:
$\begin{array}{rl}\stackrel{\to }{a}& =\left({a}_{1},{a}_{2},{a}_{3}\right)\\ \\ \stackrel{\to }{b}& =\left({b}_{1},{b}_{2},{b}_{3}\right)\\ \\ \stackrel{\to }{a}\cdot \stackrel{\to }{b}& ={a}_{1}{b}_{1}+{a}_{2}{b}_{2}+{a}_{3}{b}_{3}\end{array}$
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.
$\begin{array}{rl}& \stackrel{\to }{v}=4\stackrel{^}{ı}-1\stackrel{^}{ȷ}+2\stackrel{^}{k}\\ \\ & \stackrel{\to }{w}=1\stackrel{^}{ı}+2\stackrel{^}{ȷ}+4\stackrel{^}{k}\\ \\ & \stackrel{\to }{v}\cdot \stackrel{\to }{w}=4\cdot 1+\left(-1\right)\cdot 2+2\cdot 4=10\end{array}$
Let's try an example.
Problem 1
What is the dot product of $\stackrel{\to }{a}=\left(1,3\right)$ and $\stackrel{\to }{b}=\left(-5,2\right)$?

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.
Problem 2
Is the sign of the dot product between the two vectors positive, negative, or zero?

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?
• 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!
• 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.
• 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?
• 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?
• cos(x)=cos(2pi-x) so it doesn't matter if you take the bigger angle or the smaller angle.
• 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!
• 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.
• dude i still can not understand how ||a||*||b||*cos(theta)=a1*b1+a2*b2...
• 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).