Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

Extrema and optimisation

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 c if f(c)f(x) for every x in the domain under consideration, and a local maximum if that inequality holds only for x near c. 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 f has a local maximum at an interior point c and is differentiable there. Look at the difference quotient (f(c+h)-f(c))/h. For small positive h the numerator is at most zero, since f(c) is the largest nearby value, so the quotient is at most zero and the right-hand limit is 0. For small negative h 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 0. The derivative exists, so both one-sided limits equal it, and a number that is both 0 and 0 is zero:

f(c)=0

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 f(x)=x3 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 |x| has a genuine minimum at zero, where its derivative does not exist, so a search that only solves f=0 would miss it entirely.

A point where f(c)=0 or where f(c) 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 [a,b] the whole procedure is now mechanical: find every critical point in the interval, evaluate f 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 f(x)=x3-6x2+9x+2 on [0,5].

The derivative is f(x)=3x2-12x+9=3(x-1)(x-3), so the critical points are x=1 and x=3, both inside the interval. Evaluating: f(0)=2, f(1)=6, f(3)=2, f(5)=22. The global maximum is 22, at the right endpoint, and the global minimum is 2, attained twice, at x=0 and x=3. 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 f(x)=x4-8x2+3 on [-1,3].

Answer

The derivative is 4x3-16x=4x(x-2)(x+2), so the critical points are 0, 2 and -2, of which the first two lie in the interval. Evaluating: f(-1)=-4, f(0)=3, f(2)=-13, f(3)=12. The maximum is 12 at x=3 and the minimum is -13 at x=2.

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 f on each side. If f changes from positive to negative at c, the function rises then falls, so c is a local maximum; negative to positive gives a local minimum; no change of sign gives neither, which is the x3 case. For the cubic above, f=3(x-1)(x-3) is positive before 1, negative between 1 and 3, and positive after 3, so x=1 is a local maximum and x=3 a local minimum, matching the values computed.

The second derivative test is quicker when it works. The sign of f′′ measures concavity: where f′′>0 the slope is increasing and the curve bends upward like a bowl, and where f′′<0 it bends downward like a dome. So at a critical point with f′′(c)>0 there is a local minimum, and with f′′(c)<0 a local maximum. For the cubic, f′′=6x-12, which is -6 at x=1 and +6 at x=3, confirming the classification in two substitutions.

The test is silent when f′′(c)=0, and the silence is genuine rather than a defect in the statement: x4, -x4 and x3 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 x=2 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 355 mL. What radius and height use the least metal?

Metal used is surface area, A=2πr2+2πrh, in two variables. The constraint is the volume, πr2h=355, so h=355/(πr2), and substituting removes h:

A(r)=2πr2+710r

Differentiate: A(r)=4πr-710/r2. Setting this to zero gives 4πr3=710, so r3=56.50 and r=3.837 cm. Then h=355/(π×14.724)=7.674 cm, which is exactly 2r. The optimal can is as tall as it is wide, and its surface area is 277.5 cm². The second derivative, A′′=4π+1420/r3, is positive for every positive r, so this is a minimum, and since A at both ends of the domain it is the global one.

Now you. An open-topped box is made from a 30 cm square sheet by cutting a square of side x from each corner and folding up the sides. What x maximises the volume?

Answer

The volume is V=x(30-2x)2 for 0<x<15. Differentiating with the product and chain rules gives V=(30-2x)2-4x(30-2x)=(30-2x)(30-6x), which vanishes at x=15, outside the useful range, and at x=5. So x=5 cm, giving a volume of 5×400=2000 cm³. Checking either side confirms it: x=4 gives 1936 and x=6 gives 1944.

The can result deserves an honest postscript, because real drink cans are nowhere near h=2r. A 330 mL can has a radius of about 3.3 cm and a height of about 9.6 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 v1 above the surface and v2<v1 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 x, so that the two path lengths are a2+x2 and b2+(d-x)2, where a and b are the perpendicular distances of the two points from the surface and d is the horizontal separation. The total time is

T(x)=a2+x2v1+b2+(d-x)2v2

Differentiating with the chain rule gives

T(x)=xv1a2+x2-d-xv2b2+(d-x)2

Now read the two fractions geometrically. In the upper triangle, x is the side opposite the angle from the vertical and a2+x2 is the hypotenuse, so their ratio is sinθ1; likewise the other ratio is sinθ2. Setting T=0 gives

sinθ1v1=sinθ2v2

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 n=c/v, it takes the familiar form n1sinθ1=n2sinθ2.

Example. Light strikes water at 30 degrees from the normal. Water has n=1.333. Find the refraction angle.

Snell's law gives sinθ2=sin30/1.333=0.5/1.333=0.375, so θ2=22.03 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 v and angle θ over level ground travels a distance R=v2sin(2θ)/g. Find the angle giving maximum range, and the range for v=20 m/s.

Answer

Differentiating with respect to θ gives R=2v2cos(2θ)/g, which vanishes when 2θ=π/2, so θ=45 degrees. There sin(2θ)=1 and the range is v2/g=400/9.8=40.8 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.