 In our previous video, we introduced the idea of the dot product, but we did it purely algebraically. In this video, I want to give a geometric interpretation of what this dot product is doing. It's an easy algebraic calculation, but why bother doing it? Well, the first thing I want to mention here is that if you take the dot product of a vector with itself, this will give back its magnitude squared. Or you could also say that the magnitude of a vector v is equal to the square root of v dot v. So the dot product can recreate the magnitude of the vector, which the magnitude would be the length of the arrow. That is a geometric interpretation. Why is that? Well, it's actually a very simple formula to go with here. So if we said v was equal to, let's say its components are a and b, like so, then what is v dot v gonna do? Remember the dot product, you times the horizontal by the horizontal, so you get a times a. And then you add to that the product of the vertical times the vertical, so v times b. So you end up with a squared plus b squared, like so. But remember that the horizontal vertical components of a vector satisfies the Pythagorean relationship if you throw in, of course, the magnitude there, right? This is gonna equal the magnitude squared, again, by the Pythagorean relationship. And that's just finishes the argument right there. So the dot product of a vector with itself recaptures the magnitude, at least the magnitude squared. But taking square root simplifies that. Let me give you a little bit more sophisticated one. This one's even better. Suppose we have two different vectors and we take the dot product of u with v. Then this will equal the magnitude of u times the magnitude of v times cosine of theta. And so I want to mention that the previous result we just saw is a special case of this one right here. Because if u and u are the same vector here, then you'll get the magnitude twice, so the magnitude of u squared. And then you get cosine of zero degrees, because if it's the same vector, then the angle between them is nothing, right? And theta, I should mention, is the angle between the two vectors when they're in standard position there. Cosine of zero is one, so you just get back the original thing. So this is a generalization of that. And so the dot product captures the angle between the two vectors. People often do the following. If you solve for theta, you'll end up with arc cosine of u dot v over the magnitude of u times the magnitude of v, which these magnitudes could be expressed using dot products. So the dot product captures the angle between the two vectors. Now this right here, a product of two things times cosine of theta, this kind of looks a lot like a piece of the pi, not the Pythagorean equation, excuse me, it kind of looks like a piece of the law of cosines, which of course the Pythagorean equation is a special case of the law of cosines. In fact, in linear algebra, this formula right here is often referred to as the law of cosines because basically it's the linear algebraic equivalent of the law of cosines we've studied in this trigonometry course. And let me show you how that is. So note that the three vectors u v and u minus v form a triangle. Okay, so let's say we have our vectors. I'll draw a diagram to give some sense to it. So we have u right here and we have v right here. Then the difference vector, well, let's do u, let's do u minus v. So it always points to the direction here that comes first. So u minus v would look something like this. So these vectors form a natural triangle and the angle between v and u is an angle associated to this triangle right here. So if we give these vectors components, right, so let's say u is equal to a comma b and let's say v is equal to just the next letters in the alphabet there, c and d, right. So then we could set up the law of cosines with regard to this triangle right here. So we're going to get that the magnitude of u minus v squared is equal to the magnitude of u squared plus the magnitude of v squared minus 2 times u times v times cosine of this angle theta. So you'll notice this is what we're looking for right here, okay? So let's solve for this thing here. We're going to move this to the other side of the equation. We're going to subtract the u minus v squared. We've done this many times. So we get 2 times u v cosine theta. This equals u squared plus v squared minus u minus v squared like so. And we're going to divide both sides by 2. So this gives us the magnitude of u times the magnitude of v times cosine of theta. And this is going to equal 1 half. These things over here, absolute value of u plus the magnitude of v squared and then minus u minus v magnitude squared like so. So we get all these formulas right here. So now what we're going to do is apply the component forms we have right here, all right? So u squared, the magnitude of u squared, that's going to equal, we're going to end up with this a squared plus b squared. Remember these things, the magnitude squared, this is just equal to u dot u, which is a squared plus b squared. This one over here will just equal v dot v, which that would equal a c squared plus d squared like so. The next one takes a little bit more effort to do, but it is just going to equal, it should just equal u v dot u v for which we should be able to foil these things out, right? This is going to equal, what's the horizontal component of u minus v? The horizontal component of u minus v would be a minus c. So we get a minus c squared plus what's the vertical component? You're going to get b minus d squared. And so there's some foiling that could be going on there. We'll do that in just a second. So we're going to get minus a minus c squared plus b minus d squared like so. Just chasing the formulas around, pushing them through a little bit. And so what do we get here? We get a squared plus b squared plus c squared plus d squared minus, so if you foil out the a squared minus c squared, you end up with an a squared plus 2 a c minus c squared like so. I took the liberty of distributing the negative sign in there as well. Then for the next one, we'll end up with a minus b squared plus 2 b d, and then we're going to get a minus d squared like so. And so you'll notice there's some cancellation going on here. The a squared are gone. The b squareds are gone. Same thing with the c. Same thing with the d squared. And so everything that's left behind is equal to one half. We have what survived this massacre. We have a 2 a c. We have a 2 b d for which you get 2 a c plus 2 b d, which everything is divisible by 2. So you can cancel out. You end up with a c plus b d like so, which of course, this is the dot product of a b with c d. Wait, that's just the dot product of u and v like so. And so it's a lot of work going on there. But the important thing about recognizing that these things are the same thing is that this dot product, which is pretty easy to compute, is the same thing as u v cosine of theta. And we never have to do all of this work again in the middle because we now know they're the same thing. And so this is why this is called the law of cosines and linear algebras because the equation is essentially just the law of cosines plus a little bit of simplification. So let me then show you how you can use this. Let's compute the angle theta between two vectors u and v. So I have the vector u given a 6i minus j, and I have the vector v, which equals i plus 4j. So like I saw, like we saw before, theta is going to equal arc cosine of what was that again? You're going to take u dot v over u times v like so. So we have to find these magnitudes. So how do you do the dot product again? You multiply together the horizontal components, you get 6 times 1, which is 6, and then you get multiplied together the vertical components. Negative 1 times 4 is a negative 4, like so. We have to compute the magnitudes of these things, but the magnitude is just going to be the sum of the squares of the components. So you get 36 plus 1 for u, and then you're going to get the square root of 1 plus 16 for v. Try to simplify these things. You're going to get arc cosine of. In the top, you're going to get 6 minus 4, which is 2. In the denominator, you're going to get the square root of 37, and you're also going to get the square root of 17. Neither of those are perfect squares. So this gives you the exact form. Theta equals arc cosine of 2 over root 37 and root 17. Now put this into calculator, and if it's a degree mode, you would get 85.43 degrees if we round to the nearest 100th of a degree. And so that gives you the angle between the two vectors. Very simple formula, and we just have to do arc cosine at the end. Let's look at another example here. Let's take u to be 2, 3, and let's take v to be negative 3, 2. Let's compute the angle between them. Well, again, theta is going to equal arc cosine of u dot v over the length of u times the length of v, like so. So computing the dot product, you're going to get 2 times negative 3, which is negative 6, plus 3 times 2, which is 6 right there. And then I'm just going to pause there for a second because I can compute the lengths of u and v here, but I'm noticing the numerator there is going to be 0. And if your numerator is 0, then your denominator don't really matter too much anymore. That whole fraction is going to be 0. So you get arc cosine of 0, which if arc cosine is equal to 0, basically we're trying to say cosine theta is equal to 0. What does that mean? When is cosine equal to 0? That happens when theta is equal to 90 degrees, like so. So this would actually suggest that the vectors are perpendicular to each other. And this example kind of motivates our next theorem slash definition. Again, this is a very important geometric interpretation of the dot product, probably the most important one. If we have 2 vectors u and v, then their dot product equals 0 if and only if the vectors are perpendicular to each other. Because if the dot product equals 0, that would suggest that cosine of theta equals 0, like we saw, and that would imply that theta equals 90 degrees. So the dot product equals 0 exactly when the 2 vectors are perpendicular to each other. That is the angle between them is 90 degrees. As such, when 2 vectors, when their dot product is 0, we say they're perpendicular. Or in linear algebra, the term we typically use is orthogonal. You can take those as synonyms in this context. Perpendicular really is a geometric term. Orthogonal is an algebraic term. But again, because of this theorem, perpendicular and orthogonal mean the same thing. Orthogonal, the dot product is 0. Perpendicular means the angle between them is 90 degrees. Orthogonal vectors are perpendicular vectors. So how do we check to see if 2 vectors are orthogonal with each other? Let's take u and v, for example. Just compute their dot product, right? u dot v. This is going to equal 8 times 3, which is 24. And then you're going to subtract from it. 6 times 4, which is 24. That's equal to 0. So this tells us that u is perpendicular v. These 2 vectors are perpendicular to each other. That's super nice. What about u and w, right? So u is still 8 and 6. And then w is 4 and 3. If you take u dot w, you end up with 8 times 4, which is 32. And then you get 6 times 3, which is 18. Which admittedly, it's like that. There's no way that's going to be 0. But sure enough, it adds up to be 50. It's not 0, which means that u is not perpendicular to w. Like so. What about v and w? Could we do something like that? Well, again, it's the same thing. To check whether 2 vectors are perpendicular to each other, just do their dot products, right? 4 and 3 gives you 12. Minus 4 and 3, which is 12, again, just gives you 0. So, okay, v is, in fact, perpendicular to w, right? Because the dot product was equal to 0. So we can check to see if you have a right angle just using dot products. I want you to compare that to what we did earlier in the semester when we had a right triangle. We didn't know if it was a right triangle yet, so we tried to prove it using various techniques. In the end, it really just boils down to, if you wanted to know if you had a right triangle, you just had to compute dot products with vectors. And so the dot product is very efficient, very simple calculation that has huge geometric consequences. In particular, the dot product gives you the angle between two vectors, and thus you can very easily detect when vectors are perpendicular or not.