 Hello again and welcome back to yet another video where we're going to see two examples of the chain rule in action. This one's a little different because we're going to see rules mixed up together here. It's one of the important things about having a lot of tools available to differentiate functions is knowing exactly what tool is right in a given situation. This isn't always an easy process. So let's think through it. First of all, let's take a look at the function y equals x squared times e to the 5x. So if we're going to take the derivative of y, we need to think about what rule should we use first. Well, let's think through what we know. What rules do we have in front of us? We have the chain rule, we have the product rule, we have the quotient rule, and we have all the sort of more simple rules that we saw earlier on in the section. So which one is it that we should be using first? Well, I think what we're going to use first is the product rule. And the reason that the product rule is going to be in play here is because at the top level of structure here, think about how this function is built. It's really two functions multiplied together, and I'm just going to circle those here. Here's one function, and I'm multiplying by another function. So you look at this function here, and if you pay attention to the video on exponential functions, you see an e to the 5x, and that might make you think the chain rule is going to occur at some point in this process, and you'd be right about that. But it's not going to occur at the beginning of this process because y, globally speaking, is not a composite function. It is a function that's a product first. One of the terms of that product is a composite. But when you look at the very, very top level, this is a product first and foremost, and so we're going to use the product rule to differentiate it. Now what other rules may show up in the process? We'll see, but this is going to be a product rule problem first. So let's start cranking on that. So I have my first function, x squared, and my second function, e to the 5x. I'm just going to write out what the product rule would tell me using my d over dx notation. So y prime should be the derivative of the first function times the second function, sort of left alone, plus the first function times the derivative of the second function. Now let's just take stock and see what's going to happen next before we actually do it. This derivative here is going to be pretty easy peasy because that's just a simple power function. This one here, if you think about how I'm going to differentiate that, again, if you paid attention to the video on exponential functions, you know that when we see an e to the complicated power, that's going to involve the chain rule. So I believe that this derivative is going to involve the chain rule. So we suspected that the chain rule would make an appearance and it will here in the smaller sub-process that's going on. So let's see what we can do up to this point. So first of all, the derivative, this first derivative over here of x squared is just going to be 2x. It's already being multiplied by an e to the 5x. And I have plus x squared times, now let's get rid of this here and think about what that derivative would be of e to the 5x. Well, this is a composite function where the inside function is the exponent 5x, and the outside function, the second link in the chain, is e to the x. So for the chain rule, I need both derivatives of these functions. So g prime of x, the derivative of 5x is just 5, and f prime of x is just e to the x again. So let me switch to blue and do the derivative that I had been doing in green here. I'm going to put a large parenthesis here to encase this process. So the chain rule says I should use f prime, that's here, with the original g function put into it. That's e to the 5x. And then I would need to multiply all that by the derivative of g of x, and that's just a 5. Okay, so all the derivatives have taken place here, and before we do some simplification, just recap what we did. First of all, I need to decide what rule should apply first when differentiating y. And to do that, I have to step back and look at how the function is put together. It's not a pure composite function because this function is not one single function with another put into it. It's really a product of two things. So I'm going to use the product rule. Now in the course of doing the product rule, I encounter a chain rule that I have to do as well. And we've done that right here. Now let's start to simplify here just to clean this up a little bit. I'll do one thing here, and that's just to multiply the blue stuff out. 2x e to the 5x plus rearranging all these terms here gives me 5x squared e to the 5x. And I see just one last algebra step here. I see that I've got a common factor of x e to the 5x on all these guys here. So let me pull out that common factor and I am with my final answer x e to the 5x times 2 plus 5x. Now let's look at this other example here, y equals cosine of the square root of x squared plus 1. So again, what sort of rule should I be using here? To answer that question, I need to step back and take a look at how this function is put together. I have some choices here. Is this function a product like the one before it? Well, the answer is no. In fact, there is no multiplication taking place here at all. Don't be fooled by thinking that when I write cosine of x squared plus 1, square root of x squared plus 1, this is somehow cosine times x squared plus 1. That is not multiplication. You're looking at their underline in the red. That's function evaluation. So there's no multiplying going on at all in this problem. And so unless you count x times itself. So product rule is out the window and clearly no quotient rule here. So let's think about the chain rule and see if that's got something to say in this problem. Well, is it a composite function? If so, what's the inside, what's the outside? I'm going to perform my little trick again here to try to get an idea of what's inside and what's outside. If I evaluated this function at a point, let's say x equals 0, then I would have to go through a stage of processes like so. The first thing I would have to do is evaluate this inner function at x equals 0 and then run it through the cosine function. So that gives me a sense of what's inside quote unquote on what's outside. I'm going to move this over here. We've been letting g of x denote our first or inside function and that appears to be radical x squared plus 1. And then the outside function is f of x and that is cosine x. If I chain those two functions together with this one first and this one second, I get my original y function back. So let's go through and write out what the chain rule would say in this case. y prime would be f prime of g of x times g prime of x. Now that would involve taking the derivative of cosine, okay, which we know is minus sin of x. And it would also about mean taking the derivative of g of x. Now let's just think about this. The derivative of g of x, that's the derivative of radical x squared plus 1. Now how would I take that derivative? Well that derivative is another chain rule problem. So I would need a second set of chain rule calculations, which I'm going to do right over here. If I am differentiating the function x squared plus 1, that too is a chain rule problem. The inside, I'll just call it g of x again, but I'm using green for the sort of sub calculation here is x squared plus 1. And the outside function f is radical x. So this is not a combination of one rule and another rule like we saw in the first example. It's an example where the chain rule has to be used twice in the same problem in order to catch the derivative. So a lot of moving pieces here, I think I'm going to go and make a clean slide to do all the green calculations here and then pull it back over and finish the main derivative. So here we are and we're going to do the small piece of the main calculation off to the side here. So I'm taking the derivative of radical x squared plus 1. I've identified that the inside function is x squared plus 1, the outside function is radical x, which I'm again going to write as x to the one half because I know a derivative is coming up. So g prime of x is just simply 2x, and f prime of x is going to be one half x to the minus one half. So that's enough information to put together this piece of the derivative. So this derivative is equal to f prime evaluated at g, that's one half quote unquote x, which I'm just going to leave as a blank here, with g plugged into it, that's x squared plus 1. And then I need to multiply that by the derivative of g, that's 2x. Just to simplify this a little bit, the 2 and the one half multiply off and I'm left with x to write it a little bit more pretty is over radical x squared plus 1. So that's the piece of the bigger derivative that I was calculating. I'm just going to simply import that into the main calculation now and carry out the steps. So I'm going to start cleaning here on this slide. And the main function cosine of radical x squared plus 1 is a composite. Here's the g function I see up here, and we decided that g prime of x was eventually equal to x over the square root of x squared plus 1. And the f function cosine, as we know the derivative of cosine is minus sine x. So that's enough information and I'll put together all the derivative for the main event here. So I would need f prime which is minus sine of quote unquote x. And what I put in for x is the original function for g and that would be radical x squared plus 1. And then I'm just going to multiply by the derivative of g which we said was x over radical x squared plus 1. There's really not much of the way of simplification. I can just move the furniture around a little bit and write this as negative x sine radical x squared plus 1 over radical x squared plus 1. And that's the result of my derivative taking process. Again, this is an example where the chain rule was used twice. I guess you could say the original function was not two functions chained together. It was really three x squared plus 1 than the square root function than the cosine function. So thanks for watching.