Monocurl Essays
Series Download

Maxima and minima: where the slope is zero

To fence the largest field or make the cheapest can, look where the derivative is zero, and also at the ends. Why that works, and when it does not.

23 min·High school and early college·

AssumesWhat is a derivative? Speed at a single instantWhy the derivative of x² is 2x: the power rule from picturesWhat is a limit? The epsilon-delta definition, explained

A field against a river, fenced on the other three sides with 100 m of fence (orange; side lengths in meters). As the width changes, the area changes, and the plot on the right records it. The area peaks at 1250 m² when the field is 25 m wide and 50 m long.
Monocurl source
let SC = 0.05
let TOP = 1.7
let CX = -2.15
let fa = Frame(0, 50, 0, 1400, [2.05, -0.05, 0], 2.8, 3.0)
let Field = |x, seen| {
    let half = (100 - 2 * x) * SC / 2
    let bot = TOP - x * SC
    return [
        Region([[CX - half, bot, 0], [CX + half, bot, 0], [CX + half, TOP, 0], [CX - half, TOP, 0]], tint(LEAF, 0.3)),
        Path([[CX - half, TOP, 0], [CX - half, bot, 0], [CX + half, bot, 0], [CX + half, TOP, 0]], EMBER, 4.5),
        center{[CX + half + 0.32, (TOP + bot) / 2, 0]} color{EMBER} Number(x, 0),
        center{[CX, bot - 0.3, 0]} color{EMBER} Number(100 - 2 * x, 0),
        center{[CX, bot - 0.75, 0]} Note("area (m²)", 0.72),
        center{[CX, bot - 1.2, 0]} scale{1.5} color{LEAF} Number(A(x), 0),
        Graph(fa, A, 18, seen, AZURE, 4.5, 60),
        Seg(at(fa, x, 0), at(fa, x, A(x)), EMBER, 2.5),
        Pt(at(fa, x, A(x)), EMBER, 0.1)
    ]
}
mesh river = [
    Region([[-3.85, TOP, 0], [-0.45, TOP, 0], [-0.45, TOP + 0.42, 0], [-3.85, TOP + 0.42, 0]], tint(AZURE, 0.3)),
    center{[CX, TOP + 0.21, 0]} Cap("river", 0.74, AZURE)
]
mesh plot = [
    GridLines(fa, [10, 20, 30, 40, 50], [500, 1000]),
    Axes(fa),
    XTicks(fa, [25, 50]),
    center{[fx(fa, 0) - 0.42, fy(fa, 500), 0]} Math("500", 0.72, SLATE),
    center{[fx(fa, 0) - 0.47, fy(fa, 1000), 0]} Math("1000", 0.72, SLATE),
    center{[fx(fa, 12), fy(fa, 0) - 0.33, 0]} Note("width (m)", 0.72),
    center{[fx(fa, 25), fy(fa, 1400) + 0.4, 0]} Cap("area against width", 0.74, AZURE)
]
mesh field = Field(x: 18, seen: 18.5)

slide "sweep"
    play Wait(0.6)
    field.x = 45
    field.seen = 45
    play Lerp(4.5, [&field], linear)
    play Wait(0.4)
    field.x = 25
    play Lerp(2.2, [&field])
    play Wait(1.8)

Uses the shared definitions for this lesson's figures.

A farmer has 100 meters of fence and wants to enclose a rectangular field along a straight river. The river serves as one side, so the fence is needed only for the other three. What shape of rectangle encloses the most land?

Most people’s first guess is a square. It is a reasonable guess, and it is wrong, and finding out why takes a few minutes of arithmetic. Finding a method that answers every question of this kind is the subject of this lesson, and it is one of the main reasons calculus is used at all.

Try some fields

Call the width of the field $x$ meters, meaning the length of each of the two sides that run away from the river. Those two sides use $2x$ meters of fence, which leaves $100 - 2x$ meters for the side parallel to the river. The area is width times length:

$$ A(x) = x(100 - 2x) = 100x - 2x^2 \text{ square meters}, \qquad 0 \le x \le 50. $$

The limits on $x$ come from the fence: the width cannot be negative, and at $x = 50$ the two sides use all the fence and nothing is left for the third.

Pause and try

Compute the area for widths of 10, 20, 30 and 40 meters, and for the square field. (For a square, the three fenced sides are equal, so $x = \frac{100}{3}$.) What do you notice about 20 and 30?

Show answerHide answer

$A(10) = 10 \times 80 = 800$, $A(20) = 20 \times 60 = 1200$, $A(30) = 30 \times 40 = 1200$, $A(40) = 40 \times 20 = 800$. The square has $A = \frac{100}{3} \times \frac{100}{3} \approx 1111$, which is less than both 1200s. The areas at 20 and 30 are equal, and so are those at 10 and 40: the values are symmetric about $x = 25$, which suggests looking there. $A(25) = 25 \times 50 = 1250$.

So a field 25 m wide and 50 m long beats the square by about 139 square meters. Is 1250 the best possible, or would 24.9 or 25.3 do slightly better? We could keep trying values, but trying values can never rule out all the others. Plot the area against the width, as in the animation, and the question changes character. The graph is a hill, and we are looking for its top.

At the top, the graph is flat

To see what distinguishes the top of a hill from every other point on it, walk along the graph from left to right. On the way up, the ground slopes upward. On the way down, it slopes downward. At the top it does neither.

The slope of a graph at a point is the derivative. For $A(x) = 100x - 2x^2$ the power rule gives

$$ A'(x) = 100 - 4x, $$

measured in square meters of area per meter of width.

The tangent line to the area graph as the width goes from 8 m to 42 m. Its slope $A'(x) = 100 - 4x$ is positive on the way up, negative on the way down, and exactly 0 at $x = 25$, where the tangent is horizontal.
Monocurl source
let fh = Wide(0, 52, 0, 1400)
let Ride = |x| {
    let m = 100 - 4 * x
    var shown = m
    if (abs(m) < 0.5) { shown = 0 }
    return [
        Tangent(fh, A, m, x, 7),
        Pt(at(fh, x, A(x)), EMBER, 0.1),
        center{at(fh, 25, 330)} scale{1.5} color{EMBER} Number(shown, 0)
    ]
}
mesh plot = Hill(fh)
mesh curve = Graph(fh, A, 0, 50, AZURE, 4.5)
mesh words = [
    center{at(fh, 25, 620)} Cap("slope of the tangent", 0.74, EMBER),
    center{at(fh, 25, 110)} Note("m² per meter of width", 0.72)
]
mesh ride = Ride(x: 8)

slide "ride"
    play Wait(0.5)
    ride.x = 25
    play Lerp(3, [&ride])
    play Wait(1.2)
    ride.x = 42
    play Lerp(3, [&ride])
    play Wait(1)

Uses the shared definitions for this lesson's figures.

Setting the slope to zero gives $100 - 4x = 0$, so $x = 25$, the value our table pointed to. For this particular function we can confirm it without calculus. Completing the square gives $A(x) = 1250 - 2(x - 25)^2$, which is 1250 minus something that is never negative, so no width does better than 25. But completing the square works only for quadratics, and the slope idea promises to work for any function that has a derivative. Before relying on it we should ask why the slope at the top has to be zero. “The picture looks flat” is an observation about one picture.

Pause and try

At a width of 15 m the slope is $A'(15) = 40$ square meters per meter. Without computing any areas, explain why $x = 15$ cannot be the best width. Then do the same for $x = 35$, where $A'(35) = -40$.

Show answerHide answer

A slope of 40 means that near $x = 15$, each extra meter of width adds about 40 square meters. So a slightly wider field, say 15.1 m, has more area (about 4 m² more), and 15 is not the best. At $x = 35$ the slope is $-40$: each extra meter of width costs about 40 square meters, so each meter less gains about 40, and a slightly narrower field is better. A nonzero slope always points to a better neighbor, on one side or the other.

  1. At x = 15 the slope is +40. A step to the right goes up, so 15 is not the top.
  2. At x = 35 the slope is -40. A step to the left goes up, so 35 is not the top either.
  3. Only where the slope is 0 does neither direction offer a gain. That is x = 25.
Why the slope must be zero at the top. Wherever the slope is not zero, a small step in one direction goes uphill, so that point is not the highest.
Monocurl source
let ff = Wide(0, 52, 0, 1400)
let Probe = |x, col, dir| [
    Tangent(ff, A, 100 - 4 * x, x, 6, col),
    Pt(at(ff, x, A(x)), col, 0.1),
    Tip(at(ff, x + dir * 0.8, A(x) + 170), at(ff, x + dir * 6, A(x) + 170 + dir * (100 - 4 * x) * 5.2), col, 3.5)
]
mesh plot = Hill(ff)
mesh curve = Graph(ff, A, 0, 50, AZURE, 4.5)
mesh left = []
mesh right = []
mesh top = []
mesh notes = []

slide "At x = 15 the slope is +40. A step to the right goes up, so 15 is not the top."
    left = Probe(15, ROSE, 1)
    notes = [center{at(ff, 13, 330)} Math("A'(15) = 40", 0.82, ROSE)]
    play Fade(0.6)

slide "At x = 35 the slope is -40. A step to the left goes up, so 35 is not the top either."
    right = Probe(35, ROSE, -1)
    notes .= center{at(ff, 38, 330)} Math("A'(35) = -40", 0.82, ROSE)
    play Fade(0.6)

slide "Only where the slope is 0 does neither direction offer a gain. That is x = 25."
    top = [Tangent(ff, A, 0, 25, 7, LEAF), Pt(at(ff, 25, 1250), LEAF, 0.11)]
    notes .= center{at(ff, 25, 950)} Math("A'(25) = 0", 0.82, LEAF)
    play Fade(0.6)

Uses the shared definitions for this lesson's figures.

That is the whole argument, and it never used the formula for $A$. To state it as a theorem we need words for the things involved.

A global maximum is the highest point of the whole graph. A local maximum is the top of its own hill: highest among its near neighbors, with $\delta$ saying how near.

Compare the proof with the exercise. “Each extra meter adds area” was the quotient being positive for small positive $h$, which a maximum forbids. The step that needs care is the passage to the limit: quantities that are all $\le 0$ cannot have a positive limit, which the proof checked directly from the definition of a limit. Notice also where each hypothesis was used. The point $c$ had to be inside an open interval so that we could step both ways, and $f$ had to be differentiable at $c$ for there to be a slope to speak of. Both conditions matter, as we are about to see.

Three things the theorem does not say

Fermat’s theorem is a one-way statement: at an interior extremum with a derivative, the slope is zero. It is tempting to read more into it.

It does not say that slope zero means an extremum. Take $f(x) = x^3$. Then $f'(x) = 3x^2$ and $f'(0) = 0$. But $x^3$ is negative for $x < 0$ and positive for $x > 0$, so 0 is neither a local maximum nor a local minimum: the graph levels off for an instant and keeps climbing.

Three functions with slope 0 at x = 0. One has a maximum there, one a minimum, and one neither. The equation f'(c) = 0 finds candidates and cannot tell them apart.
Three functions with slope 0 at $x = 0$. One has a maximum there, one a minimum, and one neither. The equation $f'(c) = 0$ finds candidates and cannot tell them apart.
Monocurl source
let Flat = |i, f, reach, title, verdict, col| {
    let fm = Mini(i, -1.5, 1.5, -1.6, 1.6)
    return [
        GridLines(fm, [-1, 1], [-1, 1]),
        MiniAxes(fm, title, verdict, col),
        center{[fx(fm, -1), fy(fm, -1.6) - 0.22, 0]} Math("-1", 0.72, SLATE),
        center{[fx(fm, 1), fy(fm, -1.6) - 0.22, 0]} Math("1", 0.72, SLATE),
        center{[fx(fm, -1.5) - 0.17, fy(fm, 1), 0]} Math("1", 0.72, SLATE),
        Graph(fm, f, -reach, reach, AZURE, 4.5),
        Seg(at(fm, -0.7, 0), at(fm, 0.7, 0), EMBER, 4),
        Pt(at(fm, 0, 0), col, 0.1)
    ]
}
mesh panels = [
    Flat(0, |x| -x * x, 1.26, "-x^2", "maximum", LEAF),
    Flat(1, |x| x * x, 1.26, "x^2", "minimum", LEAF),
    Flat(2, |x| x ^ 3, 1.17, "x^3", "neither", ROSE)
]

Uses the shared definitions for this lesson's figures.

It does not say anything about points with no derivative. The function $|x|$ has its minimum at 0, at a corner, where it has no derivative. Solving $f'(x) = 0$ would never find it.

It does not say anything about endpoints. Suppose the farmer’s land is hemmed in so that the field must be at least 30 m wide. Now $x$ is restricted to $30 \le x \le 50$.

Pause and try

With the width restricted to $30 \le x \le 50$, what is the largest possible area, and what is the slope $A'(x)$ at the best width?

Show answerHide answer

On this interval $A'(x) = 100 - 4x$ is negative throughout (it is $-20$ at 30 and $-100$ at 50), so the area decreases as $x$ grows and the best choice is the smallest allowed width, $x = 30$, with $A(30) = 1200$ m². The slope there is $-20$, not zero. The farmer would like to step left, where the area is larger, and is not allowed to.

The same area function when the width must be at least 30 m. The top of the hill is outside the allowed interval, and the maximum is at the endpoint x = 30, where the slope is -20.
The same area function when the width must be at least 30 m. The top of the hill is outside the allowed interval, and the maximum is at the endpoint $x = 30$, where the slope is $-20$.
Monocurl source
let fe = Wide(0, 52, 0, 1400)
mesh banned = Region([at(fe, 0, 0), at(fe, 30, 0), at(fe, 30, 1400), at(fe, 0, 1400)], tint(ROSE, 0.1))
mesh plot = Hill(fe)
mesh ghost = stroke{tint(AZURE, 0.45), 3} dashed{[0.12, 0.08]} Polyline(map(sample(0, 30, 60), |x| at(fe, x, A(x))))
mesh curve = Graph(fe, A, 30, 50, AZURE, 5, 60)
mesh wall = Seg(at(fe, 30, 0), at(fe, 30, 1400), ROSE, 2.5)
mesh marks = [
    Ring(at(fe, 25, 1250), SLATE, 0.1, 3),
    Tangent(fe, A, -20, 30, 3.5),
    Pt(at(fe, 30, 1200), LEAF, 0.11),
    Pt(at(fe, 50, 0), INK, 0.08)
]
mesh labels = [
    center{at(fe, 14, 520)} Cap("not allowed", 0.74, ROSE),
    center{at(fe, 41, 1290)} Cap("best allowed: 1200", 0.74, LEAF),
    center{at(fe, 41, 1130)} Math("\text{slope } -20", 0.8, EMBER)
]

Uses the shared definitions for this lesson's figures.

So the points where an extremum can hide are of three kinds: interior points where the derivative is zero, interior points where the derivative does not exist, and endpoints. The first two get a name.

Is there a maximum at all?

One question has been skipped. We have been asking where the maximum is, which assumes there is one. A function need not have a maximum.

When is a highest point guaranteed? On an open interval the values of y = x approach 1 without reaching it. A function with a jump can do the same on a closed interval. A continuous function on a closed interval always attains a maximum.
When is a highest point guaranteed? On an open interval the values of $y = x$ approach 1 without reaching it. A function with a jump can do the same on a closed interval. A continuous function on a closed interval always attains a maximum.
Monocurl source
let fo = Mini(0, -0.2, 1.3, -0.2, 1.3)
let fj = Mini(1, -0.2, 1.3, -0.2, 1.3)
let fk = Mini(2, -0.2, 1.3, -0.2, 1.3)
let wig = |x| 0.55 + 0.4 * sin(5 * x - 0.6) * (1 - 0.5 * x)
let Unit = |fm| [GridLines(fm, [0.5, 1], [0.5, 1]), XTicks(fm, [1]), YTicks(fm, [1])]
mesh panels = [
    Unit(fo), MiniAxes(fo, "\text{open: } 0 < x < 1", "no maximum", ROSE),
    Unit(fj), MiniAxes(fj, "\text{a jump}", "no maximum", ROSE),
    Unit(fk), MiniAxes(fk, "\text{continuous on } [0, 1]", "maximum", LEAF)
]
mesh graphs = [
    Seg(at(fo, 0, 0), at(fo, 1, 1), AZURE, 4.5),
    Ring(at(fo, 0, 0), AZURE, 0.09, 3),
    Ring(at(fo, 1, 1), ROSE, 0.09, 3),
    Seg(at(fj, 0, 0.3), at(fj, 0.7, 1), AZURE, 4.5),
    Seg(at(fj, 0.7, 0.45), at(fj, 1, 0.45), AZURE, 4.5),
    Pt(at(fj, 0, 0.3), AZURE, 0.08),
    Ring(at(fj, 0.7, 1), ROSE, 0.09, 3),
    Pt(at(fj, 0.7, 0.45), AZURE, 0.08),
    Pt(at(fj, 1, 0.45), AZURE, 0.08),
    Graph(fk, wig, 0, 1, AZURE, 4.5),
    Pt(at(fk, 0, wig(0)), AZURE, 0.08),
    Pt(at(fk, 1, wig(1)), AZURE, 0.08),
    Pt(at(fk, 0.41, wig(0.41)), LEAF, 0.1)
]

Uses the shared definitions for this lesson's figures.

On the open interval $0 < x < 1$, the function $f(x) = x$ takes values as close to 1 as you like and never the value 1. Whatever point you propose as the highest, the point halfway between it and 1 is higher. The second panel does the same thing on the closed interval $[0, 1]$ by means of a jump. What rules out both failures is the pair of conditions in the following theorem.

We quote this theorem without proof. It is due to Bolzano and Weierstrass, and its proof, found in any real analysis text, depends on the same completeness property of the real numbers that underlies limits: among the rational numbers alone it is false. It is believable because the two panels on the left show the ways to dodge it on a bounded interval, an endpoint that is missing or a break in the graph, and the hypotheses exclude both. The word “bounded” excludes a third: on $[0, \infty)$ the function $f(x) = x$ is continuous and has no maximum.

Put the extreme value theorem together with Fermat’s theorem and we have a complete method.

For the fence: $A$ is continuous on $[0, 50]$, its only critical point is $x = 25$, and $A(0) = 0$, $A(25) = 1250$, $A(50) = 0$. The maximum is 1250 m², and this time the conclusion is a theorem that owes nothing to the graph or to completing the square.

Hill or valley: the second derivative

The closed interval method needs no knowledge of whether a critical point is a hill or a valley, because it compares values. But often we want to know, and often there are no endpoints to compare with. The function $x^3 - 3x$ shows how to tell.

Left: $f(x) = x^3 - 3x$ with its tangent line. Right: the slope $f'(x) = 3x^2 - 3$. At $x = -1$ the slope passes through 0 on its way down, which makes a hilltop. At $x = 1$ it passes through 0 on its way up, which makes a valley.
Monocurl source
let fl = Frame(-2.3, 2.3, -3.6, 3.6, [-1.85, -0.25, 0], 3.0, 3.1)
let fv = Frame(-2.3, 2.3, -4.5, 10.5, [1.95, -0.25, 0], 3.0, 3.1)
let f = |x| x ^ 3 - 3 * x
let df = |x| 3 * x * x - 3
# tick numbers along the bottom and left edges, clear of the curves and the riding tangent
let Edge = |fr, xs, ys| block {
    for (x in xs) {
        . center{[fx(fr, x), fy(fr, fr[2]) - 0.26, 0]} Math(to_string(x), 0.72, SLATE)
    }
    for (y in ys) {
        . center{[fx(fr, fr[0]) - 0.28, fy(fr, y), 0]} Math(to_string(y), 0.72, SLATE)
    }
}
# the tangent keeps the same length on screen whatever its slope
let Ride = |x| [
    Tangent(fl, f, df(x), x, 0.7 / sqrt(1 + (0.66 * df(x)) ^ 2)),
    Pt(at(fl, x, f(x)), EMBER, 0.09),
    Seg(at(fv, x, 0), at(fv, x, df(x)), EMBER, 2.5),
    Pt(at(fv, x, df(x)), EMBER, 0.09)
]
mesh panels = [
    GridLines(fl, [-2, -1, 1, 2], [-2, 2]), Axes(fl), Edge(fl, [-2, -1, 1, 2], [-2, 2]),
    GridLines(fv, [-2, -1, 1, 2], [-3, 3, 6, 9]), Axes(fv), Edge(fv, [-2, -1, 1, 2], [3, 6, 9]),
    center{[fx(fl, 0), fy(fl, 3.6) + 0.55, 0]} Math("f(x) = x^3 - 3x", 0.82, AZURE),
    center{[fx(fv, 0), fy(fv, 10.5) + 0.55, 0]} Math("f'(x) = 3x^2 - 3", 0.82, PLUM)
]
mesh curves = [
    Graph(fl, f, -2.2, 2.2, AZURE, 4.5),
    Graph(fv, df, -2.12, 2.12, PLUM, 4.5),
    Pt(at(fl, -1, 2), LEAF, 0.09),
    Pt(at(fl, 1, -2), LEAF, 0.09),
    Pt(at(fv, -1, 0), LEAF, 0.09),
    Pt(at(fv, 1, 0), LEAF, 0.09)
]
mesh ride = Ride(x: -2)

slide "ride"
    play Wait(0.5)
    ride.x = -1
    play Lerp(1.8, [&ride])
    play Wait(0.7)
    ride.x = 1
    play Lerp(2.6, [&ride])
    play Wait(0.7)
    ride.x = 2
    play Lerp(1.8, [&ride])
    play Wait(1)

Uses the shared definitions for this lesson's figures.

At a hilltop the slope goes from positive, through zero, to negative: the slope is decreasing. At the bottom of a valley it goes from negative to positive: the slope is increasing. Whether the slope $f'$ is decreasing or increasing is told by the sign of its derivative, the second derivative $f''$. Here $f''(x) = 6x$, so $f''(-1) = -6 < 0$ at the hilltop and $f''(1) = 6 > 0$ in the valley.

The proof uses the mean value theorem, quoted in an earlier lesson: if $f$ is continuous on $[p, q]$ and differentiable on $(p, q)$, then $f(q) - f(p) = f'(\xi)(q - p)$ for some $\xi$ between $p$ and $q$.

The second half of the proof is worth isolating, since it gives a global conclusion: if $f$ is continuous on an interval containing $c$, with $f' < 0$ at every point of the interval to the left of $c$ and $f' > 0$ at every point to the right, the same mean value argument shows $f(x) > f(c)$ for every other $x$ in the interval. That is the first derivative test, and it is what we use when the domain has no endpoints to check.

Worked examples

The surface area of a 355 cm³ can against its radius. The two ends (purple) need more metal as the can gets wider, and the side (gold) needs more as it gets narrower. Their sum (blue) is smallest at r \approx 3.84 cm.
The surface area of a 355 cm³ can against its radius. The two ends (purple) need more metal as the can gets wider, and the side (gold) needs more as it gets narrower. Their sum (blue) is smallest at $r \approx 3.84$ cm.
Monocurl source
let fcan = Wide(0, 8.4, 0, 720)
let ends = |r| 2 * PI * r * r
let side = |r| 710 / r
let R0 = (710 / (4 * PI)) ^ (1 / 3)
mesh plot = Ax(fcan, [2, 4, 6, 8], [200, 400, 600], "radius r (cm)", "surface area (cm²)", 1.4)
mesh parts = [
    Graph(fcan, ends, 0, 8.3, PLUM, 3),
    Graph(fcan, side, 0.99, 8.3, GOLD, 3),
    Graph(fcan, |r| ends(r) + side(r), 1.08, 8.3, AZURE, 4.5)
]
mesh best = [
    stroke{SLATE, 2} dashed{[0.1, 0.08]} Line(at(fcan, R0, 0), at(fcan, R0, ends(R0) + side(R0))),
    Seg(at(fcan, R0 - 1.1, ends(R0) + side(R0)), at(fcan, R0 + 1.1, ends(R0) + side(R0)), EMBER, 3.5),
    Pt(at(fcan, R0, ends(R0) + side(R0)), LEAF, 0.11)
]
mesh labels = [
    center{at(fcan, R0 + 0.1, 395)} Math(str_join(["r = ", to_string(R0, 2), ",\ S = ", to_string(ends(R0) + side(R0), 1)]), 0.78, LEAF),
    center{at(fcan, 6.7, 190)} Cap("two ends", 0.74, PLUM),
    center{at(fcan, 7.2, 40)} Cap("side", 0.74, GOLD),
    center{at(fcan, 6.3, 480)} Cap("total", 0.74, AZURE)
]

Uses the shared definitions for this lesson's figures.

Real drink cans are taller than this, about 12 cm against a width of 6.6 cm. The model minimizes area, while a manufacturer minimizes cost, and the ends of a can are made of thicker metal than the side. An optimum is only ever the optimum of the function you wrote down.

Check yourself

On the interval $[0, 4]$, where does $f(x) = x^2 - 2x$ attain its maximum value?

Looking back: the calculation, solving $f'(x) = 0$, is the easy part. The care goes into the logic around it. Fermat’s theorem only narrows the search to a short list of candidates; the extreme value theorem, or an argument about the sign of $f'$, is what guarantees that the best candidate is the answer. The same two-step pattern, a necessary condition that produces candidates and then a separate argument that selects among them, reappears when there are several variables, where “slope zero” becomes “every partial slope zero”.

Problems

The first three are direct applications, the next four need you to set up the function or justify the conclusion, and the last asks for a proof.

Problem 1

Find the maximum and minimum values of $f(x) = x^2 - 4x + 1$ on $[0, 5]$.

Show solutionHide solution

$f$ is continuous on $[0, 5]$ and $f'(x) = 2x - 4$, which is zero only at $x = 2$. Candidates: $f(0) = 1$, $f(2) = 4 - 8 + 1 = -3$, $f(5) = 25 - 20 + 1 = 6$. The maximum is 6 at $x = 5$ and the minimum is $-3$ at $x = 2$.

Problem 2

With no river, 100 m of fence must go around all four sides of a rectangular field. Which rectangle has the largest area?

Show solutionHide solution

Let the sides be $x$ and $y$ with $2x + 2y = 100$, so $y = 50 - x$ and $A(x) = x(50 - x) = 50x - x^2$ on $[0, 50]$. $A'(x) = 50 - 2x = 0$ at $x = 25$. Candidates: $A(0) = 0$, $A(25) = 625$, $A(50) = 0$. The best field is the 25 m by 25 m square, with area 625 m². Here the first guess of a square is right; the river changed the answer because it made one side free.

Problem 3

Find the critical points of $f(x) = x^3 - 6x^2 + 9x + 2$ and classify each with the second derivative test.

Show solutionHide solution

$f'(x) = 3x^2 - 12x + 9 = 3(x - 1)(x - 3)$, zero at $x = 1$ and $x = 3$. $f''(x) = 6x - 12$. At $x = 1$: $f''(1) = -6 < 0$, a local maximum, with $f(1) = 1 - 6 + 9 + 2 = 6$. At $x = 3$: $f''(3) = 6 > 0$, a local minimum, with $f(3) = 27 - 54 + 27 + 2 = 2$. Neither is global on the whole real line, since $f(x)$ grows without bound as $x \to \infty$ and falls without bound as $x \to -\infty$.

Problem 4

Two positive numbers have product 36. How small can their sum be? Justify that your answer is a global minimum.

Show solutionHide solution

Call one number $x > 0$; the other is $\frac{36}{x}$, and the sum is $s(x) = x + \frac{36}{x}$ on $(0, \infty)$. $s'(x) = 1 - \frac{36}{x^2} = \frac{x^2 - 36}{x^2}$, which is zero for positive $x$ only at $x = 6$. For $0 < x < 6$ the numerator is negative, so $s' < 0$; for $x > 6$ it is positive. By the first derivative test $s$ has its global minimum on $(0, \infty)$ at $x = 6$, where both numbers are 6 and the sum is 12. (The domain is open, so the closed interval method was not available.)

Problem 5

Find and classify the critical points of $f(x) = x^4 - 4x^3$.

Show solutionHide solution

$f'(x) = 4x^3 - 12x^2 = 4x^2(x - 3)$, zero at $x = 0$ and $x = 3$. $f''(x) = 12x^2 - 24x$. At $x = 3$: $f''(3) = 108 - 72 = 36 > 0$, a local minimum, with $f(3) = 81 - 108 = -27$. At $x = 0$: $f''(0) = 0$, so the test is silent and we look at the sign of $f'$. The factor $4x^2$ is positive on both sides of 0 and $x - 3$ is negative near 0, so $f' < 0$ on both sides: the function is decreasing before 0 and after it, and 0 is neither a maximum nor a minimum. Since $f' \le 0$ for all $x < 3$ and $f' > 0$ for $x > 3$, the mean value theorem gives $f(x) - f(3) = f'(\xi)(x - 3) \ge 0$ for every $x$, so the value $-27$ is the global minimum.

Problem 6

Find the point on the line $y = 2x + 1$ that is closest to the origin, and the distance.

Show solutionHide solution

The distance from the origin to $(x, 2x + 1)$ is $\sqrt{x^2 + (2x+1)^2}$. A positive quantity is smallest exactly when its square is smallest, so minimize $D(x) = x^2 + (2x + 1)^2 = 5x^2 + 4x + 1$ over all real $x$. $D'(x) = 10x + 4$, zero at $x = -0.4$, negative before and positive after, so this is the global minimum. The point is $(-0.4,\ 0.2)$, and $D = 5(0.16) - 1.6 + 1 = 0.2$, so the distance is $\sqrt{0.2} \approx 0.447$. Check: the segment from the origin to $(-0.4, 0.2)$ has slope $-\frac12$, and $-\frac12 \times 2 = -1$, so it is perpendicular to the line, as the shortest segment should be.

Problem 7

A student argues: “Let $f(x) = \frac1x$ on $[-1, 1]$. Its derivative $-\frac{1}{x^2}$ is never zero, so there are no critical points. The endpoints give $f(-1) = -1$ and $f(1) = 1$. By the closed interval method the maximum value is 1.” Find the error.

Show solutionHide solution

The closed interval method requires $f$ to be continuous on the whole of $[-1, 1]$, and $\frac1x$ is not even defined at $x = 0$. The extreme value theorem therefore does not apply, and in fact there is no maximum: $f(0.001) = 1000$, and values just to the right of 0 are as large as you please. The conclusion “maximum 1” is false. The hypotheses of a theorem have to be checked before its conclusion is used.

Problem 8

(Rolle’s theorem.) Let $f$ be continuous on $[a, b]$ and differentiable on $(a, b)$, with $f(a) = f(b)$. Prove that there is a point $c$ in $(a, b)$ with $f'(c) = 0$.

Show solutionHide solution

By the extreme value theorem, $f$ has a global maximum at some $c_1$ and a global minimum at some $c_2$ in $[a, b]$.

Case 1: at least one of $c_1$, $c_2$ lies in the open interval $(a, b)$. Call it $c$. It is a local extremum at an interior point where $f$ is differentiable, so Fermat’s theorem gives $f'(c) = 0$.

Case 2: both are endpoints. Since $f(a) = f(b)$, the maximum value and the minimum value of $f$ are the same number. Then $f$ is constant on $[a, b]$, its difference quotients are all 0, and $f'(c) = 0$ at every $c$ in $(a, b)$.

This is the step on which the mean value theorem rests: applying Rolle’s theorem to $f$ minus the straight line through $(a, f(a))$ and $(b, f(b))$ gives a point where $f'$ equals the slope of that line. So the chain of reasoning in this series runs: completeness of the real numbers, extreme value theorem, Fermat and Rolle, mean value theorem, and then both the second derivative test here and the evaluation of integrals in the lesson on the fundamental theorem.

Shared definitions used by this lesson's figures
# house kit: prepended to every essay figure after the std imports

# palette. AZURE and EMBER are the two actors, LEAF marks an answer, ROSE a problem
let PAPER = [1, 1, 1, 1]
let INK = [0.08, 0.09, 0.11, 1]
let SLATE = [0.40, 0.44, 0.50, 1]
let MIST = [0.85, 0.86, 0.88, 1]
let AZURE = [0.13, 0.42, 0.68, 1]
let EMBER = [0.89, 0.42, 0.12, 1]
let LEAF = [0.13, 0.55, 0.36, 1]
let ROSE = [0.78, 0.22, 0.24, 1]
let PLUM = [0.47, 0.30, 0.66, 1]
let GOLD = [0.85, 0.62, 0.08, 1]

background = PAPER

# an opaque pastel of col; use for fills so overlaps do not darken
let tint = |col, amount = 0.18| [
    1 - (1 - col[0]) * amount,
    1 - (1 - col[1]) * amount,
    1 - (1 - col[2]) * amount,
    1
]

# text: Cap for labels, Note for quiet labels, Math for typeset maths
let Cap = |txt, size = 0.75, col = INK| color{col} Text(txt, size, "Charter")
let Note = |txt, size = 0.65| color{SLATE} Text(txt, size, "Charter")
let Math = |tex, size = 0.9, col = INK| color{col} Tex(tex, size)

# a paper rectangle to sit behind text that crosses lines
let Plate = |pos, size| center{pos} fill{PAPER} stroke{alpha{0} PAPER, 0} Rect(size)

# shapes with fill and stroke both set, so no stray black appears
let Pt = |pos, col = INK, r = 0.075| center{pos} fill{col} stroke{col, 1} Circle(r, 48)
let Ring = |pos, col = INK, r = 0.1, w = 3| center{pos} fill{PAPER} stroke{col, w} Circle(r, 48)
let Seg = |a, b, col = INK, w = 3| stroke{col, w} Line(a, b)
let Path = |pts, col = INK, w = 3| stroke{col, w} Polyline(pts)
let Region = |pts, col| fill{col} stroke{alpha{0} col, 0} Polygon(pts)
let Outline = |pts, col = INK, w = 3| fill{alpha{0} PAPER} stroke{col, w} Polygon(pts)
let Shape = |pts, col, amount = 0.18, w = 3| fill{tint(col, amount)} stroke{col, w} Polygon(pts)
let Disc = |pos, r, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Circle(r, 96)
let Box = |pos, size, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Rect(size)
# a line from a to b ending in a small solid arrowhead
let Tip = |a, b, col = INK, w = 3, head = 0.17| {
    let d = normalize([b[0] - a[0], b[1] - a[1], 0])
    let n = [-d[1], d[0], 0]
    let base = [b[0] - d[0] * head, b[1] - d[1] * head, 0]
    return [
        stroke{col, w} Line(a, base),
        fill{col} stroke{col, 1} Polygon([
            b,
            [base[0] + n[0] * head * 0.42, base[1] + n[1] * head * 0.42, 0],
            [base[0] - n[0] * head * 0.42, base[1] - n[1] * head * 0.42, 0]
        ])
    ]
}

# plots. a frame is [x0, x1, y0, y1, centre, width, height]: a data window and the scene box it fills
let Frame = |x0, x1, y0, y1, c = [0, 0, 0], w = 6.4, h = 3.6| [x0, x1, y0, y1, c, w, h]
let fx = |fr, x| fr[4][0] + (x - (fr[0] + fr[1]) / 2) * fr[5] / (fr[1] - fr[0])
let fy = |fr, y| fr[4][1] + (y - (fr[2] + fr[3]) / 2) * fr[6] / (fr[3] - fr[2])
let at = |fr, x, y| [fx(fr, x), fy(fr, y), 0]

# axes through the data origin (or the nearest edge of the window), with optional names
let Axes = |fr, x_name = "", y_name = "", col = SLATE| {
    let ox = clamp(fr[0], 0, fr[1])
    let oy = clamp(fr[2], 0, fr[3])
    var parts = [
        Tip(at(fr, fr[0], oy), [fx(fr, fr[1]) + 0.25, fy(fr, oy), 0], col, 2.5, 0.15),
        Tip(at(fr, ox, fr[2]), [fx(fr, ox), fy(fr, fr[3]) + 0.25, 0], col, 2.5, 0.15)
    ]
    if (x_name != "") {
        parts .= center{[fx(fr, fr[1]) + 0.5, fy(fr, oy), 0]} Math(x_name, 0.8, col)
    }
    if (y_name != "") {
        parts .= center{[fx(fr, ox), fy(fr, fr[3]) + 0.5, 0]} Math(y_name, 0.8, col)
    }
    return parts
}

# tick marks with numbers at the listed data values
let XTicks = |fr, xs, col = SLATE, places = 0| block {
    let oy = fy(fr, clamp(fr[2], 0, fr[3]))
    for (x in xs) {
        . Seg([fx(fr, x), oy - 0.07, 0], [fx(fr, x), oy + 0.07, 0], col, 2)
        . center{[fx(fr, x), oy - 0.33, 0]} Math(to_string(x, places), 0.72, col)
    }
}
let YTicks = |fr, ys, col = SLATE, places = 0| block {
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], col, 2)
        . center{[ox - 0.36, fy(fr, y), 0]} Math(to_string(y, places), 0.72, col)
    }
}

# faint grid lines at the listed data values
let GridLines = |fr, xs, ys, col = MIST| block {
    for (x in xs) {
        . Seg(at(fr, x, fr[2]), at(fr, x, fr[3]), col, 1.5)
    }
    for (y in ys) {
        . Seg(at(fr, fr[0], y), at(fr, fr[1], y), col, 1.5)
    }
}

# the graph of f over [a, b], drawn in the frame. values are clamped to the window
let Graph = |fr, f, a, b, col = AZURE, w = 4, n = 160|
    stroke{col, w} Polyline(map(sample(a, b, n), |x| at(fr, x, clamp(fr[2], f(x), fr[3]))))

# the region between the graph of f and the x axis over [a, b]
let AreaUnder = |fr, f, a, b, col = AZURE, amount = 0.2, n = 80| {
    var pts = [at(fr, a, 0)]
    for (x in sample(a, b, n)) {
        pts .= at(fr, x, clamp(fr[2], f(x), fr[3]))
    }
    pts .= at(fr, b, 0)
    return fill{tint(col, amount)} stroke{alpha{0} col, 0} Polygon(pts)
}

# area in square meters of a field of width x meters, fenced on three sides with 100 m of fence
let A = |x| x * (100 - 2 * x)
let Wide = |x0, x1, y0, y1| Frame(x0, x1, y0, y1, [0.2, 0.22, 0], 6.1, 3.0)
# axes with a grid and numbered ticks; the y numbers sit a little further out so four digits fit
let Ax = |fr, xs, ys, x_name, y_name, y_dx = 1.0, places = 0| block {
    . GridLines(fr, xs, ys)
    . Axes(fr)
    . XTicks(fr, xs, SLATE, places)
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], SLATE, 2)
        . center{[ox - 0.47, fy(fr, y), 0]} Math(to_string(y), 0.72, SLATE)
    }
    . center{[fx(fr, fr[1]) - 0.75, fy(fr, clamp(fr[2], 0, fr[3])) - 0.68, 0]} Note(x_name, 0.72)
    . center{[ox + y_dx, fy(fr, fr[3]) + 0.32, 0]} Note(y_name, 0.72)
}
let Hill = |fr| Ax(fr, [10, 20, 30, 40, 50], [500, 1000], "width x (m)", "area (m²)", 0.85)
# a short piece of the tangent line to f at x, with slope m, reaching `reach` to each side
let Tangent = |fr, f, m, x, reach, col = EMBER, w = 3.5|
    stroke{col, w} Line(at(fr, x - reach, f(x) - m * reach), at(fr, x + reach, f(x) + m * reach))
# three small plots side by side
let Mini = |i, x0, x1, y0, y1| Frame(x0, x1, y0, y1, [-2.45 + 2.45 * i, 0, 0], 2.05, 2.5)
let MiniAxes = |fr, title, verdict, col| [
    Axes(fr),
    center{[fx(fr, (fr[0] + fr[1]) / 2), fy(fr, fr[3]) + 0.55, 0]} Math(title, 0.82, AZURE),
    center{[fx(fr, (fr[0] + fr[1]) / 2), fy(fr, fr[2]) - 0.62, 0]} Cap(verdict, 0.74, col)
]