The reason most people want calculus is to find the best of something: the cheapest container, the strongest beam, the angle that carries a projectile furthest, and the derivative answers such questions because the best is usually where the curve stops rising.
The previous lessons built the machinery to compute a derivative of anything. This one uses it, and it is the first lesson where calculus does work that could not be done without it. It also has to be careful: the condition everyone remembers, that the derivative vanishes at a maximum, is neither sufficient on its own nor applicable at every kind of maximum.
Two kinds of extreme
A function has a global maximum at if for every in the domain under consideration, and a local maximum if that inequality holds only for near . Minima are defined the same way with the inequality reversed. The distinction matters because the derivative is a local instrument: it can only ever report on the immediate neighbourhood of a point, so it detects local extremes and says nothing directly about global ones.
The bridge between them is the Extreme Value Theorem from the continuity lesson: a continuous function on a closed bounded interval does attain a global maximum and minimum. That theorem provides existence, and the derivative then narrows down the location. Without the theorem there would be no guarantee that the search is for something that exists.
The candidates are few. A global extreme on a closed interval must occur either at an endpoint, or at an interior point where the function has no derivative, or at an interior point where the derivative is zero. There is no fourth possibility, and the reason is the next result.
Fermat's condition
Suppose has a local maximum at an interior point and is differentiable there. Look at the difference quotient . For small positive the numerator is at most zero, since is the largest nearby value, so the quotient is at most zero and the right-hand limit is . For small negative the numerator is still at most zero but the denominator is now negative, so the quotient is at least zero and the left-hand limit is . The derivative exists, so both one-sided limits equal it, and a number that is both and is zero:
That is Fermat's theorem, stated by Pierre de Fermat around 1636, decades before Newton and Leibniz, in a method for maxima and minima that he never justified with limits.
Two warnings come attached. First, the converse is false. For the derivative at zero vanishes, and zero is neither a maximum nor a minimum: the curve is rising on both sides and merely pauses. A vanishing derivative is a necessary condition, not a sufficient one. Second, the theorem assumes differentiability. The function has a genuine minimum at zero, where its derivative does not exist, so a search that only solves would miss it entirely.
A point where or where fails to exist is called a critical point, and Fermat's theorem says the interior extremes are among them.
The closed interval method
For a continuous function on the whole procedure is now mechanical: find every critical point in the interval, evaluate there and at both endpoints, and compare the numbers. The largest is the global maximum and the smallest the global minimum. No test for the type of critical point is needed, because comparing values settles it directly.
Example. Find the global extremes of on .
The derivative is , so the critical points are and , both inside the interval. Evaluating: , , , . The global maximum is , at the right endpoint, and the global minimum is , attained twice, at and . Notice that the largest value is at an endpoint where the derivative is not zero at all, which is exactly why endpoints must be checked.
Now you. Find the global extremes of on .
Answer
The derivative is , so the critical points are , and , of which the first two lie in the interval. Evaluating: , , , . The maximum is at and the minimum is at .
Telling the critical points apart
When the domain is not a closed interval, or when the shape of the curve is wanted rather than one number, the critical points have to be classified.
The first derivative test reads the sign of on each side. If changes from positive to negative at , the function rises then falls, so is a local maximum; negative to positive gives a local minimum; no change of sign gives neither, which is the case. For the cubic above, is positive before , negative between and , and positive after , so is a local maximum and a local minimum, matching the values computed.
The second derivative test is quicker when it works. The sign of measures concavity: where the slope is increasing and the curve bends upward like a bowl, and where it bends downward like a dome. So at a critical point with there is a local minimum, and with a local maximum. For the cubic, , which is at and at , confirming the classification in two substitutions.
The test is silent when , and the silence is genuine rather than a defect in the statement: , and all have vanishing first and second derivatives at the origin, and they have a minimum, a maximum and neither. When the second derivative test says nothing, fall back on the first.
A point where the concavity changes is an inflection point. For a cubic there is exactly one, at here, and it is where the curve is steepest between its two turning points. Inflections matter physically: on a graph of position against time, the inflection is where the acceleration reverses, and on a curve of a population against time, it is the moment growth stops accelerating and starts slowing, which is the peak of the epidemic rather than its end.
Optimising a real thing
A word problem becomes a calculus problem in four steps: name the quantity to be optimised, express it in terms of one variable using whatever constraint the problem supplies, differentiate and solve, and check that the critical point is the kind of extreme wanted.
Example. A cylindrical can is to hold mL. What radius and height use the least metal?
Metal used is surface area, , in two variables. The constraint is the volume, , so , and substituting removes :
Differentiate: . Setting this to zero gives , so and cm. Then cm, which is exactly . The optimal can is as tall as it is wide, and its surface area is cm². The second derivative, , is positive for every positive , so this is a minimum, and since at both ends of the domain it is the global one.
Now you. An open-topped box is made from a cm square sheet by cutting a square of side from each corner and folding up the sides. What maximises the volume?
Answer
The volume is for . Differentiating with the product and chain rules gives , which vanishes at , outside the useful range, and at . So cm, giving a volume of cm³. Checking either side confirms it: gives and gives .
The can result deserves an honest postscript, because real drink cans are nowhere near . A mL can has a radius of about cm and a height of about cm, far taller than the optimum. The model is not wrong, it is incomplete: the ends of a can are thicker than the wall and are stamped from different stock, so they cost more per square centimetre; the rim requires a seam; and a can has to fit a hand and a vending machine slot. Minimising area subject to volume is one term of an objective function with several. What calculus supplies is the answer to the question actually asked, which is why stating the question carefully is most of the work.
Snell's law from a minimum
The most famous optimisation in physics is the one that derives the law of refraction, and it needs nothing beyond this lesson.
Light travels from a point in air to a point in water. Its speed is above the surface and below. Pierre de Fermat proposed in 1662 that the path taken is the one of least time, which is a claim to be tested rather than assumed. Let the light cross the surface at horizontal position , so that the two path lengths are and , where and are the perpendicular distances of the two points from the surface and is the horizontal separation. The total time is
Differentiating with the chain rule gives
Now read the two fractions geometrically. In the upper triangle, is the side opposite the angle from the vertical and is the hypotenuse, so their ratio is ; likewise the other ratio is . Setting gives
which is Snell's law, published by Willebrord Snellius in 1621 as an empirical regularity and derived here from a minimum principle. Since the refractive index is , it takes the familiar form .
Example. Light strikes water at degrees from the normal. Water has . Find the refraction angle.
Snell's law gives , so degrees. The ray bends toward the normal on entering the slower medium, which is what the minimum-time principle predicts: light spends less of its path in the slow medium by turning.
Now you. A projectile launched at speed and angle over level ground travels a distance . Find the angle giving maximum range, and the range for m/s.
Answer
Differentiating with respect to gives , which vanishes when , so degrees. There and the range is m. The second derivative is negative there, confirming a maximum.
What is still owed
Every conclusion in this lesson rests on two claims that have not been proved: that a function is increasing wherever its derivative is positive, and that concavity is read off the sign of the second derivative. Both were used freely and both sound obvious.
They are not obvious, and they cannot be proved directly from the definition of the derivative, because the derivative is a local statement and "increasing on an interval" is a global one. Something is needed to carry information from one point to a whole interval, and that something is the Mean Value Theorem.
It also delivers a second result which matters more for the rest of the course: that two functions with the same derivative everywhere can differ only by a constant. That single fact is what makes it possible to run differentiation backwards at all, and running it backwards is the entire second half of this subject.