Calculus

Optimization: Finding the Best

What is the largest area you can enclose with a fixed amount of fencing? What shape of can uses the least material? These are optimization problems, and calculus gives you a systematic way to solve them.

The key insight: at a maximum or minimum, the derivative is zero.

1. Peaks and Valleys

Think about hiking. At the top of a hill, the trail is momentarily flat — you stop climbing and are about to descend. At the bottom of a valley, same thing — flat for an instant. The slope (derivative) is zero at these turning points.

-112345-4-3-2-112345678x = -0.1x = 1x = 3f(x) = x³ - 6x² + 9x + 1f'(x) = 3x² - 12x + 9

The red curve (derivative) crosses zero at x = 1 and x = 3. Look at the blue curve at those points: x = 1 is a local maximum and x = 3 is a local minimum.

2. Finding Critical Points

The recipe for optimization:

  1. Take the derivative f’(x)
  2. Set f’(x) = 0 and solve
  3. Check whether each solution is a max, min, or neither

Let’s practice with a function you can control. The parameter a shifts the function.

a (parameter)1
-33
f(x)=x2+1x+2f(x) = -x^2 + 1 \cdot x + 2
f(x)=2x+1=0    x=10f'(x) = -2x + 1 = 0 \implies x = \frac{{1}}0
-4-224-4-22468(0.5, 2.25)f(x)f'(x)
Try This

Try this: Drag a and watch the vertex (peak) of the parabola slide left and right. The red derivative line always crosses zero at the peak location. The critical point moves to x = a/2 exactly as the formula predicts.

3. The Second Derivative Test

Finding where f’(x) = 0 tells you where the extrema are. But is it a maximum or a minimum? The second derivative answers that:

Second Derivative Test:f(c)<0    0,f(c)>0    0\text{Second Derivative Test:} \quad f''(c) < 0 \implies \text0, \quad f''(c) > 0 \implies \text0
b (shift cubic)0
-44
f(x)=x33x+0f(x) = x^3 - 3x + 0
f(x)=3x23,f(x)=6xf'(x) = 3x^2 - 3, \quad f''(x) = 6x
f(1)=6<0 (max),f(1)=6>0 (min)f''(-1) = -6 < 0 \text{ (max)}, \quad f''(1) = 6 > 0 \text{ (min)}
-4-224-8-6-4-22468f(x) = x³ - 3x + bf'(x) = 3x² - 3f''(x) = 6x
Connection

The green line is the second derivative. At x = -1, the green line is negative (curve bends down = local max). At x = 1, the green line is positive (curve bends up = local min). Changing b slides the function up and down but does not change where the critical points are — the derivative does not depend on b.

4. Optimization with Constraints

Real optimization problems often have constraints. Here is a classic: you have a fixed perimeter P, and you want to make a rectangle with maximum area.

If the width is x, then the height is (P/2 - x), and the area is:

P (perimeter)12
420
A(x)=x(120x)=120xx2A(x) = x \cdot \left(\frac{{12}}0 - x\right) = \frac{{12}}0x - x^2
A(x)=1202x=0    x=120A'(x) = \frac{{12}}0 - 2x = 0 \implies x = \frac{{12}}0
24681012-4-22468101214(3, 9)A(x) = areaA'(x)
Try This

Try this: With P = 12, the optimal width is 12/4 = 3, and the height is also 3. A square maximizes the area for a given perimeter. Change P and confirm: the optimal rectangle is always a square.

5. Watching the Optimal Point Move

As the constraint parameter changes, the best solution changes too. This is a powerful idea: optimization is not a one-time answer but a relationship between constraints and optima.

c (constraint)2
0.55
f(x)=(x2)2+22f(x) = -(x - 2)^2 + 2^2
Maximum at x=2,max value=22\text{Maximum at } x = 2, \quad \text{max value} = 2^2
510-551015202530(2.01, 4)
Challenge

Challenge: A farmer has 200 meters of fencing and wants to create a rectangular pen against a barn wall (so only 3 sides need fencing). If the width perpendicular to the barn is x, the area is A = x(200 - 2x). Find the value of x that maximizes the area. What are the dimensions of the optimal pen?

The Big Idea

To find the best value of something, take the derivative, set it equal to zero, and solve. The second derivative tells you if you found a maximum or minimum.

Optimization is one of the most practical tools in all of calculus. Engineers use it to design efficient structures, economists use it to maximize profit, and scientists use it to find equilibrium states. The recipe is always the same: express what you want to optimize as a function, then let the derivative find the peak or valley.

Take the Quiz