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
Suppose you’ve found the peaks and valleys in the interior of an interval. Are you
done? Not yet — the exam usually 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 is not automatically the tallest point in the room.
There’s a clean theorem that makes 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 the interval. And those winners
can only live in two places: at an interior critical point, or at an endpoint. That’s
a short, finite list of suspects — exactly what GATE wants you to check.
This “check the interior and the boundary” habit is exactly 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, but just as often it’s pinned at one end.
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.
No second-derivative test is needed — you are not classifying the points, just comparing their heights. The whole method is “evaluate and compare.”
b. Always evaluate a and b too.Play with this on a cubic. Pick x³ − x and slide the point across the plotted
domain. The tangent flattens at the two interior critical points — but watch what
happens at the ends of the curve: the function climbs higher (and dips lower) there
than at either critical point. On a closed interval those endpoint values are
candidates too, and the global winner is often one of them.
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: a candidate forgets the endpoints
and reports an interior local extremum as the global answer. GATE DA 2025 used 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 before:
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 is tied between an interior critical point
(x = −1) and an endpoint (x = 2), and the global minimum is tied 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.
Quick check
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.