TExcelTAD
Home › Calculus in Depth › Maximum and Minimum Values

Maximum and Minimum Values

Where does a function reach its highest and lowest values? This lesson gives the precise definitions of absolute and local extrema, the Extreme Value Theorem that guarantees them on closed intervals, Fermat's theorem with its proof, and the closed interval method that turns "find the maximum" into a finite checklist. For a gentler first look, see Extrema.

Definitions

Let cc be a number in the domain DD of ff.

Term Definition
absolute (global) maximum at cc f(c)≥f(x)f(c) \ge f(x) for every xx in DD
absolute minimum at cc f(c)≤f(x)f(c) \le f(x) for every xx in DD
local (relative) maximum at cc f(c)≥f(x)f(c) \ge f(x) for every xx in some open interval around cc
local minimum at cc f(c)≤f(x)f(c) \le f(x) for every xx in some open interval around cc
critical number cc in DD with f′(c)=0f'(c) = 0 or f′(c)f'(c) undefined

The value f(c)f(c) is the maximum or minimum value; cc is where it happens. Note that with this definition a local extremum needs an open interval around cc, so an endpoint of a closed domain is never a local extremum, though it can be an absolute one.

The Extreme Value Theorem

Extreme Value Theorem. If ff is continuous on a closed interval [a,b][a, b], then ff attains an absolute maximum value f(c)f(c) and an absolute minimum value f(d)f(d) at some numbers c,dc, d in [a,b][a, b].

Both hypotheses matter. f(x)=1/xf(x) = 1/x on (0,1](0, 1] is continuous but the interval is not closed: no maximum. f(x)=x−⌊x⌋f(x) = x - \lfloor x \rfloor on [0,1][0, 1] is on a closed interval but jumps at 1: it gets arbitrarily close to 1 and never reaches it on [0,1)[0, 1), and f(1)=0f(1) = 0. The proof needs the completeness of the real numbers (every bounded set has a least upper bound) and is usually given in a course in real analysis; here we take it as given.

Fermat's theorem

Fermat's Theorem. If ff has a local maximum or minimum at cc, and f′(c)f'(c) exists, then f′(c)=0f'(c) = 0.

Proof (local maximum; the minimum case is the same with inequalities flipped). For all hh close enough to 0, f(c+h)≤f(c)f(c + h) \le f(c), so f(c+h)−f(c)≤0f(c + h) - f(c) \le 0.

h>0:f(c+h)−f(c)h≤0⇒lim⁡h→0+…=f′(c)≤0h<0:f(c+h)−f(c)h≥0⇒lim⁡h→0−…=f′(c)≥0\begin{aligned} h > 0&: \quad \frac{f(c+h) - f(c)}{h} \le 0 \quad \Rightarrow \quad \lim_{h \to 0^+} \ldots = f'(c) \le 0 \\ h < 0&: \quad \frac{f(c+h) - f(c)}{h} \ge 0 \quad \Rightarrow \quad \lim_{h \to 0^-} \ldots = f'(c) \ge 0 \end{aligned}

Since f′(c)f'(c) exists, both one-sided limits equal it, so 0≤f′(c)≤00 \le f'(c) \le 0, i.e. f′(c)=0f'(c) = 0. ∎

The converse is false: f(x)=x3f(x) = x^3 has f′(0)=0f'(0) = 0 and no extremum at 0. And an extremum can sit where f′f' does not exist, as ∣x∣\lvert x \rvert at 0 shows. So Fermat's theorem says only: local extrema in the interior happen at critical numbers.

The closed interval method

To find the absolute extrema of a continuous ff on [a,b][a, b]:

  1. Find the values of ff at the critical numbers in (a,b)(a, b).
  2. Find f(a)f(a) and f(b)f(b).
  3. The largest of these is the absolute maximum, the smallest the absolute minimum.

It works because the extremum exists (EVT), and if it is at an interior point it is a local extremum there, hence at a critical number (Fermat). SymPy does the bookkeeping exactly:

python · try it yourself
import sympy as sp

x = sp.symbols('x', real=True)
f = x**4 - 4*x**3 + 2*x**2 + 3
a, b = -1, 4

crit = [c for c in sp.solve(sp.diff(f, x), x) if a < c < b]
candidates = crit + [a, b]
for c in candidates:
    v = sp.simplify(f.subs(x, c))
    print(f"x = {str(c):18} f = {str(v):20} ≈ {float(v):8.4f}")
vals = [f.subs(x, c) for c in candidates]
print("absolute max ≈", round(float(max(vals)), 4), " absolute min ≈", round(float(min(vals)), 4))
x = 0                  f = 3                    ≈   3.0000
x = 3/2 - sqrt(5)/2    f = -5/2 + 5*sqrt(5)/2   ≈   3.0902
x = sqrt(5)/2 + 3/2    f = -5*sqrt(5)/2 - 5/2   ≈  -8.0902
x = -1                 f = 10                   ≈  10.0000
x = 4                  f = 35                   ≈  35.0000
absolute max ≈ 35.0  absolute min ≈ -8.0902

The maximum, 35, is at the endpoint x=4x = 4; the minimum, −5+552≈−8.09-\frac{5 + 5\sqrt{5}}{2} \approx -8.09, is at the critical number x=3+52x = \frac{3 + \sqrt{5}}{2}. The local maximum f(0)=3f(0) = 3 is not the absolute one. SymPy prints sqrt(5) for 5\sqrt{5}.

A critical number where f′f' does not exist

g(x)=x2/3(x−5)g(x) = x^{2/3}(x - 5) on [−1,4][-1, 4]. Here g′(x)=5x−103x1/3g'(x) = \frac{5x - 10}{3x^{1/3}}, which is 0 at x=2x = 2 and undefined at x=0x = 0. Both are critical numbers, and SymPy's solve on g′=0g' = 0 only finds the first, so we add the second ourselves:

python · try it yourself
import sympy as sp

x = sp.symbols('x', real=True)
g = sp.real_root(x, 3)**2 * (x - 5)  # real cube root, valid for x < 0 too
t = sp.symbols('t', positive=True)   # differentiate where x > 0 to see the formula
print("g'(x) =", sp.factor(sp.diff(t**sp.Rational(2, 3) * (t - 5), t)))
crit = [2, 0]                        # g' = 0 at 2; g' undefined at 0
for c in crit + [-1, 4]:
    print(f"g({c:2}) = {float(g.subs(x, c)): .4f}")
g'(x) = 5*(t - 2)/(3*t**(1/3))
g( 2) = -4.7622
g( 0) =  0.0000
g(-1) = -6.0000
g( 4) = -2.5198

The minimum is g(−1)=−6g(-1) = -6 at an endpoint, and the maximum g(0)=0g(0) = 0 sits at a cusp, which no derivative test that only solves f′=0f' = 0 would find.

In software

  • Bounding boxes and culling. To fit an axis-aligned box around a Bézier curve, a renderer finds where each coordinate's derivative is 0 on [0,1][0, 1] and checks the endpoints: the closed interval method, solved with a quadratic formula.
  • Clamped parameters. In optimisation with box constraints (a learning rate in [1e−5, 1], a joint angle with limits) the best value is either an interior critical point or a boundary value, exactly as here. Projected gradient methods encode this rule.
  • Robust code checks both. A frequent bug is to solve f′=0f' = 0 and forget endpoints and non-differentiable points (abs, max, ReLU kinks).

Exercises

Exercise 1: Classify the critical numbers

Find all critical numbers of f(x)=x3−12x+1f(x) = x^3 - 12x + 1.

Answer

x=−2x = -2 and x=2x = 2.

Solution
f′(x)=3x2−12=3(x−2)(x+2)=0⇒x=±2f′ exists everywhere, so there are no other critical numbers.\begin{aligned} &f'(x) = 3x^2 - 12 = 3(x - 2)(x + 2) = 0 \quad \Rightarrow \quad x = \pm 2 \\ &f' \text{ exists everywhere, so there are no other critical numbers.} \end{aligned}

Exercise 2: Closed interval method by hand

Find the absolute maximum and minimum of f(x)=x3−12x+1f(x) = x^3 - 12x + 1 on [−3,5][-3, 5].

Answer

Maximum 66 at x=5x = 5, minimum −15 at x=2x = 2.

Solution
f(−3)=−27+36+1=10f(−2)=−8+24+1=17f(2)=8−24+1=−15f(5)=125−60+1=66\begin{aligned} f(-3) &= -27 + 36 + 1 = 10 \\ f(-2) &= -8 + 24 + 1 = 17 \\ f(2) &= 8 - 24 + 1 = -15 \\ f(5) &= 125 - 60 + 1 = 66 \end{aligned}

The largest is 66 (an endpoint), the smallest −15.

python · try it yourself
f = lambda x: x**3 - 12*x + 1
pts = [-3, -2, 2, 5]
print({p: f(p) for p in pts})
{-3: 10, -2: 17, 2: -15, 5: 66}

Exercise 3: A trigonometric extremum

Find the absolute extrema of h(x)=x+2cos⁡xh(x) = x + 2\cos x on [0,π][0, \pi].

Answer

Maximum π6+3≈2.2556\frac{\pi}{6} + \sqrt{3} \approx 2.2556 at x=π6x = \frac{\pi}{6}; minimum 5π6−3≈0.8859\frac{5\pi}{6} - \sqrt{3} \approx 0.8859 at x=5π6x = \frac{5\pi}{6}.

Solution
h′(x)=1−2sin⁡x=0⇒sin⁡x=12⇒x=π6 or 5π6h(0)=2,h(π6)=π6+3≈2.2556,h(5π6)=5π6−3≈0.8859,h(π)=π−2≈1.1416\begin{aligned} &h'(x) = 1 - 2 \sin x = 0 \quad \Rightarrow \quad \sin x = \tfrac{1}{2} \quad \Rightarrow \quad x = \tfrac{\pi}{6} \text{ or } \tfrac{5\pi}{6} \\ &h(0) = 2, \quad h(\tfrac{\pi}{6}) = \tfrac{\pi}{6} + \sqrt{3} \approx 2.2556, \quad h(\tfrac{5\pi}{6}) = \tfrac{5\pi}{6} - \sqrt{3} \approx 0.8859, \quad h(\pi) = \pi - 2 \approx 1.1416 \end{aligned}
python · try it yourself
import math
h = lambda x: x + 2 * math.cos(x)
for x in [0, math.pi / 6, 5 * math.pi / 6, math.pi]:
    print(round(x, 4), round(h(x), 4))
0 2.0
0.5236 2.2556
2.618 0.8859
3.1416 1.1416

Exercise 4: Why the hypotheses matter

Give a function on [0,2][0, 2] with no absolute maximum, and say which hypothesis of the EVT it breaks.

Answer

For example f(x)=1x−1f(x) = \frac{1}{x - 1} for x≠1x \ne 1, f(1)=0f(1) = 0: unbounded near 1, not continuous at 1.

Solution

The interval is closed, so continuity must fail. As x→1+x \to 1^+, 1x−1→+∞\frac{1}{x - 1} \to +\infty, so no value is largest. Defining f(1)=0f(1) = 0 keeps ff defined on all of [0,2][0, 2], but the discontinuity at 1 breaks the theorem's hypothesis.

Test yourself

f′(c)=0f'(c) = 0. What can you conclude?

  1. cc is a critical number, nothing more
  2. ff has a local extremum at cc
  3. ff has an absolute extremum at cc
  4. f′′(c)≠0f''(c) \ne 0

Which function is guaranteed an absolute maximum by the Extreme Value Theorem?

  1. 1/x1/x on (0,1](0, 1]
  2. tan⁡x\tan x on (−π/2,π/2)(-\pi/2, \pi/2)
  3. e−x2sin⁡xe^{-x^2} \sin x on [−3,3][-3, 3]
  4. x−⌊x⌋x - \lfloor x \rfloor on [0,1][0, 1]

In the closed interval method, which points do you compare?

  1. Only critical numbers
  2. Critical numbers in (a,b)(a, b) and the endpoints a,ba, b
  3. Only endpoints
  4. Points where f′′=0f'' = 0