Optimization on a Closed Interval
To find the global max and min of a continuous function on a closed interval, compare every critical point against both endpoints — the endpoints are the part everyone forgets.
What you'll learn
- The Extreme Value Theorem guarantees a continuous function on a closed interval `[a, b]` attains a global max and min
- The candidates are the interior critical points PLUS the two endpoints `a` and `b`
- Evaluate `f` at every candidate, then pick the largest and smallest values
- The global extremum can sit at an endpoint — never skip evaluating `a` and `b`
Before you start
Last lesson ended with a warning: a local minimum is only the bottom of one valley, and the
true global best might lie elsewhere — even at the very edge of the domain. So suppose you have
dutifully found every peak and valley in the interior of an interval. Are you done? Not yet.
The exam almost always wants the single highest and lowest value f takes anywhere on
[a, b], and that winner can easily sit at one of the endpoints. A local peak in the middle of
the room is not automatically the tallest point in the room.
There is a clean theorem that keeps the search short. If f is continuous on a closed
interval [a, b], the Extreme Value Theorem promises that f actually attains a global
max and a global min somewhere on it. And those winners can live in only two kinds of place:
at an interior critical point, or at an endpoint. That is a short, finite list of suspects —
exactly what GATE wants you to check.
This “search the interior and the boundary” habit is precisely what you do when tuning a
hyperparameter over a fixed range — a learning rate in [0.001, 0.1], say. The best value is
sometimes inside the range, but just as often it is pinned to one end, and you would never know
without checking both.
The closed-interval method
To find the global max and min of a continuous f on [a, b]:
1. Find the critical points inside (a, b): solve f'(x) = 0
(and note any x in (a, b) where f' is undefined).
2. List the candidates: those interior critical points + the endpoints a and b.
3. Evaluate f at EVERY candidate.
4. Largest value = global maximum. Smallest value = global minimum.
Notice what is not here: no second-derivative test. You are not classifying any point as a peak or trough — you are only comparing their heights. The whole method is “evaluate and compare,” and the endpoints are full candidates in that comparison, not afterthoughts.
b. Always evaluate a and b too.The figure makes the lesson’s whole point visible. The interior peak is only a local maximum,
while the curve quietly climbs higher at the right endpoint b — where the slope is nowhere
near flat. On a closed interval those endpoint heights are candidates in their own right, and
the global winner is often one of them, exactly as the worked example below confirms.
How GATE asks this
Look for a NAT or MSQ that says “find the global maximum (or minimum) value of f on
[a, b],” or an MSQ probing why you must check endpoints or when the Extreme Value Theorem
applies. The reliable trap is a solver who forgets the endpoints and reports an interior local
extremum as the global answer. GATE DA 2025 used exactly this shape — a polynomial on a closed
interval where one endpoint held the true extreme.
Worked example — based on a real GATE DA 2025 question
Find the global maximum and global minimum of
f(x) = x³ − 3xon the closed interval[−2, 2].
Step 1 — interior critical points. Same derivative as the last two lessons:
f'(x) = 3x² − 3 = 0 → x = −1 and x = +1 (both lie inside (−2, 2))
Step 2-3 — evaluate f at all four candidates (two critical points, two endpoints):
candidate type f(x) = x³ − 3x
──────────────────────────────────────────────────────
x = −2 endpoint (−2)³ − 3(−2) = −8 + 6 = −2
x = −1 critical point (−1)³ − 3(−1) = −1 + 3 = 2
x = +1 critical point (1)³ − 3(1) = 1 − 3 = −2
x = +2 endpoint (2)³ − 3(2) = 8 − 6 = 2
Step 4 — compare. The largest value is 2; the smallest is −2:
global maximum = 2 (attained at x = −1 and at x = 2)
global minimum = −2 (attained at x = 1 and at x = −2)
Notice that the global maximum ties between an interior critical point (x = −1) and an
endpoint (x = 2), and the global minimum ties between x = 1 and the endpoint x = −2. Had
you skipped the endpoints, you would have missed half of where the extremes actually occur —
and on a different interval, the endpoint could have been the sole winner, as the practice
below shows.
A question to carry forward
The closed-interval method is reliable, but look at the labour it demands: list every candidate, evaluate, and compare. Worse, a wiggly function can carry many local minima, and the method gives no assurance that a deeper one is not hiding between the ones you found — you simply have to check them all. Yet some functions are so well-shaped that this anxiety vanishes: a single bowl, one bottom, no false valleys to fear. Here is the thread onward: is there a class of functions where any local minimum is automatically the global minimum — so an optimiser can stop the instant it finds a flat spot, confident it has found the best point of all? That property is the quiet hero behind why machine learning works at all.
In one breath
- On a closed, bounded interval
[a, b], a continuousfis guaranteed a global max and min by the Extreme Value Theorem. - Closed-interval method: find interior critical points (
f'=0or undefined), add the endpointsa,b, evaluatefat all, then take the largest and smallest. No second-derivative test — just evaluate and compare. - The global extremum can sit at an endpoint, where
f'is generally non-zero — forgettingaandbis the classic lost mark (GATE DA 2025). x³ − 3xon[−2, 2]: global max2(atx = −1andx = 2), global min−2(atx = 1andx = −2).- EVT needs continuity + a closed interval: on
(0, 1)or with a jump, a global extremum can simply not exist.
Practice
Quick check
Practice this in an interview
All questionsBinary search halves the search space each iteration to find a target in O(log n). The tricky part is not the idea but the boundary conditions: closed vs. half-open intervals, how to update lo/hi, and when to use lo < hi vs. lo <= hi. One clean template eliminates all the classic bugs.
Gaps-and-islands is the problem of identifying contiguous ranges (islands) within ordered sequential data and the breaks (gaps) between them. The classic solution subtracts a dense sequential integer from the ordering column — equal differences belong to the same island.
Scan left to right, carrying a running sum. At each element, decide: extend the existing subarray (add to the running sum) or start fresh (take just the current element). Whichever is larger becomes the new running sum. Track the global maximum throughout. One pass, O(n) time, O(1) space.
Logistic regression minimizes binary cross-entropy (log-loss), which is the negative log-likelihood of the Bernoulli distribution given the sigmoid-transformed linear predictions. The Hessian of log-loss is positive semi-definite everywhere, guaranteeing a convex surface with a unique global minimum.