Finding the Best with Derivatives — A Story of Maxima and Minima

Finding the Best with Derivatives

Reading

Every day, we look for the best in many situations: the cheapest shop, the shortest route, or the tastiest recipe. When we think about it, many questions in life come down to wanting to make something as large or as small as possible.

What is interesting is that many of these searches for the best can be solved with just one tool: derivatives. Before getting into calculation methods, let's take a relaxed look at why derivatives give us a clue for finding the best value.

At the Top, the Ground Becomes Flat

Imagine climbing a mountain. As you walk from the foot of the mountain toward the summit, the ground is always sloping upward. Eventually, you reach the top. Once you pass it, the path begins to slope downward. So what happens to the ground at the very top of the mountain?

That's right. For just a moment, it becomes flat. The slope is neither upward nor downward; its slope is zero. The same thing happens at the bottom of a valley. At the lowest point, where the downward slope changes to an upward one, the ground is flat again. The observation that "the tangent is horizontal at the highest or lowest point" is at the heart of optimization.

A derivative is precisely the tool that tells us the slope of the tangent at each point. So, to find the best value, we can look for points where the derivative is zero. Instead of walking all over the mountain, we can narrow down the candidates for the top or bottom by focusing on places where the slope is zero. For a closer look at how increasing and decreasing behavior can be understood from the sign of the slope, see Chapter 6: The Meaning of the Derivative.

At the optimal point, the tangent is horizontal: the top is where the slope changes from positive to negative ↑ ↓ Maximum Slope + Slope −
$x$
$y$
$y = f(x)$
$x^*$
Slope $\gt 0$ (uphill)
Slope $\lt 0$ (downhill)
Slope $= 0$ (flat)
The top is where the slope changes from + → $0$ → −
Figure 1. For a hill-shaped function $y=f(x)$, the tangent is horizontal at the top, where the slope changes from uphill ($f'(x) > 0$) to downhill ($f'(x) < 0$). In other words, $f'(x^*)=0$ at this point. The slope passes through zero at the point where the function reaches its highest value.

Making a Can That Uses the Least Material

Let's look at a familiar example. Suppose we want to make a cylindrical can to hold a fixed amount of juice. What shape would use the least amount of material? Should the can be tall and narrow, or short and wide?

The volume of the contents is fixed, so the only thing we can change is the balance between the height and the width. If the can is narrow and tall, it needs more material for its side. If it is short and wide, it needs more material for its top and bottom. The surface area changes depending on this balance. In other words, the surface area becomes a function of a single quantity, such as the radius.

Now derivatives come into play. Differentiate the surface area with respect to the radius, and find the radius at which the derivative is zero. This gives us just the right width for the can, where its surface area is smallest. If we keep the volume fixed and minimize the surface area, including the top and bottom lids, the answer is a can whose height is equal to its diameter. An everyday question can be solved beautifully with a single application of derivatives. You can practice this kind of problem-solving in Chapter 17: Optimization Problems.

A Quick Note: The Key Is the Constraint

What makes the can problem interesting is the constraint that the volume must stay the same. Without this constraint, the smaller the can, the less material it would need. There would be no real problem to solve. Only when we have a condition that cannot be changed does it make sense to ask how we should adjust the remaining variables to get the best result. Most real-world optimization problems take this form: finding the best solution under certain constraints.

Light Takes the Path of Least Time

Optimization is not just about what people want. There are situations in which nature itself seems to choose what is best.

In the seventeenth century, the mathematician Fermat explained the bending of light at the surface of water, known as refraction, in the following way: light travels along the path between two points that takes the least amount of time. Light travels at different speeds in air and water. So, rather than taking the shortest straight-line route, it can sometimes take less time overall to travel a little farther by spending more time in the faster medium, air. The idea is similar to how a lifeguard chooses a route to reach a person in trouble as quickly as possible, taking into account the different speeds of running and swimming.

We can solve the question "Where should the light bend to minimize the total travel time?" by treating the travel time as a function of the bending point and setting its derivative to zero. Many laws of nature can be expressed as a search for a maximum or minimum. This is one of the deep beauties of physics, and derivatives are often at the entrance to this way of thinking.

A Zero Slope Is Only a Suspect

However, we must be careful. For a smooth function, the derivative is always zero at a maximum or minimum that lies inside the range we are considering. But the reverse is not true: a zero derivative alone does not prove that we have found one.

For example, there can be a point like a mountain pass where the path becomes flat for just a moment while still going uphill. The slope is zero there, but the point is neither a top nor a bottom. Also, if the range we are considering has endpoints, the maximum or minimum may occur at one of them, where the slope does not have to be zero. Think of a cliff whose highest point is at its edge.

So the correct procedure is as follows. First, list all the points where the derivative is zero as "suspects." Then examine each one to see whether it is a genuine maximum or minimum by looking at how the slope changes nearby and comparing the values at the endpoints. First list the suspects, then narrow them down. This two-step approach is the standard way to solve optimization problems. You can learn how to identify the candidates in Chapter 15: Increasing and Decreasing Functions and Extrema.

A Quick Note: The Second Derivative Reveals the Shape

There is a useful way to tell whether a point with zero slope is at the top of a hill or the bottom of a valley. Differentiate once more. This is called the second derivative. If the second derivative is negative, the slope is decreasing, so the graph is shaped like a hill that is concave down. The point is a local maximum. If it is positive, the graph is shaped like a valley that is concave up, and the point is a local minimum. If the second derivative is also zero, this method cannot tell them apart (for example, $y = x^4$ has a valley bottom at $x = 0$, but its second derivative is zero there). The first derivative helps us find the candidates, and the second derivative helps us identify their nature. By differentiating twice, we can learn about the shape of a function as well.

The Search for the Best Is Everywhere

The idea of finding the best with derivatives is not limited to cans and light. It appears in many fields and takes many forms: finding the price that gives the greatest profit, the speed that gives the best fuel efficiency, or the shape of a garden that can enclose the largest area.

The basic idea is the same in each case. First, express the quantity to be maximized or minimized as a function. Then look for points where its slope is zero. Economics optimizes profit, engineering optimizes efficiency, and machine learning optimizes prediction errors. The words differ from one field to another, but the central idea is the same: finding the point where the tangent is horizontal. This ability to find the best is one of the main reasons derivatives are so useful in so many areas today.

Conclusion — Using a Flat Point as a Clue

We have turned the vague question "Where is the best?" into a question with a clear clue: "Where is the slope zero?" The ground becomes flat at the top of a hill or the bottom of a valley. This simple fact is the key to solving countless optimization problems, from choosing the shape of a can to finding the path taken by light.

Once you have a feel for the idea, try finding the best value yourself. After learning about increasing and decreasing functions and how to find extrema in the chapters on the Introduction page, you can move on to the next level: Elementary. There, you will discover a wider landscape of optimization with several variables, where hills extend in more than one direction.

Frequently Asked Questions

Why is the derivative zero at a maximum or minimum?

At the top of a smooth hill or the bottom of a smooth valley, the tangent at that point is horizontal. Just before the top, the slope is positive, and just after it, the slope is negative. The slope passes through zero at the boundary between the two. Since a derivative represents the slope of the tangent, its value is zero at the top or bottom. This gives us a useful strategy for finding the best value: first, look for points where the derivative is zero.

Is a point where the derivative is zero always a maximum or minimum?

No, not necessarily. A point where the derivative is zero is only a candidate for a maximum or minimum. Such a point can also be a flat point that is neither a top nor a bottom, such as an inflection point that looks like a pass over a hill. A maximum or minimum can also occur at an endpoint of an interval, where the derivative does not have to be zero. Therefore, we need to list the candidates and compare how the slope changes around them and the values at the endpoints to determine the actual maximum or minimum.