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.

Main content

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 between the two vectors (pronounced "a dot b"):
ab=abcos(θ)
If we break this down factor by factor, the first two are a and b. These are the magnitudes of a and b, so the dot product takes into account how long vectors are. The final factor is cos(θ), where θ is the angle between a and b. This tells us the dot product has to do with direction.
Specifically, when θ=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 cos(0)=1. In general, the more two vectors point in the same direction, the bigger the dot product between them will be.
When θ=π2, the two vectors are precisely perpendicular to each other. This corresponds to the dot product between them being 0, because cos(π2)=0.
It's also possible for a dot product to be negative if the two vectors are pointing in opposite directions, which is when π2<θ<3π2.
Another way to think about θ 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 θ is close to π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 abc equals. Once we evaluated ab 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 a and b. Calculating abcos(θ) 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:
a=(a1,a2,a3)b=(b1,b2,b3)ab=a1b1+a2b2+a3b3
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.
v=4ı^1ȷ^+2k^w=1ı^+2ȷ^+4k^vw=41+(1)2+24=10
Let's try an example.
Problem 1
What is the dot product of a=(1,3) and b=(5,2)?
Choose 1 answer:

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?
Choose 1 answer:

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?

  • leafers seed style avatar for user nathanielcrowley
    why do we use dot products? what can it be used for, like in computers or something?
    (21 votes)
    Default Khan Academy avatar avatar for user
    • mr pants teal style avatar for user shelbypup252
      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)
  • blobby green style avatar for user Michele
    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)
    Default Khan Academy avatar avatar for user
    • blobby green style avatar for user lakern
      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)
  • blobby green style avatar for user Aryan Pokhrel
    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)
    Default Khan Academy avatar avatar for user
  • stelly blue style avatar for user Romina M. Santoro
    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)
    Default Khan Academy avatar avatar for user
    • primosaur seed style avatar for user Ian Pulizzotto
      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)
  • blobby green style avatar for user zenin_acturion
    dude i still can not understand how ||a||*||b||*cos(theta)=a1*b1+a2*b2...
    (3 votes)
    Default Khan Academy avatar avatar for user
    • primosaur seed style avatar for user Ian Pulizzotto
      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)