With 20 m of fence for a rectangle, a 1×9 pen has area 9, a 3×7 pen 21, a 5×5 pen 25 and a 7×3 pen 21 again. The area rises, peaks and falls. Write it as a function of one side: if one side is x, the other is 10−x, so A(x)=x(10−x)=10x−x2. At the peak the graph is flat for an instant: just before it the area is increasing, just after it the area is decreasing, so the slope changes from positive to negative and passes through zero.
That gives the method. Solve A′(x)=10−2x=0 to get x=5. Then classify: A′′(x)=−2<0, so the graph bends downward and x=5 is a peak. The best pen is the 5×5 square, 25 m². In word problems most of the work is the setup: using the constraint (perimeter 20) to turn a quantity with two variables into a function of one.
A zero slope does not guarantee a maximum, or even an extreme value. f(x)=x3 has f′(0)=0, yet it keeps rising on both sides: the graph only pauses. The best value can also sit at an end of the allowed range. On 0≤x≤3, g(x)=x2−2x has its only critical point at x=1, and that is the minimum, g(1)=−1; the maximum, g(3)=3, is at an endpoint where the slope is not zero.
Think of it like this. Hiking a ridge in fog, you know you are at a summit or the bottom of a dip when the path goes level, so level ground is where to look. But a level spot can also be a flat ledge partway up a climb, and the hike's highest point might be where the trail ends at a cliff. So check every level spot and both ends.
Core idea. Optimization uses derivatives to find a function's maxima and minima by locating where f′(x)=0 and classifying them.