# Max and Min and Second Derivative

Flash and JavaScript are required for this feature.

At the top and bottom of a curve (Max and Min), the slope is zero. The "second derivative" shows whether the curve is bending down or up. Here is a real-world example of a minimum problem:

What route from home to work takes the shortest time?

Professor Strang's Calculus textbook (1st edition, 1991) is freely available here.

Subtitles are provided through the generous assistance of Jimmy Ren.

PROFESSOR: Hi. Well, I hope you're ready for second derivatives. We don't go higher than that in many problems, but the second derivative is an important-- the derivative of the derivative is an important thing to know, especially in problems with maximum and minimum, which is the big application of derivatives, to locate a maximum or a minimum, and to decide which one it is. And I can tell you right away, locating a maximum, minimum, is the first derivative's job. The first derivative is 0. If I have a maximum or a minimum, and we'll have pictures, somewhere in the middle of my function I'll recognize by derivative equals 0. Slope equals 0, that the function is leveling off, either bending down or bending up, maximum or minimum.

OK, and it's the second derivative that tells me which it is. The second derivative tells me the bending of the graph. OK, so we now will have three generations. The big picture of calculus started with two functions: the distance and the speed. And we discussed in detail the connection between them. How to recover the speed if we know the distance, take the derivative.

Now comes the derivative of the speed, which in that language, in the distance-speed-time language, the second derivative is the acceleration, the rate at which your speed is changing, the rate at which you're speeding up or slowing down. And this is the way I would write that. If the speed is the first derivative-- df dt-- this is the way you write the second derivative, and you say d second f dt squared. d second f dt squared.

OK, so that's you could say the physics example: distance, speed, acceleration. And I say physics because, of course, acceleration is the a in Newton's Law f equals ma. For a graph, like these graphs here, I won't especially use those physics words. I'll use graph words.

So I would say function one would be the height of the graph. And in this case, that height is y equals x squared, so it's a simple parabola. Here would be the slope. I would use the word "slope" for the second function. And the slope of y equals x squared we know is 2x, so we see the slope increasing. And you see on this picture the slope is increasing. As x increases, I'm going up more steeply.

Now, it's the second derivative. And what shall I call that? Bending. Bending is the natural word for the second derivative on a graph. And what do I-- the derivative of 2x is 2, a constant, a positive constant, and that positive constant tells me that the slope is going upwards and that the curve is bending upwards.

So in this simple case, we connect these three descriptions of our function. It's positive. It's slope is positive. And its second derivative-- bending-- is positive. And that gives us a function that goes like that.

Now, let me go to a different function. Let me take a second example now, an example where not everything is positive. But let's make it familiar. Take sine x. So sine x starts out like that. So this is a graph of sine x up to 90 degrees, pi over 2, so that's y equals sine x.

OK, what do you think about its slope? We know the derivative of sine x, but before we write it down, look at the graph. The slope is positive, right? But the slope actually starts out at 1. Better make it look a little more realistic. That's a slope of 1 there. So the slope starts at 1 and the slope drops to a slope of 0 up there. So a slope of 1. I see here is a 1.

Here I'm graphing y prime. dy dx I sometimes write as y prime, just because it's shorter, and particularly, it'll be shorter for a second derivative. So y prime, we know the derivative of sine x is cos x, which is pretty neat actually, that we start with a familiar function, and then we get its twin, its other half. And the cosine is the slope of the sine curve, and it starts at 1, a slope of 1, and it comes down to 0, as we know the cosine does. So that's a graph of the cosine.

And now, of course, we have three generations. I'm going to graph y double prime. Let me put it up here. y double prime, the second derivative, the derivative of the cosine of x is minus sine x.

OK, let's just-- from the picture, what am I seeing here? I'm seeing a slope of 0. I'm taking now the slope of the slope. So here it starts at 0. The slope is downwards, so the second derivative is going to be negative. Oh, and it is negative, minus sign x. So the slope starts at 0 and ends at minus 1 because that now comes down at a negative slope. The slope is negative. I'm going downhill, and that's a graph of the second derivative.

And which way is our function bending? It's bending down. As I go along, the slope is dropping. And I see that in the slope curve. It's falling. And I see it in the bending curve because I'm below 0 here. This is bending down, where that one was bending up.

I could introduce the word convex for something that bends upwards, and bending down, I could introduce the word concave. But those are just words. The graphs are telling us much more than the words do.

OK, so do you see that picture bending down, but going up? So the slope is positive here, but the second derivative, the slope is dropping. So the second derivative-- and you have to pay attention to keep them straight. The second derivative is telling us that the original one is bending down. OK, let me continue these graphs just a little beyond 90 degrees, pi over 2, because you'll see something interesting.

So what happens in the next part of the graph? So this is going-- the sine curve, of course, continues on its way downwards. So the slope is going negative, as I know the cosine curve will do, as the cosine curve will come like that. The slope down to minus 1, the slope-- do you see here? The slope is negative, so on this slope graph, I'm below 0. And the slope is 0. Let me put a little mark at these points here, at these three points.

Those are important points. In fact, that is a maximum, of course. The sine curve hits its maximum at 1. At that point when it hits its maximum, what's its slope? When you hit a maximum, you're not going up anymore. You haven't started down. The slope is 0 right there.

What's the second derivative? What's the bending at a maximum? The bending tells you that the slope is going down, so the bending is negative. The bending is negative at a maximum. Good.

OK, now I'm going to continue this sine curve for another 90 degrees, the cosine curve, and I'll continue the bending curve, so I have minus sine x, which will go back up. OK, now what? Now what? And then, of course, it would continue along.

OK, there's something interesting happening at 180 degrees, at pi. Can I identify that point? So there's 180 degrees. Something's happening there. I don't see-- I don't quite know how to say what yet, but something's happening there. It's got to show up here, and it has to show up here. So whatever is happening is showing up by a point where y double prime, the second derivative, is 0. That's my new little observation, not as big a deal as maximum or minimum. This was a max here. And we identified it as a max because the second derivative was negative.

Now I'm interested in this point. Can you see what's happening at this point as far as bending goes? This curve is bending down. But when I continue, the bending changes to up. This is a point where the bending changes. The second derivative changes sign, and we see it here. Up to this square point, the bending is below 0. The bending is downwards as I come to here. But then there's something rather special that-- you see, can I try to blow that point up? Here the bending is down, and there it turns to up, and right in there with the-- this is called-- so this is my final word to introduce-- inflection point. Don't ask me why.

An inflection point is a point where the second derivative is 0. And what does that mean? That means at that moment, it stopped bending down, and it's going to start bending up. The second derivative is passing through 0. The sign of bending is changing. It's changing from concave here to convex there. That's a significant point on the graph. Not as big a thing as the max or the min that we had over there. So let me draw one more example and identify all these different points.

OK, so here we go. I drew it ahead of time because it's got a few loops, and I wanted to get it in good form. OK, here it is. This is my function: x cubed minus x squared. Well, before I look at the picture, what would be the first calculus thing I do? I take the derivative. y prime is the derivative of x cubed, is three x squared minus the derivative of x squared, which is 2x.

And now today, I take the derivative of that. I take the second derivative, y double prime. So the second derivative is the derivative of this. x squared is going to give me 2x, and I have a 3, so it's all together 6x. And minus 2x, the slope of that is minus 2, right? Cubic, quadratic, linear, and if I cared about y triple prime, which I don't, constant. And then the fourth derivatives and all the rest would be 0 for this case.

OK, now somehow, those derivatives, those formulas for y, y prime, y double prime should tell me details about this graph. And the first thing I'm interested in and the most important thing is max and min. So let me set y prime to be-- which is 3x squared minus 2x. I'll set it to be 0 because I want to look for max, or min. And I look for both at the same time by setting y prime equals 0, and then I find out which I've got by looking at y double prime.

So let me set y prime to be 0. What are the solutions? Where are the points on the curve where it's stationary? It's not climbing and it's not dropping? Well, I see them on the curve here. That is a point where the slope is 0. And I see one down here. There is a point where the slope is 0, but I can find them with algebra. I solve 3x squared equals to 2x, and I see it's a quadratic equation. I expect to find two roots. One of them is x equals 0, and the other one is what? If I cancel those x's to find a non-zero, canceling those x's leaves me with 3x equals 2 or x equals 2/3. Yeah, and that's what our graph shows.

OK, now we can see on the graph which is a max and which is a min. And by the way, let me just notice, of course, this is the max. But let me just notice that it's what I would call a local maximum. It's not the absolute top of the function because the function later on is climbing off to infinity. This would be way a maximum in its neighborhood, so a maximum, and it's only a local max. And what do I expect to see at a maximum at x equals 0? I expect to see the slope 0 at x equals 0, which it is. Check. And at a maximum, I need to know the second derivative.

OK, here's my formula. At x equals 0, I see y double prime if x is 0 is minus 2. Good. Negative second derivative tells me I'm bending down, as the graph confirms, and the place where the slope is 0 is a maximum and not a minimum.

What about the other one? What about at x equals 2/3? At that point, y double prime, looking at my formula here for y double prime, is what? 6 times 2/3 is 4 minus 2 is plus 2. 4 minus 2 is 2. So this will be-- this is positive, so I'm expecting a min. At x equals 2/3, I'm expecting a min. And, of course, it is. And again, it's only a local minimum. The derivative can only tell you what's happening very, very close to that point. The derivative doesn't know that over here the function is going further down. So this is a min, and again, a local min.

OK, those are maximum and minimum when we know the function. Oh yeah, I better do the inflection point. Do you remember what the inflection point is? The inflection point is when the bending changes from-- up to here I see that bending down. From here, I see it bending up. So I will not be surprised if that's the point where the bending is changing, and 1/3 is the inflection point.

And now how do we find an inflection point? How do we identify this point? Well, y double prime was negative. y double prime was positive. At that point, y double prime is 0. This is an inflection point. And it is. At x equals to 1/3, I do have 6 times 1/3. 2 subtract 2, I have 0. So that is truly an inflection point. And now I know all the essential points about the curve.

And these are the quantities-- oh! Say you're an economist. You're looking now at the statistics for the US economy or the world economy. OK, I suppose we're in a-- we had a local maximum there, a happy time a little while ago, but it went downhill, right? If y is, say, the gross product for the world or gross national product, it started down. The slope of that curve was negative. The bending was even negative. It was going down faster all the time.

Now, at a certain moment, the economy kept going down, but you could see some sign of hope. And what was the sign of hope? It was the fact that it started bending up. And probably that's where we are as I'm making this video. I suspect we're still going down, but we're bending up. And at some point, hopefully tomorrow, we'll hit minimum and start really up. So I don't know. I would guess we're somewhere in there, and I don't know where. If I knew where, mathematics would be even more useful than it is, which would be hard to do. OK, so that's an example of how the second derivative comes in.

Now, I started by giving this lecture the title Max and Min and saying those are the biggest applications of the derivative. Set the derivative to 0 and solve. Locate maximum points, minimum points. That's what calculus is most-- many of the word problems, most of the ones I see in use, involve derivative equals 0.

OK, so let me take a particular example. So these were graphs, simple functions which I chose: sine x, x squared, x cubed minus x squared. Now let me tell you the problem because this is how math really comes. Let me tell you the problem, and let's create the function.

OK, so much it's the problem I faced this morning and every morning. I live here. So OK, so here's home. And there is a-- the Mass Pike is the fast road to MIT. So let me put in the Mass Pike here, and let's say that's MIT, and I'm trying to get there as fast as possible.

OK, so for part of the time, I'm going to have to drive on city streets. I do have to drive on city streets, and then I get to go on the Mass Pike, which is, let's say, twice as fast. The question is should I go directly over to the fast road and then take off? Let's take off on a good morning. The Mass Pike could be twice as slow, but let's assume twice as fast. Should I go straight over? Probably not. That's not the best way. I should probably pick up the Mass Pike on some road. I could go directly to MIT on the city streets at the slow rate, say 30 miles an hour or 30 kilometers an hour and 60, so speeds 30 and 60 as my speeds.

OK, so now I should have put in some measure. Let's call that distance a, whatever it is. Maybe it's about three miles. And let me call-- so that's the direct distance. If I just went direct to the turnpike, I would go a distance a at 30 miles an hour, and then I would go a distance-- shall I call that b?-- at 60. So that's one possibility. But I think it's not the best.

I think better to-- and you know better than me. I think I should probably angle over here and pick up this-- my question is where should I join the Mass Pike. And let's-- so we get a calculus problem, let's model it. Suppose that I can join it anywhere I like, not just at a couple of entrances. Anywhere. And the question is where?

So calculus deals with the continuous choice of x. So that is the unknown. I could take that as the unknown x. That was a key step, of course, deciding what should be the unknown. I could also have taken this angle as an unknown, and that would be quite neat, too. But let me take that x.

So this distance is then b minus x. So that's what I travel on the Mass Pike, so my time to minimize. I'm trying to minimize my time. OK, so on this Mass Pike when I travel at 60, I have distance divided by 60 is the time, right? Am I remembering correctly? Let's just remember.

Distance is speed times time. That's the one we know. And then if I divide by the speed, the time is the distance divided by the speed, the distance divided by the speed on the pike. And now I have the distance on the city streets.

OK, so that speed is going to be 30. So the time is going to be a bit longer for the distance, and what is that distance? OK, that was a. This was x. Pythagoras is the great leveler of mathematics. That's the distance on the city streets.

And now what do I do? I've got an expression for the time. This is the quantity I'm trying to minimize. I minimize it by taking its derivative and set the derivative to 0. Take the derivative and set the derivative to 0. So now this is where I use the formulas of calculus. So the derivative, now I'm ready to write the derivative, and I'll set it to 0. So the derivative of that, b is a constant, so I have minus 1/60; is that OK? Plus whatever the derivative of this is. Well, I have 1/30. I always take the constant first.

Now I have to deal with that expression. That is some quantity square root. The square root is the 1/2 power, so I have 1/2 times this quantity to one lower power. That's the minus 1/2 power. That means that I still have a square root, but now it's a minus 1/2 power. It's down here. And then the chain rule says don't forget the derivative of what's inside, which is 2x.

OK, depending on what order you've seen these videos and read text, you know the chain rule, or you see it now. It's a very, very valuable rule to find derivatives as the function gets complicated. And the thing to remember, there will be a proper discussion of the chain rule. It's so important. But you're seeing it here that the thing to remember is take also the derivative of what's inside the a squared plus x squared, and the derivative of the x squared is the 2x.

OK, and that I have to set to 0. And, of course, I'm going to cancel the 2's, and I'll set it to 0. What does that mean "set to zero"? Here's something minus. Here's something plus. I guess what I really want is to make them equal. When the 1/60 equals this messier expression, at that point the minus term cancels the plus term. I get 0 for the derivative, so I'm looking for derivative equals 0. That's my equation now.

OK, now I just have to solve it. All right, let's see. If I wanted to solve that, I would probably multiply through by 60. Can I do this? I'll multiply both sides by 60. That will cancel the 30 and leave an extra 2, so I'll have a 2x here. And let me multiply also by this miserable square root that's in the denominator to get it up there. I think that's what I've got. That's the same equation as this one, just simplified. Multiply through by 60. Multiply through by square root of a squared plus x squared, and it's looking good.

All right, how am I going to solve that? Well, the only mess up is the square root. Get rid of that by squaring both sides. So now I square both sides, and I get a squared plus x squared, and the square of 2x is 4x squared. All right, now I have an equation that's way better. In fact, even better if I subtract x squared from both sides. My equation is telling me that a squared should be 3x squared. In other words, this good x is-- now I'm ready to take the square root and find x itself. So put the 3 here. Take the square root. I'm getting a over the square root of 3.

So there is a word problem, a minimum problem, where we had to create the function to minimize, which was the time, trying to get to work as quickly as possible. After naming the key quantity x, then taking the derivative, then simplifying, that's where the little work of calculus comes in, in the end getting something nice, solving it, and getting the answer a over square root of 3. So we now know what to do driving in if there's an entrance where we want to get it. And actually, it is a beautiful answer. If this is a over the square root of 3, this will turn out to be 30 degrees, pi over 6-- I think. Yeah, I think that's right.

So that's the conclusion from calculus. Drive at a 30-degree angle. Hope that there's a road going that way-- sorry about that point-- and join the turnpike. And probably the reason for that nice answer, 30 degrees, came-- I can't help but imagine that because I chose 30 and 60 here, a ratio of 1:2, and then somehow the fact that the sine of 30 degrees is 1/2, those two facts have got to be connected. So I change these 30 and 60 numbers, I'll change my answer, but basically, the picture won't change much.

And there's another little point to make to really complete this problem. It could have happened that the distance on the turnpike was very small and that this was a dumb move. That 30-degree angle could be overshooting MIT if MIT was there. So that's a case in which the minimum time didn't happen where the derivative bottomed out.

If MIT was here, the good idea would be go straight for it. Yeah, the extra part on the turn-- you wouldn't drive on the turnpike at all. And that's a signal that somehow in the graph, which I didn't graph this function, but if I did, then this stuff would be locating the minimum of the graph. But this extra example where you go straight for MIT would be a case in which the minimum is at the end.

And, of course, that could happen. You could have a graph that just goes down, and then it ends, so the minimum is there. Even though the graph looks like it's still going down, the graph ended. What can you do? That's the best point there is.

OK, so that is a-- can I recap this lecture coming first over here? So the lecture is about maximum and minimum, and we learned which it is by the second derivative. So then we had examples. There was an example of a minimum when the second derivative was positive. Here was an example of a local maximum when the second derivative was negative. Here with the sine and cosine, those are nice examples.

And it takes some patience to go through them. I suggest you take another simple function, like start with cosine x. Find its maximum. Find its minimum. Find its inflection points so the inflection points are where the bending is 0 because it's changing from bending one way to bending the other way.

We didn't need an inflection test-- so actually, I didn't complete the lecture, because I didn't compute the second derivative and show that this was truly a minimum. I could have done that. I would have had to take the derivative of this, which would be one level messier, and look at its sign. I wouldn't have to set it to 0. I would be looking at the sign of the second derivative. And in this problem, it would be safely come out positive sign, meaning bending upwards, meaning that this point I've identified by all these steps was truly the minimum time, not a maximum.

OK, that's a big part of important calculus applications. Thanks.

NARRATOR: This has been a production of MIT OpenCourseWare and Gilbert Strang. Funding for this video was provided by the Lord Foundation. To help OCW continue to provide free and open access to MIT courses, please make a donation at ocw.mit.edu/donate.