hi everyone welcome back in this section we're going to introduce the dot product for two vectors so we're going to start with a concrete problem we want to find the angle between these two vectors so let's get a sketch for what these vectors look like so our first vector a has x component our first component three it has a zero for the y component and a four one two three 4 for the z component so there is the corresponding point 3 0 4 and we're looking at a as the position vector for that point so there's our vector a in the diagram and we've also got this vector b so b has components 0 4 and 3. so 1 2 four and three along the z axes so we can draw it as the position vector for that point zero four three so that's our vector b and what we are interested in is the angle between these two vectors what is the angle between them now with three dimensions sometimes it's difficult to get your head around us to what the angle between two vectors r in order to just imagine how would i envision this angle so let's just look at a demo so here i've got the two vectors drawn there's a and b and we're interested in the angle between them so what would the angle between them be well the idea is that these two vectors they form a plane and so if we look at the plane that they both live in then now it makes sense to talk about the angle between them in terms of it's just the angle between the two line segments in this plane so it would be that angle there so that is the angle we are interested in finding just looking at it from a few different angles a few different viewpoints so that's the angle we are interested in finding the angle between vector a and vector b so how can we do this well that's going to be our concrete motivating problem for this section we'll come back to this problem in just a second i'm now going to introduce the dot product of two vectors and it turns out that the dot product is connected to the angle between two vectors as we will see so here's the definition of the dot product of two vectors so what is a dot product is just a way of taking two vectors as inputs and then combining them together in some way to produce in this case a scalar so we call this the dot product it's also known as the scalar product of these two vectors so what is the dot product it's defined to be just the product of their corresponding components added together so it's the product of their first components a1 and b1 plus the product of their second components a2 b2 plus the product of the third components a3 and b3 you can also see how then this could drop down to a dot product of two dimensional vectors we just multiply their corresponding components and add them up in this case it would be a1b18 plus a2b2 or we could extend this dot product to higher dimensional vectors by just continuing on multiplying corresponding components and adding them up so here's the definition for the dot product for three dimensional vectors but it can be applied to any number of dimensions so let's just do a quick example where we compute a dot product so we'll take the dot product of a and b and for that we just multiply their corresponding components the first component of a is 5 that's times negative 3 which is the first component of b and then we get the 7 times 4 plus the 0 times 2. and so that's negative 15 plus 28 and then there's a zero there and so that's a value of 13.
so that's a calculation of a dot product that's the definition of the dot product and also in this case an example of how to calculate it now one question you may ask is what does the number 13 actually mean we get a product of 13 what does that actually mean in terms of the original two vectors what is this value that comes out what does it tell us about the original two vectors and that's what we're going to get into and explore in this section so first we will list a few properties of the dot product the properties of the dot product just follow straight from the definition so if we look at taking a vector and dotting it with itself basically we're just summing up the squares of each of its components and that's precisely the definition of the square of the length so we get that first property pretty much just by thinking about what we do for the dot product and what we do to compute a length a dot b is the same as b dot a so it doesn't matter which order you take the dot product of two vectors in you'll get the same result so in our example above if you were to take b dot a all that would happen is in each of the products these values would just switch spots and because multiplication is commutative it doesn't matter if you multiply two numbers you know for example 5 times negative 3 is the same as negative 3 times 5. so order doesn't matter there and and that trickles on through to tell me that in the order of the vectors in the dot product doesn't matter the third property is that if we dot a with a sum of vectors we can dot it with the individual vectors and add them up this is a distributive property so i'll write this down distributive property this tells us how a dot product distributes over a sum property number four is that if we scale or multiply a vector and then dot it with another one that scalar could really float around and be put anywhere we could take the dot product to the two vectors first then multiply by the scalar or we could have multiplied the vector b by the scalar and then dotted it with a and the last property is if you dot any vector with the zero vector you get the zero scalar you get zero so those are properties of the dot product now they may not look very surprising they just really just follow from the definition but the power comes in as to what you can do with them and so now we're going to use those results to prove this geometric interpretation of the dot product this is the connection the dot product is connected with the angle between the two vectors and that's what we're going to show now so if theta is the angle between the two vectors a and b then the dot product is equal to the magnitude of the two vectors multiplied together times cosine of the angle between those two vectors let's go ahead and prove that this is the case so maybe i'll write down here proof now the way we're going to show it the way we're going to justify this is we're going to use the law of cosines and if you don't remember what the law of cosines is the law of cosines is really just a generalization of the pythagorean theorem so relating the lengths of three sides of a triangle but in this case the triangle doesn't necessarily have to be a right triangle it doesn't have to contain a right angle so here's our picture that we're going to look at we got our vector a we've got our vector b we've got the angle between them that we're interested in finding that alone doesn't make a triangle but we can introduce a third side to this the third side i will introduce i'll introduce it as a vector and it's the vector b minus a and so now i've got this triangle and i can use the law of cosines to relate the lengths of the sides of this triangle so by the law of cosines what do we have well it's the length of the side opposite the angle that we are interested in so that's the length of the side opposite the angle actually it's a square of the length of the side opposite the angle is equal to the sums of the squares of the two side lengths adjacent to the angle so this is really the pythagorean theorem if theta was a right angle but since theta's not necessarily a right angle we can't assume it we're interested in finding theta whatever it is then there's this adjustment factor and this is the law of cosines adjustment factor from the pythagorean theorem 2 times so minus 2 times the length of those two sides adjacent to the angle so 2 times the length of a length of b cosine of the angle between them so that's the law of cosines and that gives us a relationship between the lengths of the sides of this triangle and the angle this one angle theta so now let's unpack this we're going to use the properties above to relate the dot product to the links so i've got a length of b minus a all squared well that's just b minus a dotted with itself so dot b minus a and then i've got the length of a squared plus the length of b squared minus 2 times the length of a length of b cosine of theta all right now we're going to work out the dot product we're going to use the distributive property if i think of this as a single vector i can distribute it across there so that would be b minus a dot b minus b minus a dot a so that's the first application of the distributive property and then i'll just fill in the right hand side and then again we're going to use a distributive property in this case i'm going to distribute this b across that difference and you may say well we don't have a distributive property that lists that we can distribute across from the right and the idea is well we do you just have to realize that it's a combination of that one and that one so this becomes b dot b minus a dot b minus b dot a and then plus a dot a and that's equal to the magnitude of a squared plus the magnitude of b squared minus 2 magnitude of a magnitude of b cosine of theta and now what do we get well a dot a that's the magnitude of a all squared so that would cancel with that and then i also have b dot b well that's just the magnitude of b squared and that's appearing on the right hand side so those would cancel and then i have a b dot a and an a dot b but those are the same those are both equal to a dot b and there's negative two of them on that side so this boils down to negative two a dot b is equal to negative 2 the length of a length of b cosine of theta and now i can cancel off the negative 2s from each side and i get a dot b is equal to the magnitude of a magnitude of b cosine of theta and that's what we wanted to prove the dot product of two vectors is exactly the length of the two vectors multiplied to each other times the cosine of the angle between them so to answer our question from before and i computed the dot product of these two vectors up above i got an answer of 13. what does that 13 represent well that's the magnitude of a times the magnitude of b times cosine of the angle between them so if i divided 13 by the length of a and the length of b then what i end up with is just cosine of the angle between them and so that allows me to compute the angle between them all right so from that geometric interpretation if we divide both sides by the length of a and length of b what we get is cosine of theta is the dot product of a and b divided by the product of their lengths so let's go ahead and use this result to find the angle between a and b the cosine of that angle is the dot product of a and b divided by their lengths the dot product of them is 3 times 0 which is 0 plus 0 times 4 which is 0 plus 4 times 3 which is 12 divided by the length of a which is not square root of 9 plus 16.
and the length of b which is the square root of 16 plus 9 and so that's 12 over root 25 times root 25 or 25. so we have that theta is equal to arc cosine or cos inverse however you like to say it of 12 over 25 so there's the angle between them if you wanted to get an estimate for you know an approximate value for this you can use a calculator computer to go ahead and work out some decimal approximation all right what else what else do we get from this formula for the angle between two vectors involving the dot product well what we get is that if we have two non-zero vectors so two nonzero vectors they are perpendicular if and only if their dot product is zero so why is that the case well they're perpendicular so we use a little upside down t to read perpendicular so a is perpendicular to b if and only if the angle between them is pi by 2. so we're using radian measure here if you want to use degrees the angle between them would be 90 degrees so they're perpendicular the angle between them is 90 degrees or pi by 2 radians but that happens precisely when cosine of the angle between them is 0 and that's because when we talk about the angle between two vectors it's a value between zero and pi so the only value between zero and pi that has a cosine of zero is precisely pi by two so they're perpendicular precisely when cosine of the angle between them is zero and since the two vectors are non-zero then that happens precisely when the length of a times the length of b times cosine of the angle between them is zero and that is precisely the dot product and so i read my implications from start to finish and i get that that the two vectors are perpendicular precisely when their dot product is zero so that's a nice way to check whether two vectors are perpendicular or another way to phrase this this is a condition that two vectors have to satisfy in order to be perpendicular and we're going to use this over and over again so let's just try it for our first example let's check are a and b perpendicular well we take the dot product and we get 3 times 2 which is 6 minus 16 plus 10 oh that's 16 minus 16 or zero so the answer is yes a is perpendicular to b now the last thing i want to introduce when talking about the dot product is this idea of projection so in this definition we have two kinds of projection a scalar projection and a vector projection rather than go into the individual formulas here we'll get a feel for what the idea is we're trying to capture so we've got a vector b we've got another vector a and the idea is to take that vector b and break it up into the sum of two vectors one vector that's parallel to a and one vector that's perpendicular to a the vector that's perpendicular to a i'll just call it w the one that's parallel to a since it's parallel to a we can write it as some c times a for some scalar c and our goal is to figure out what is the value of this scalar c so how do we find the value of c well the first thing we do is write down the vector b as this decomposition into these two pieces it's c times a plus w where c is some real number and w is a vector perpendicular to a now once i've got that decomposition really that's the whole idea is i take b and i'm trying to write it in this way once i've got it written in this way i can dot it with the vector a so we'll dot with the vector a why are we dotting it with a because i'd like to find the value of c in this expression and that means i'd like to get rid of w w is perpendicular to a so if i dotted it with a i'd get 0.
so i take this equation i dot the left side with a i dot the right side with a and i get the a dot w part that is 0 because a is perpendicular to w so that means this boils down to a dot b is equal to and i can factor out that constant all the way out front i get an a dot a but a dot a is just the length of a squared so this equation can be solved for c and we get that c is equal to a dot b over the length of a squared that means then that the component of the vector b that is parallel to a which we've written here as c times a we actually know the value of c this vector is what we call the projection of b in the direction of a and we've just found that the projection of b in the direction of a which is c times a we've now found the value of c so it's a dot b over the length of a all squared times a and that's the formula we've given up here so that's what we refer to as the definition of the projection but now i've taken a step back and i've introduced or defined the projection in terms of that diagram and we verify that this is the formula that gives that particular vector we want now there's a couple of things to note with this uh the first thing is do these formulas depend on the length of a they shouldn't because if we think about what we're doing we're just taking b and we're saying how can i write it as a piece that's in the direction of a i don't care how long a is i don't care the length of a all i care about is the direction of a so how can i write b as a piece that points in the direction of a or is parallel to a and a piece that's perpendicular to a so it shouldn't depend on the length of a and it doesn't because we could rearrange this formula by grouping one of those lengths in the denominator with the a that's in the dot product and then the other length of a in the denominator will group with the vector on the right and both of these are unit vectors in the direction of a so these are unit vectors so the projection of b onto a it doesn't matter what the length of a is because we are normalizing them anyway in the formula so we normalize a and then we take the dot product of b with the unit vector in the direction of a and multiply that to the unit vector in the direction of a so this becomes our scalar this is essentially going to be the length of the part of b that's in the direction of a now i don't really want to call it the length because what if it was negative so this is a scalar and as i said it's in some sense trying to capture the length of the part of b in the direction of a but let's look a little bit more closely at that so what is the length of that part there well the length of that would be the magnitude of the projection of b onto a and if i look at that expression up above we see that there's a unit vector here and then we've got the scalar part and that scalar part is precisely going to be either the length of this vector or negative the length of this vector because it all depends on the sign of the dot product so now i've got absolute value signs on there and this is what we call the component of b in the direction of a we call it the component of b in the direction a and that is a dot b over the length of a and that can be positive or negative if the component of b parallel to a actually points in the same direction as a then this is a positive quantity this component is positive and in fact it gives us the length of the part of b that points in the direction of a if it's negative it just means that the part of b parallel to a is actually pointing in the opposite direction of a so the thing to observe with this formula here is that this piece this scalar is what we call the component of b in the direction of a and so that's our scalar and our vector projection let's have a look at an example where we use this so find the scalar and vector projection of this vector b onto a so we'll first look at the scalar projection so we're going to look for the component of b in the direction of a that's given by a dot b over the length of a a dot b that's given by 6 minus 2 plus four and the length of a is given by the square root of four plus one plus one so that is eight over root 6. so there is our component in the direction of a and for the projection vector of b in the direction of a we can work it out as a dot b over the magnitude of a squared times a or we could look at it as the component of b in the direction of a times a over the length of a we'll write it like this a dot b over the length of a squared well we've already done a dot b that was eight the length of a we already computed above that was root six so the square of it would be six and then we're multiplying by the vector a which is two one one and so this becomes 4 3 2 1 1.