Optimization with Derivatives

Calculus · about 2 min read · updated October 2026

Optimization is the practical payoff of differentiation. It answers questions of the form "what choice gives the best result" — the most area, the least cost, the greatest profit, the shortest distance. The tool that makes all of these tractable is the derivative, because a function is momentarily flat at every peak and every valley.

That flatness is the key insight. Where a smooth curve reaches a maximum or a minimum, its tangent line is horizontal, which means the derivative there equals zero.

A maximum where the tangent line is horizontal
A maximum where the tangent line is horizontal

Critical Points

A critical point is any input $c$ where $f'(c) = 0$ or where the derivative fails to exist. Candidate optima can only occur at critical points or at the endpoints of an interval, so the search procedure is the same every time:

  1. Differentiate the function.
  2. Solve $f'(x) = 0$ to find critical points.
  3. Test each candidate to classify it as a maximum or a minimum.

The first derivative test does the classification. If $f'$ changes from positive to negative at $c$, the function was rising then falling, so $c$ is a local maximum. If $f'$ changes from negative to positive, $c$ is a local minimum. If the sign does not change, the point is neither.

A Worked Example

A farmer has $40$ metres of fencing and wants to enclose a rectangular pen against an existing wall, so only three sides need fencing. What dimensions maximise the area?

Let $x$ be the width perpendicular to the wall and $y$ the length along the wall. The fencing condition is

$$ 2x + y = 40 \quad\Rightarrow\quad y = 40 - 2x $$

The area is $A = xy$, so substituting removes one variable:

$$ A(x) = x(40 - 2x) = 40x - 2x^{2} $$

Differentiate and set the result to zero:

$$ A'(x) = 40 - 4x = 0 \quad\Rightarrow\quad x = 10 $$

Since $A''(x) = -4 < 0$, the curve is concave down and this critical point is a maximum. The optimal pen is $10$ metres wide with $y = 20$ metres along the wall, giving an area of $200 \text{ m}^2$.

The Second Derivative Test

There is a faster classification when the second derivative is easy to compute. At a critical point $c$: if $f''(c) < 0$, the curve bends downward and $c$ is a maximum; if $f''(c) > 0$, it bends upward and $c$ is a minimum. Because a negative second derivative means the slope itself is decreasing, the tangent goes from positive to negative — exactly the signature of a peak.

Setting Up the Problem

Most difficulty in optimization is not calculus but translation. The reliable framework is: name the quantity to be optimised, write it as a formula, use any given constraints to reduce it to a single variable, then differentiate. Failing to apply the constraint first is the most common reason a problem becomes unsolvable.

Common Mistakes to Watch For

Watch for forgetting to check endpoints when the domain is a closed interval, since the best value could sit at a boundary rather than a critical point. A second error is assuming every critical point is an optimum; some are inflection-like flat spots. Always classify before declaring an answer.

Key takeaway: optima hide where the slope is zero, so differentiate, solve for the flat points, and classify each one before choosing.

Practice it: try the equation solver or generate a practice set on this topic.

More calculus guides