 So, we now know how to differentiate sums, differences, multiplication by constants, quotients, products, and that covers a lot of functions, but not all of them. To continue our attempt to find derivatives, we need to introduce a new idea, which is called the chain rule, and here it's particularly important to ask yourself the following question. Given an expression, what is the last thing that I do? The type of expression you're dealing with is always determined by the last thing that you do. And the importance of this is that the last thing that you do corresponds to the first thing that you're going to worry about as a derivative. So for example, if I consider this expression 3x-5, 1 over x cubed plus x plus 7, well if I consider a value of x times 3 minus 5, hold it, take x cubed plus x plus 7, 1 over, hold it, then I'm going to take those two values, multiply them together to get my expression. The last thing I do to evaluate this expression is multiply, so this expression is a product, and so the derivative rule I start with is the product rule. Now one useful thing to keep in mind is that while this expression is a product, I could actually change the operation by a very minor shift in what algebra I do. So if I recognize this as a thing times a fraction, I can actually multiply the two things together, and this is exactly the same as 3x-5 over x cubed plus x plus 7. And in this case, the last thing I would do before I evaluate this expression is to divide two things. So what I have here is a quotient, and if I want to differentiate this thing, I would start with the quotient rule. So which one do we start with? Well it depends. If we're dealing with the product, we use the product rule. If we're dealing with the quotient, we use the quotient rule. Actually, we can go a little bit further. It actually helps if we ignore everything but the last thing that we do. So for example, let's take a look at my function f of x equals square root of x cubed plus 4x plus 7. Let's see. Again, let's analyze this. If I take x cubed, take x times 4, add 7, add all those things together, hit the square root button on the calculator. The last thing that you do before you evaluate the expression is to take the square root. This thing is a square root function, and it will be very convenient to think about it as f of, well I don't know what it is, but it's going to be the square root of something. And the function that we're looking at there, square root function, and again, that's going to tell me what the first thing I differentiate is going to be. Another quick example, take a look at the function. This horrible thing raised to the third, well that's something raised to the third power. It's a cube function, so I can think about it as my function is something cubed. And again, I'm ignoring what I do before I'm focusing on the absolute last thing I do before I evaluate the expression. And in this case, the last thing I do is cube it. If you don't go through this analysis, you will have many, many, many difficulties applying the chain rule, and most of your derivatives will be wrong. So you do want to go through this analysis, and it's a fairly simple question. What's the last thing that I do, and that's going to tell you what's the first thing to differentiate. So what happens if I have a function of a function, if I'm daring to differentiate a composite function, the chain rule tells me that the derivative of f of g of x, while the derivative of f, where I'm still going to evaluate it at g of x, multiplied by the derivative of g of x. Now this is one where the expression of the chain rule is a little bit more complicated using either the differential or the prime notation. You don't get a lot of insight from looking at the formula here. If you really want to understand the chain rule, you actually have to differentiate a lot of functions. Fortunately, we have a lot of functions we can differentiate. So let's consider one problem here, f of x equals 3x plus 5 quantity cubed, and we want to find the derivative. One helpful approach to finding the derivative is to take it out, put it back. What do we mean by that? Well, take a look at our function here. Again, do the evaluation. If I were to evaluate 3x plus 5 cubed, I would take x times 3, add 5, take the whole thing, and raise it to the third power. The last thing that I do in this function is I cube it, so this is a cubing function, and I'm going to take out everything except for that very last thing. So my function 3x plus 5 cubed to find the derivative, I'm going to ignore everything else. It's a cube function, and I want to find the derivative of a cube. So how does the chain rule work? Well, I want to find the derivative of a cubed. If this were x cubed, if that were x cubed, my derivative would look like 3x to the second. Because this is not an x in here, I want to add in this factor of the derivative of whatever was there. And now we apply a rule that everybody should have learned in kindergarten, which is if you take something out, make sure that you put it back later. So here I took out that 3x plus 5. I want to make sure that I put it back. 3x plus 5 was in the parentheses, so it should be in all of our parentheses. So there we put everything back, and the important thing to note here is I am not done with this problem. This last term here says differentiate 3x plus 5. So I have to go one further step to complete my derivative. And again, this is a perfectly good form to leave the derivative in. If you want to, you can multiply the constant 3 by the constant 3. But there's no real need to do much more algebraic simplification than this. The chain rule is sufficiently complicated that it's worth looking at the final expression and looking for an echo of the original function. Again, if you are differentiating anything more complicated than a polynomial, if you're differentiating anything involving the quotient rule, or the product rule, or now the chain rule, you will generally get an echo of the original function in the derivative. So if this is the derivative of this, there should be some component of this that we see in our final function. And again, an echo is not the entire thing. It's only a part of it. So here the echo is that 3x plus 5, which showed up here, and shows up here once again. How about another example, find the derivative of square root x squared plus 5x minus 7. Again, do the consideration of what type of function it is. The last thing we do is to evaluate the square root. So we'll ignore everything except for that very last thing that we do. This is the derivative of a square root. And that's going to be the derivative of something to power 1 half. So this is something to the n. So the derivative is going to be n something power drop 1, 1 half minus 1, negative 1 half. And don't forget the chain rule, derivative of whatever that happened to be. So we invoke the kindergarten rule. If you took it out, put it back. So everything's back into place. And again, I have to find the derivative of x squared plus 5x minus 7. So I'll differentiate that. And again, let's answer in the same dialect that we got our original question in. We had the square root, not a rational exponent. So we'll go and rewrite it so that we have a square root. And finally, we'll look for that echo. And here, x squared plus 5x plus 7 echoes as x squared plus 5x minus 7. This example is actually fairly important. You can't apply the chain rule too many times. It's actually self-correcting. So let's take one where we already know the derivative, x to the 5. So we'll work the problem using differential notation, mainly for a little bit of variety. And also later on, we're going to prepare for something called implicit differentiation. So I want to find the derivative of x to the 5. Well, what type of function is it? Well, I'm taking x. The last thing I do, raise it to the fifth power. So this is a something to the fifth power. So I'll apply the chain rule. This is a something to the fifth. So when I differentiate x to the 5, for example, I get 5x to the 4 times, now here's where the chain rule comes in, the derivative of whatever that was. And again, we apply the kindergarten rule. Put back what you took out. So here, what I took out was the x. So I want to put the x back in. And so my next expression, 5x to the 4, times the derivative with respect to x of x. So I need to differentiate x and the derivative of x is just equal to 1. And notice that's exactly what we expect the derivative of x to the fifth to be. It should be 5x to the fourth. The moral of this story is that if you apply the chain rule when you don't really need to, nothing bad happens. On the other hand, if you don't apply the chain rule where you need to, you get the wrong derivative. So if you have any doubts as to whether you should be applying the chain rule, apply it. The worse that will happen, you'll get a bunch of factors of one that you don't need. Well, what if I have something else raised to the fifth? So this horrible mess raised to the fifth power, and let's go ahead and find that derivative. It's a fifth power, so if I want to differentiate, it's 5 whatever to power 5 minus 1, which is 4, times the derivative of whatever was in there. Apply the kindergarten rule, we took it out, we put things back, and I have 5 this thing to the fourth derivative of this expression here. And let's see, that is a quotient. So that means I have to apply the quotient rule. And that'll get a little bit messy, but it doesn't look too horrible. That's bottom times derivative of top, minus top times derivative of bottom, all over bottom squared. And unless you really have far too much free time on your hands, this expression doesn't really need to be simplified. This is a perfectly good way to leave the derivative. And again, very important thing, particularly when you're working chain rule problems, is to look for the echo. We want to find the echo of the original function in our supposed derivative, and well, this quotient here does reappear in the derivative. If you don't see the echo, there's a pretty good chance you've done the derivative incorrectly.