[MUSIC] Thus far, I've been trying to sell you on the idea that the derivative of f measures how we wiggling the input effects the output. A very important point is that sensitivity to the input depends on where you're wiggling the input. And here's an example. Think about the function f(x)=x^3. f(2) which is 2^3 is 8. f(2.01) 2.01 cubed is 8.120601. So, the input change of 0.01 was magnified by about 12 times in the output. Now, think about f(3) which is 3^3, which is 27. f(3.01) is 27.270901 so the input change of 0.01 was magnified by about 24 times as much, right? This input change and this input change were magnified by different amounts. You know, you shouldn't be too surprised by that right, the derivative, of course, measures this. The derivative of this function is 3x^2, so the derivative at two is 3*2^2 is 3*4 is 12 and not coincidentally, there's a 12 here and there's a 12 here, right, that's reflecting the sensitivity of the output to the input change. And the derivative of this function at 3 is 3*3^2, which is 3*9 which is 27 and again, not too surprisingly here's a 27, right? The point is just that how much the output is effected depends on where you're wiggling the input. If you're wiggling around 2, the output is affected by about 12 times as much if we're wiggling around 3, the output is affected by 27 times as much, right? The derivative isn't constant everywhere, it depends on where you're plugging in. We can package together all of those ratios of output changes to input changes as a single function. What I mean by this, well, f'(x) is the limit as h goes to 0 of f(x+h)-f(x)/h. And this limit doesn't just calculate the derivative at a particular point. This is actually a rule, right, this is a rule for a function. The function is f'(x) and this tells me how to compute that function at some input X. The derivative is a function. Now, since the derivative is itself a function, I can take the derivative of the derivative. I'm often going to write the second derivative, the derivative of the derivative this way, f''(x). There's some other notations that you'll see in the wild as well. So, here's the derivative of f. If I take the derivative of the derivative, this would be the second derivative but I might write this a little bit differently. I could put these 2 d's together, so to speak, and these dx's together and then I'll be left with this. The second derivative of f(x). A subtle point here is if f were maybe y, you might see this written down and sometimes people write this dy^2, that's not right. I mean, it's d^2 dx^2 is the second derivative of y. The derivative measures the slope of the tangent line, geometrically. So, what does the second dreivative measure? Well, let's think back to what the derivative is measuring. The derivative is measuring how changes to the input affect the output. The deravitive of the derivative measures how changing the input changes, how changing the input changes the output, and I'm not just repeating myself here, it's really what the second derivative is measuring. It's measuring how the input affects how the input affects the output. If you say it like that, it doesn't make a whole lot of sense. Maybe a geometric example will help convey what the second derivative is measuring. Here's a function, y=1+x^2. And I've drawn this graph and I've slected three points on the graph. Let's at a tangent line through those 3 points. So, here's the tangent line through this bottom point, the point 0,1 and the tangent line to the graph at that point is horizontal, right, the derivative is 0 there. If I move over here, the tangent line has positive slope and if I move over to this third point and draw the tangent line now, the derivative there is even larger. The line has more slope than the line through that point. What's going on here is that the derivative is different. Here it's 0, here it's positive, here it's larger still, right? The derivative is changing and the second derivative is measuring how quickly the derivative is changing. Contrast that with say, this example of just a perfectly straight line. Here, I've drawn 3 points on this line. If I draw the tangent line to this line, it's just itself. I mean, the tangent line to this line is just the line I started with, right? So, the slope of this tangent line isn't changing at all. And the second derivative of this function, y=x+1, really is 0, right? The function's derivative isn't changing at all. Here, in this example, the function's derivative really is changing and I can see that if I take the second derivative of this, if I differentiate this, I get 2x, and if I differentiate that again, I just get two, which isn't 0. There's also a physical interpretation of the second derivative. So, let's call p(t), the function that records your position at time t. Now, what happens if I differentiate this? What's the derivative with respect to time of p(t)? I might write that, p'(t). That's asking, how quickly is your position changing, well, that's velocity. That's how quickly you're moving. You got a word for that. Now, I could ask the same question again. What happens if I differentiate velocity, I am asking how quickly is your velocity changing. We've got a word for that, too. That's acceleration. That's the rate of change of your rate of change. There's also an economic interpretation of the second derivative. So, maybe right now dhappiness, ddonuts for me is equal to 0, right? What this is saying? This is saying how much will my happiness be affected, if I change my donut eating habits. If I were really an economist I'd be talking about marginal utility of donuts or something, but, this is really a reasonable statement, right? This is saying that right at this moment you know, eating more donuts really won't make me any more happier and I probably am in this state right now, because if this weren't the case, I'd be eating donuts. So, let's suppose this is true right now and now, something else might be true right now. I might know something about the second derivative of my happiness with respect to donuts. What is this saying? Maybe this is positive right now. This is saying that a small change to my donut eating habits might affect how, changing my donut habits would affect how happy I am. If this were positive right now, should I be eating more donuts, even though dhappiness, ddonuts is equal to zero? Well, yeah, if this is positive, then a small change in my donut eating habits, just one more bite of delicious donut would suddenly result in dhappiness, ddonuts being positive, which should be great, then I should just keep on eating more donuts. Contrast this with the situation of the opposite situation, where the second derivative happens with respect to donuts isn't positive, but the second derivative of happiness with respect to donuts is negative. If this is the case I absolutely should not be eating any more donuts because if I start eating more donuts, then I'm going to find that, that eating any more donuts will make me less happy. Let's think about this case geometrically. So here, I've drawn a graph of my happiness depending on how many donuts I'm eating. And here's two places that I might be standing right now on the graph. These are two places where the derivative is equal to zero. And I sort of know that I must be standing at a place where the derivative is 0, because if I were standing in the middle, I'd be eating more donuts right now. So, I know that I'm standing either right here, say, or right here. Or maybe here, or here. I'm standing some place where the derivative vanishes. Now, the question is how can I distinguish between these two different situations? Right here, if I started eating some more donuts, I'd really be much happier. But here, if I started eating some more donuts I'd be sadder. Well, look at this situation, this is a situation where the second derivative of happiness to respected donuts is positive, right? When I'm standing at the bottom of this hole, a small change in my donut consumption starts to increase the extent to which a change in my donut consumption will make me happier, alright? If I find that the second derivative of my happiness with respect to donuts is positive, I should be eating more donuts to walk up this hill to a place where I'm happier. Contrast that with a situation where I'm up here. Again, the derivative is zero so a small change in my doughnut consumption doesn't really seem to affect my happiness. But the second derivative in that situation is negative. And what does that mean? That means a small change to my donuts consumption starts to decrease the extent to which donuts make me happier. So, if I'm standing up here and I find that the second derivative of my happiness with respect to donuts is negative, I absolutely shouldn't be eating anymore donuts. I should just realize that I'm standing in a place where, at least for small changes to my donut consumption, I'm as happy as I can possibly be and I should just be content to stay there. There's more to this graph. Look at this graph again. So, maybe I am standing here. Maybe the derivative of my happiness with respect to donuts is zero. Maybe the second derivative of my happiness with respect to donuts is negative. So, I realize that I'm as happy as I really could be for small changes in my donut consumption. But if I'm willing to make a drastic change to my life, if I'm willing to just gorge myself on donuts, things are going to get real bad, but then they're going to get really really good and I'm going to start climbing up this great hill. It's not just about donuts, it's also true for Calculus. Look, right now, you might think things are really good, they're going to get worse. But with just a little bit more work, you're eventually going to climb up this hill and you're going to find the immeasurable rewards that increased Calculus knowledge will bring you. [MUSIC]