Many important applied problems involve finding the best way to accomplish some task. Often this involves finding the maximum or minimum value of some function: the minimum time to make a certain journey, the minimum cost for doing a task, the maximum power that can be generated by a device, and so on. Many of these problems can be solved by finding the appropriate function and then using techniques of calculus to find the maximum or the minimum value required.

Generally such a problem will have the following mathematical form: Find the largest (or smallest) value of $f(x)$ when $a\le x\le b$. Sometimes $a$ or $b$ are infinite, but frequently the real world imposes some constraint on the values that $x$ may have.

Such a problem differs in two ways from the local maximum and minimum problems we encountered when graphing functions: We are interested only in the function between $a$ and $b$, and we want to know the largest or smallest value that $f(x)$ takes on, not merely values that are the largest or smallest in a small interval. That is, we seek not a local maximum or minimum but a global maximum or minimum, sometimes also called an absolute maximum or minimum.

Any global maximum or minimum must of course be a local maximum or minimum. If we find all possible local extrema, then the global maximum, if it exists, must be the largest of the local maxima and the global minimum, if it exists, must be the smallest of the local minima. We already know where local extrema can occur: only at those points at which $f'(x)$ is zero or undefined. Actually, there are two additional points at which a maximum or minimum can occur if the endpoints $a$ and $b$ are not infinite, namely, at $a$ and $b$. We have not previously considered such points because we have not been interested in limiting a function to a small interval. An example should make this clear.

Figure 6.1.1. The function $\ds f(x)=x^2$ restricted to $[-2,1]$

Example 6.1.1 Find the maximum and minimum values of $\ds f(x)=x^2$ on the interval $[-2,1]$, shown in figure 6.1.1. We compute $\ds f'(x)=2x$, which is zero at $x=0$ and is always defined.

Since $f'(1)=2$ we would not normally flag $x=1$ as a point of interest, but it is clear from the graph that when $f(x)$ is restricted to $[-2,1]$ there is a local maximum at $x=1$. Likewise we would not normally pay attention to $x=-2$, but since we have truncated $f$ at $-2$ we have introduced a new local maximum there as well. In a technical sense nothing new is going on here: When we truncate $f$ we actually create a new function, let's call it $g$, that is defined only on the interval $[-2,1]$. If we try to compute the derivative of this new function we actually find that it does not have a derivative at $-2$ or $1$. Why? Because to compute the derivative at 1 we must compute the limit $$\lim_{\Delta x\to 0} {g(1+\Delta x)-g(1)\over \Delta x}.$$ This limit does not exist because when $\Delta x>0$, $g(1+\Delta x)$ is not defined. It is simpler, however, simply to remember that we must always check the endpoints.

So the function $g$, that is, $f$ restricted to $[-2,1]$, has one critical value and two finite endpoints, any of which might be the global maximum or minimum. We could first determine which of these are local maximum or minimum points (or neither); then the largest local maximum must be the global maximum and the smallest local minimum must be the global minimum. It is usually easier, however, to compute the value of $f$ at every point at which the global maximum or minimum might occur; the largest of these is the global maximum, the smallest is the global minimum.

So we compute $f(-2)=4$, $f(0)=0$, $f(1)=1$. The global maximum is 4 at $x=-2$ and the global minimum is 0 at $x=0$.

It is possible that there is no global maximum or minimum. It is difficult, and not particularly useful, to express a complete procedure for determining whether this is the case. Generally, the best approach is to gain enough understanding of the shape of the graph to decide. Fortunately, only a rough idea of the shape is usually needed.

There are some particularly nice cases that are easy. A continuous function on a closed interval $[a,b]$ always has both a global maximum and a global minimum, so examining the critical values and the endpoints is enough:

Theorem 6.1.2 (Extreme value theorem) If $f$ is continuous on a closed interval $[a,b]$, then it has both a minimum and a maximum point. That is, there are real numbers $c$ and $d$ in $[a,b]$ so that for every $x$ in $[a,b]$, $f(x)\le f(c)$ and $f(x)\ge f(d)$.

Another easy case: If a function is continuous and has a single critical value, then if there is a local maximum at the critical value it is a global maximum, and if it is a local minimum it is a global minimum. There may also be a global minimum in the first case, or a global maximum in the second case, but that will generally require more effort to determine.

Example 6.1.3 Let $\ds f(x)=-x^2+4x-3$. Find the maximum value of $f(x)$ on the interval $[0,4]$. First note that $f'(x)= -2 x +4=0$ when $x=2$, and $f(2)= 1$. Next observe that $f'(x)$ is defined for all $x$, so there are no other critical values. Finally, $f(0) = -3$ and $f(4)= -3$. The largest value of $f(x)$ on the interval $[0,4]$ is $f(2)=1$.

Example 6.1.4 Let $\ds f(x)=-x^2+4x-3$. Find the maximum value of $f(x)$ on the interval $[-1,1]$.

First note that $f'(x)= -2 x +4=0$ when $x=2$. But $x=2$ is not in the interval, so we don't use it. Thus the only two points to be checked are the endpoints; $f(-1) = -8$ and $f(1)= 0$. So the largest value of $f(x)$ on $[-1,1]$ is $f(1)=0$.

Example 6.1.5 Find the maximum and minimum values of the function $f(x)= 7+|x-2|$ for $x$ between $1$ and $4$ inclusive. The derivative $f'(x)$ is never zero, but $f'(x)$ is undefined at $x=2$, so we compute $f(2)= 7$. Checking the end points we get $f(1)=8$ and $f(4)=9$. The smallest of these numbers is $f(2)=7$, which is, therefore, the minimum value of $f(x)$ on the interval $1 \le x \le 4$, and the maximum is $f(4)=9$.

Figure 6.1.2. $f(x)=x^3-x$

Example 6.1.6 Find all local maxima and minima for $\ds f(x)=x^3-x$, and determine whether there is a global maximum or minimum on the open interval $(-2,2)$. In example 5.1.2 we found a local maximum at $\ds (-\sqrt3/3,2\sqrt{3}/9)$ and a local minimum at $\ds (\sqrt3/3,-2\sqrt{3}/9)$. Since the endpoints are not in the interval $(-2,2)$ they cannot be considered. Is the lone local maximum a global maximum? Here we must look more closely at the graph. We know that on the closed interval $\ds [-\sqrt3/3,\sqrt3/3]$ there is a global maximum at $\ds x=-\sqrt3/3$ and a global minimum at $\ds x=\sqrt3/3$. So the question becomes: what happens between $-2$ and $\ds -\sqrt3/3$, and between $\ds \sqrt3/3$ and $2$? Since there is a local minimum at $\ds x=\sqrt3/3$, the graph must continue up to the right, since there are no more critical values. This means no value of $f$ will be less than $\ds -2\sqrt{3}/9$ between $\ds \sqrt3/3$ and $2$, but it says nothing about whether we might find a value larger than the local maximum $\ds 2\sqrt{3}/9$. How can we tell? Since the function increases to the right of $\ds \sqrt3/3$, we need to know what the function values do "close to'' $2$. Here the easiest test is to pick a number and do a computation to get some idea of what's going on. Since $\ds f(1.9)=4.959>2\sqrt{3}/9$, there is no global maximum at $\ds -\sqrt3/3$, and hence no global maximum at all. (How can we tell that $\ds 4.959>2\sqrt{3}/9$? We can use a calculator to approximate the right hand side; if it is not even close to $4.959$ we can take this as decisive. Since $\ds 2\sqrt{3}/9\approx 0.3849$, there's really no question. Funny things can happen in the rounding done by computers and calculators, however, so we might be a little more careful, especially if the values come out quite close. In this case we can convert the relation $\ds 4.959>2\sqrt{3}/9$ into $\ds (9/2) 4.959>\sqrt{3}$ and ask whether this is true. Since the left side is clearly larger than $4\cdot 4$ which is clearly larger than $\ds \sqrt3$, this settles the question.)

A similar analysis shows that there is also no global minimum. The graph of $f(x)$ on $(-2,2)$ is shown in figure 6.1.2.

Example 6.1.7 Of all rectangles of area 100, which has the smallest perimeter?

First we must translate this into a purely mathematical problem in which we want to find the minimum value of a function. If $x$ denotes one of the sides of the rectangle, then the adjacent side must be $100/x$ (in order that the area be 100). So the function we want to minimize is $$f(x)=2x+2{100\over x}$$ since the perimeter is twice the length plus twice the width of the rectangle. Not all values of $x$ make sense in this problem: lengths of sides of rectangles must be positive, so $x>0$. If $x>0$ then so is $100/x$, so we need no second condition on $x$.

We next find $f'(x)$ and set it equal to zero: $\ds 0=f'(x)=2-200/x^2$. Solving $f'(x)=0$ for $x$ gives us $x=\pm 10$. We are interested only in $x>0$, so only the value $x=10$ is of interest. Since $f'(x)$ is defined everywhere on the interval $(0,\infty)$, there are no more critical values, and there are no endpoints. Is there a local maximum, minimum, or neither at $x=10$? The second derivative is $\ds f''(x)=400/x^3$, and $f''(10)>0$, so there is a local minimum. Since there is only one critical value, this is also the global minimum, so the rectangle with smallest perimeter is the $10\times10$ square.

Example 6.1.8 You want to sell a certain number $n$ of items in order to maximize your profit. Market research tells you that if you set the price at \$1.50, you will be able to sell 5000 items, and for every 10 cents you lower the price below \$1.50 you will be able to sell another 1000 items. Suppose that your fixed costs ("start-up costs'') total \$2000, and the per item cost of production ("marginal cost'') is \$0.50. Find the price to set per item and the number of items sold in order to maximize profit, and also determine the maximum profit you can get.