Welcome to our lecture on the chain rule. The chain rule is one of the most important differentiation rules we're going to have in this class, we're going to use it over and over again. I promise you'll have it memorized by the time we get past this, you just need it to do almost everything in this class, but the idea now is we want to study the functions that are compositions. Let's define some big function, capital F to be the composition of f of g of x. I have one function and I compose it with another. Well, here it comes, folks, here's the chain rule, the derivative of this composition, which you'll see a couple of ways. You could see it as d, dx of f composed with g of x, they might use a little circle notation, either one is fine. But here it is, it is the derivative of the outside function, and we keep the inside function the same, multiplied, so times the derivative of the inside function. You can work this out using limit definition, it's a bit of a pain, but this is the idea. We're just going to state the rule, and then I just want you to get good at using it. The reason why is a lot of stuff, a lot of functions are composed with each other. It's pretty common to see sine of 2x or sine of cosine or e to the whatever. This is the one that we're going to use the most. It is important that we keep the inside the same, multiplied by the derivative of the outside function. I'll write this out a bunch of times as we go through the first one. This is a little prime by the way, it's Newton's notation. We're going to see it in its other form, so in leib, but it's notation. It looks something like this, if I have the function little y as my function, we can say the derivative of y, so y is now my function over here, dy dx becomes dy du, du dx. The variables are all dummy variables. You can think of it as y as a function of u, and then u is some function of g of x. This is just another way to write it. For the most part, for now at least, we're going to use Newton's notation with the primes. The way to get good at this one is to find lots of derivatives, here's your assignment, take the derivatives of a bunch of problems. We'll do these together, then I'm going to telling you to go off and pause the video and try some on your own, but let's start off with something like this. You can already see the value of the chain rule, I like this one a lot. When I show this to students for the first time, they freak out, because what we had to do before, I had the chain rule, was I'd have to foil this thing four times. Like, write out 2x cubed plus 5, started out four times. Then you take a page of algebra, you hope you don't miss any minus signs, you say anything like 2 plus 2 is 5 and you work all this out, and then you use the product rule. Now that's pretty terrible. Instead what I'd like to do is I'd like to use the chain rule, but you have to remember what is my inside function? What is my outside function? Let's just write everything on the beginning. The inside function on the inside is 2x cubed plus 5. This will be my inside function g of x, and my outside function, the thing that I have plugged the g of x into, which will be my f of x, is x_4. I take 2x cubed plus 5 and I shove it into x_4, then I get the function that you see before you. With all these pieces in mind, let's go find some derivatives here. We can go off on the side, the derivative of x_4 is 4x cubed, and then the derivative, I'll write g of x over here just so we have it all in one place. This was 2x cubed plus 5, and then g-prime of x, using the power rule, is 6x squared. Now I have everything I want, and you can go off on the side, make a little table if you like, y-prime, which is going to be the derivative of f, plugged in with g. So I take g and I plug it into the derivative of f, you get 4, 2x cubed plus 5 cubed, and then don't forget the cost so not doing algebra, I'd rather do calculus, I rather take the power rule and foil something four times all day, so you don't get the skip algebra for free. The charge to do that is you have to multiply by g-prime. Let's get in good habits. I'm going to write parentheses, although I don't quite need it, but it's going to happen to do it. This is your derivative. Now you say, "Wait a minute, do I have to cube this thing out and multiply it and simplify?" No, don't do that. Just keep it as is, this is not an algebra class, this is calculus, so I care about the derivative, if there's ever a time and a place when it'll be beneficial to simplify, then sure, and I'll point out when and where, but not for this just to get the learn the chain rule. Final answer, wrap it up, y-prime, 4 times 2x cubed plus 5 cubed, times 6x squared. Let's do more examples. How about if I give you the function y equals sine of cosine of x. So you see one function is composed with another. This is not multiplication, this is the chain rule. Let's see if we can write it out. What is our outside function? What is our inside function? The inside function, which we're calling g is good old cosine of x, so we could find g prime. Let's do that before we go too much further. The derivative of cosine, which we all remember is, you said it, minus sine. I hope you said it. Then the outside function is f of x, which we're going to cosine, and then of course f prime of x is the derivative of sine, which is cosine. I have my little table that I have. Now remember, it's the derivative, so we're going to say y prime equals. Don't just write equals because we're actually coming up with a new function. It's y prime equals, so friendly reminder, just in case. I have it on my screen here. f composed with g, the derivative is f prime, cube the inside the same times the derivative of the inside. Good old chain rule. It is the derivative of the outside function. Well, that's cosine. Keep the inside function the same. That's cosine x. This is my g times g prime of x, that's negative sine of x. Cosine of cosine times negative sine. It's important to put the parentheses around. Otherwise, it looks like you're subtracting and that's not the case. Let's do another example. Again, there isn't too much to clean up here, but you get the idea. Let's do another example. What if I said y equals the square root of 2 minus e to the x. You see the outside function? Do you see the inside function? Square roots? No. We don't deal with square roots in this class, we turn everything into one half. We're going to write it as a fractional exponent. My outside function is the one half. My inside function is 2 minus e to the x. Let's write our new line. Let's write y equals. Let's see if we can do this without writing out all the stuff. But of course, if you want to write the little table, that's fine too. Let's take the derivative of the outside function. That's x to the one half. The one half comes down and I keep the inside the same, and I subtract 1 from the exponent. Notice the inside is the same, bring the exponent down, subtract 1. I treated this like a general power. Now, here comes the cost, the price we got to pay. I take the derivative of the inside. Let me just write that out. It's 2 minus e to the x times the derivative inside. It's okay to write out some steps. You don't have to be a hero, don't do it all in your head. One half, 2 minus e to the x and I get one half. Now we've got to take a derivative. But once you take derivatives, you can take derivatives all day. Derivative of the constant 2, well that's of course 0 and the derivative of minus e to the x, well that minus is coming along for the ride and the derivative of the exponential. The one we all know and love is just good old e to the x. There it is. Not much to do here. I wouldn't clean up much more. That's good. I'll heck, let's do another one just because they're so much fun. How about y equals 2 to the sine of Pi x? Now we have an exponential function our base is 2, and there's something going on here because I have a whole bunch of stuff. Composition of a composition. Interesting. Let' think about this for a second. What is my outside function? What is my inside function? Maybe we'll write it out for this one. I'm composing the outside function f of x is 2 to the x. I'm composing what I'm throwing in that function is sine of Pi to the x. I take sine of Pi x and I throw it into 2 to the x. Now I have my pieces. Let's take a derivative. Here's a good one. Do you remember the derivative of 2 to the x, 2 to the x times ln of 2. Remember the natural log to base repeat, the natural log to base. Here's a good one. What's the derivative of sine of part of the x? Wait a minute. This is another composition, easy composition, but here's a chain rule inside of it as well. You can't just say it's cosine Pi to the x because it's not just sine of x. It's a composition. You can come off on the side and do this. But let's use the example we did above to see this. It's derivative of the outside. Sine becomes cosine. I keep the inside the same and then I'm going to put it below it because amount of room, you times it by Pi. Where is the times Pi comes from? That's the multiplied by the derivative inside. This is like a chain rule inside a chain rule. It's delicious parfait. It's wrapped in layers, so you got to love it. So y prime, I think I have everything I need here. Remember what the formula says. It says take the derivative of the outside function, so that was 2. I keep the inside the same, so I keep the composition. I repeat this thing. So two raised to the sine of Pi x. But I need the derivative there, so there's a natural log of two that's coming along. Okay, that's the first part, times the derivative of the inside function. I know for this one's a little weird because it's upstairs, but they're the same thing, the inner function when you compose it. That's our G prime and that's cosine of Pi x times Pi. Final answer, 2_sin, Pi x times natural log of 2 times cosine Pi x times Pi. That's a good one. Let's try another one. Oh, all my examples are good ones you're probably saying. Well, that's nice of you to say that. So let's say e_cosine x cosine x. Again, the way to do this is just do lots of examples. You don't want to be surprised by anything. Here once again, I have my exponential but I'm plugging in x cosine x. I'm composing two functions. We have an outside function, we have an inside function. Let's see if we can write some stuff out here. Take the derivative of the outside, but keep the inside the same. My outside function's the exponential. What's the derivative of the exponential? It's just itself. So we'll keep it the same. Then I multiply by the derivative, I step into the function and I multiply by the derivative. So I'm going to have the derivative of x cosine of x. Wait a minute, x cosine x, I know what this is. It's e, x cosine of x times, wait a minute, that's a product. Now you have to use the product rule on this one. We have first times derivative of the second, what's the derivative of cosine? That's minus sine. There's a big bracket parentheses going on here. So first times derivative of the second plus the second function times the derivative of the first, that's just 1, I'll put it just so you see it, but of course you don't need to write that. Notice that if you didn't have the brackets or big parentheses, whatever you want to put, you'd be wrong because then the exponential would only hit the first piece, when in theory, it's got to hit the whole derivative. I would not clean this up, I wouldn't distribute, there's really no point to doing it, leave it as is, don't clean up unless you have to. Let's do one more and then we'll go off and do something else. Again, we'll get more practice with this as we do more calculus, we'll be using the chain rule constantly. Let's take y equals r over the square root of r squared plus 1. Okay, so here we go. R is the variable, who cares? It's a dummy variable, if you don't like it, change it to x, put it back, whatever you want. But the point here is square roots, that's a no-no, we're not going to deal with that. We like to write them as one-half. You could do a quotient rule here. You can totally do a quotient rule here. That's fine. I just want to show you one option to not do a quotient rule. You can also rewrite this function as r squared plus 1 to the negative one-half. Here's a little trick. If you want to avoid the quotient rule, which is maybe not a bad thing to avoid, you can write it as r squared plus 1 to the negative one-half. Now when I go take the derivative, instead of doing quotient rule, I could do a product rule. You get the same answer either way, just pick your poison. Here we go. I'm going to write this out in many steps so you see what's going on. First, I guess it's DDR, times the derivative of the second. So r squared plus 1 to the negative one-half plus the second function. So r squared plus 1 to the negative one half times the derivative of r. Derivative of r, of course is just 1, and then derivative of r squared plus 1 to the negative one-half, that's the chain rule. It's a composition of r squared plus 1 into x to the negative one half. We have to do a little chain rule here, no big deal. We have to bring the exponent down minus one-half, keep the inside the same, subtract 1, so it's minus three-halves, times the derivative of the inside, there's the cost you got to pay, times the derivative of the inside. Don't forget that piece. That's it. That's the chain rule. Then over here, we have r squared plus 1 to the negative one-half and then times 1 which you can write or not write. The answer is a bit messy. Maybe there's stuff that cleans up, like I see a two and a one-half, but in all honesty, I don't care. I don't think we need to clean it up. If you see some basic stuff, if you have a multiple choice question or something short, try to clean it up, but usually it's pretty obvious what it is. When we start using this thing more to do more things, then I'll care about cleaning it up. But for now, I want you to practice the chain rule. Don't forget to multiply by the derivative of the inside, write out, show your steps, don't do it all at once and practice, practice, practice. All right, great job on this one. We'll keep this one short and sweet. We'll see you next time.