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

Vector dot product and vector length

Definitions of the vector dot product and vector length. Created by Sal Khan.

Want to join the conversation?

  • blobby green style avatar for user davejroach
    Why learn to do calculations using more than three dimensions if anything more than 3D is just theoretical?
    (81 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user scikud00
    SO...whats the intuition behind scalar/dot product I mean was it just defined that way and what exactly is the point of producing a seemingly arbitrary scalar from two vectors? What function does this new scalar serve?
    (57 votes)
    Default Khan Academy avatar avatar for user
  • leaf grey style avatar for user Arnold Yu
    i still don't understand exactly, what IS a vector????
    (13 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user David Sprague
      More generally, a vector is just a collection of values. If the vector contains 3 values then we say that it's dimension is 3. In physics and geometry/trigonometry we talk about vectors having a magnitude and direction but you can also use vectors to hold other kinds of values. For example, if you were analyzing financial data, a vector might hold several characteristics of a company (e.g. Market Value, Number of Employees, Last Year Income, Last Year Profit, Number of years in business). See this video in the series:

      http://www.khanacademy.org/video/linear-algebra--introduction-to-vectors

      starting at time to see the formal definition of a vector.
      (42 votes)
  • blobby green style avatar for user awakil134
    is there any relation between the dot product of two vectors and cosine the angle between them?
    (9 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Helene Tate
    How do you take the dot product of three vectors?
    (7 votes)
    Default Khan Academy avatar avatar for user
    • primosaur ultimate style avatar for user Derek M.
      You can't. When you take a dot product, it converts two vectors into a scalar. Attempting another dot product after that is impossible, because you would be trying to dot a scalar with a vector, which violates the definition of the dot product.
      (19 votes)
  • blobby green style avatar for user Patrik
    Why is the dot product a•b = a1b1+a2b2+...+anbn?
    Is it just randomly difined as such or is there a proof that it has to be this?
    (10 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user Peter Barke
      I prefer to think of the dot product as a way to figure out the angle between two vectors.
      If the two vectors form an angle A then you can add an angle B below the lowest vector, then use that angle as a help to write the vectors' x-and y-lengts in terms of sine and cosine of A and B, and the vectors' absolute values.
      If you do that then you will end up with the equation a·b = |a|·|b|·cos(A).
      (5 votes)
  • leaf green style avatar for user Antony Paul
    How do I find the component of a vector in a certain direction using dot product?
    (6 votes)
    Default Khan Academy avatar avatar for user
    • old spice man green style avatar for user newbarker
      This is where projections come in. If you have a vector a that you want to project onto a direction given by vector b, you use (a · b)b/(b · b) [that is a dot b over b dot b all multiplied by b]. Note that b · b is the square length of b, so we can write (a · b)b/b², or some might prefer the notation (a · b)b/||b||².

      Later on in the Linear Algebra playlist, Sal goes through projections. I can't recommend this MIT lecture highly enough for projections though: http://www.youtube.com/watch?v=Y_Ac6KiQ1t0
      (10 votes)
  • leaf green style avatar for user InquisitiveLearner
    How is it possible for two quantities with direction to have a product that does not have one? If we take two vectors and multiply them using both dot and cross methods then will the solutions vary? Or should we use dot and cross products for different situations? If so, how do we figure out?
    (1 vote)
    Default Khan Academy avatar avatar for user
    • leaf red style avatar for user Ralph Schraven
      You shouldn't think of the dot and cross product as "multiplication". Taking a dot product is taking a vector, projecting it onto another vector and taking the length of the resulting vector as a result of the operation. Simply by this definition it's clear that we are taking in two vectors and performing an operation on them that results in a scalar quantity.
      We could have defined an operation that takes in two vectors and returns true if they are perpendicular, false otherwise. Then you'd have an operation that takes in two vectors and results in a boolean value. My point being that you can take any parameter types and return any desired type independently. I don't see how the types are related!
      (9 votes)
  • purple pi purple style avatar for user mihir.borkar
    What can you use the dot product for?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • old spice man green style avatar for user newbarker
      One application is detecting orthogonality/perpendicularity of vectors if the dot product is zero.

      If you divide the dot product by the lengths of the vectors, you're left with the cosine of the angle between the vectors, so the arc cosine of this will be the angle.
      (4 votes)
  • leaf green style avatar for user Russell Palmer
    Can you reduce the problem to the A-vector in the brakets squared, equal to simple A-vector ^2
    (5 votes)
    Default Khan Academy avatar avatar for user

Video transcript

We've already made a few definitions of operations that we can do with vectors. We've defined addition in the context of vectors and you've seen that. If you just have two vectors, say a1, a2, all the way down to a n. We defined the addition of this vector and let's say some other vector, b1, b2, all the way down to bn as a third vector. If you add these two, we defined the addition operation to be a third-- you will result in a third vector where each of its components are just the sum of the corresponding components of the two vectors you're adding. So it's going to be a1 plus b1, a2 plus b2, all the way down to a n plus bn. We knew this and we've done multiple videos where we use this definition of vector addition. We also know about scalar multiplication. Maybe we should just call it scaling multiplication. And that's the case of look, if I have some real number c and I multiply it times some vector, a1, a2, all the way down to a n, we defined scalar multiplication of a vector to be-- some scalar times its vector will result in essentially, this vector were each of its components are multiplied by the scalar. ca1, ca2, all the way down to c a n. And so after seeing these two operations, you might be tempted to say, gee, wouldn't it be nice if there was some way to multiply two vectors. This is just a scalar times a vector, just scaling it up. And that's actually the actual effect of what it's doing if you visualize it in three dimensions or less. It's actually scaling the size of the vector. And we haven't defined size, very precisely just yet. But you understand at least this operation. For multiplying vectors or taking the product, there's actually two ways. And I'm going to define one of them in this video. And that's the dot product. And you signify the dot product by saying a dot b. So they borrowed one of the types of multiplication notations that you saw, but you can't write across here. That'll be actually a different type of vector multiplication. So the dot product is-- it's almost fun to take because it's mathematically pretty straightforward, unlike the cross product. But it's fun to take and it's interesting because it results-- so this is a1, a2, all the way down to a n. That vector dot my b vector: b1, b2, all the way down to bn is going to be equal to the product of each of their corresponding components. So a1 b1 added together plus a2 b2 plus a3 b3 plus all the way to a n, bn. So what is this? Is this a vector? Well no, this is just a number. This is just going to be a real number. You're just taking the product and adding together a bunch of real numbers. So this is just going to be a scalar, a real scalar. So this is just going to be a scalar right there. So in the dot product you multiply two vectors and you end up with a scalar value. Let me show you a couple of examples just in case this was a little bit too abstract. So let's say that we take the dot product of the vector 2, 5 and we're going to dot that with the vector 7, 1. Well, this is just going to be equal to 2 times 7 plus 5 times 1 or 14 plus 6. No, sorry. 14 plus 5, which is equal to 19. So the dot product of this vector and this vector is 19. Let me do one more example, although I think this is a pretty straightforward idea. Let me do it in mauve. OK. Say I had the vector 1, 2, 3 and I'm going to dot that with the vector minus 2, 0, 5. So it's 1 times minus 2 plus 2 times 0 plus 3 times 5. So it's minus 2 plus 0 plus 15. Minus 2 plus 15 is equal to 13. That's the dot product by this definition. Now, I'm going to make another definition. I'm going to define the length of a vector. And you might say, Sal, I know what the length of something is. I've been measuring things since I was a kid. Why do I have to wait until a college level or hopefully you're taking this before college maybe. But what is now considered a college level course to have length defined for me. And the answer is because we're abstracting things to well beyond just R3 or just three-dimensional space is what you're used to. We're abstracting that these vectors could have 50 components. And our definition of length will satisfy, will work, even for these 50 component vectors. And so my definition of length-- but it's also going to be consistent with what we know length to be. So if I take the length of a and the notation we use is just these double lines around the vector. The length of my vector a is equal to-- and this is a definition. It equals the square root of each of the terms, each of my components, squared. Add it up. Plus a2 squared plus all the way to plus a n squared. And this is pretty straightforward. If I wanted to take let's call this was vector b. If I want to take the magnitude of vector b right here, this would be what? This would be the square root of 2 squared plus 5 squared, which is equal to the square root of-- what is this? This is 4 plus 25. The square root of 29. So that's the length of this vector. And you might say look, I already knew that. That's from the Pythagorean theroem. If I were to draw my vector b-- let me draw it. Those are my axes. My vector b if I draw it in standard form, looks like this. I go to the right 2. 1, 2. And I go up 5. 1, 2, 3, 4, 5. So it looks like this. My vector b looks like that. And from the Pythagorean theorem you know look, if I wanted to figure out the length of this vector in R2, or if I'm drawing it in kind of two-dimensional space, I take this side which is length 2, I take that side which is length 5; this is going to be the square root from the Pythagorean theorem of 2 squared plus 5 squared. Which is exactly what we did here. So this definition of length is completely consistent with your idea of measuring things in one-, two- or three-dimensional space. But what's neat about it is that now we can start thinking about the length of a vector that maybe has 50 components. Which you know, really to visualize it in our traditional way, makes no sense. But we can still apply this notion of length and start to maybe abstract beyond what we traditionally associate length with. Now, can we somehow relate length with the dot product? Well what happens if I dot a with itself? What is a dot a? So that's equal to-- I'll just write it out again. a1, all the way down to a n dotted with a1 all the way down to a n. Well that's equal to a1 times a1, which is a1 squared. Plus a2 times a2. a2 squared. Plus all the way down, keep doing that all the way down to a n times a n, which is a n squared. But what's this? This is the same thing as the thing you see under the radical. These two things are equivalent. So we could write our definition of length, of vector length, we can write it in terms of the dot product, of our dot product definition. It equals the square root of the vector dotted with itself. Or, if we square both sides, we could say that our new length definition squared is equal to the dot product of a vector with itself. And this is a pretty neat-- it's almost trivial to actually prove it, but this is a pretty neat outcome and we're going to use this in future videos. So this is an introduction to what the dot product is, what length is. In the next video I'm going to show a bunch of properties of it. It will almost be mundane, but I want to get all those properties out of the way, so we can use them in future proofs.