Sunteți pe pagina 1din 5

Max/min of a function

A lot of real world problems involve nding a minimum or a maximum of a given function. For example minimizing distance in navigation: what is the shortest path from A to B? Or maximizing prot in economics: how should one invest money for biggest return? Or height in geography: what is the tallest peak in a mountain region? Sometimes we want the max/min wherever it is. Sometimes there are constraints: for instance, one cannot invest negative money, or more than one has. The rst step towards solving these questions is to nd local max/min: in other words, to nd all mountain peaks. Once that is done, we can compare their heights to nd the tallest one.

Local min/max

A function f has a local minimum at x = a if f (x) f (a) near a. The picture to have in mind is the bottom of a parabola, namely x = 0 for f = x2 . Similarly, f has a local maximum at x = a if f (x) f (a) near a. How can we nd these points? The function is turning around: they are the top of a mountain or the bottom of a pit. If x = a is a local min or max of f , then f (a) = 0. Unfortunately, the converse does not hold. The derivatives can be zero at other points: consider f (x) = x3 . Its derivative f (x) = 3x2 is zero at x = 0, but this point is not a local min or max; the function levels of and then starts increasing again. You can see that by drawing its picture, or simply because the derivative is positive for every x = 0. Even so, we want to start our local min/max search by nding the points where the derivative is zero. We call them critical points, because they are candidates for min/max. The next step is to classify each one, meaning decide whether its a local max, min, or neither. It is possible, and sometimes necessary, to do this classication by hand: draw the function, and check its behavior near the point. In many cases, it can be done algebraically, but looking at the second derivative of f at the critical point.

Second derivative test

The second derivative f (x) is the derivative of the derivative. Algebraically, you dierentiate twice. Geometrically, its the slope of the slope, which means that its sign tells you whether the slope is increasing or decreasing. What does that have to do with anything? Lets take a look. First lets take f (x) = x2 . We have f (x) = 2x which is zero at x = 0. Of course, we know that x = 0 is a minimum of this function. But the second derivative can tell us even without a picture: f (x) = 2, which means that the slope of f is increasing everywhere. In particular, its increasing right around x = 0, which means that the slope was negative just before this points, and its positive right after. What do we have then? A min. If you analyze f (x) = x2 , you will reach the conclusion that if f (x) < 0 at our critical point, then its a max. What if f (x) = 0? Then we know nothing. This is a very sad fact of life, but there it is. In this case, you have to get your hands dirty and actually draw the function, or use a computer program. If you dont believe me, think about f1 (x) = x4 , f2 (x) = x4 , and f3 (x) = x3 . You will nd that all three have a critical point at x = 0, and all three have f (x) = 0. Now, at x = 0, the rst function has a min, f2 has a max, and f3 has neither. To summarize, if f (a) = 0, then the second derivative test says: If f (a) > 0, then x = a is a local minimum. If f (a) < 0, then x = a is a local maximum. If f (a) = 0, then the test fails.

Global max/min

If f (x) = x2 , then x = 0 is really a minimum of the entire function, and it can proudly bear the name global minimum. This is not always the case with local min/max. Example 1: In Geometry of derivatives, we discussed the function f (x) = x3 3x. Its re-drawn here in Figure 1 You can see that x = 1 is a local minimum of the function, but it is not a global one: the function goes lower than that in the negative x-direction. It goes down forever, as a matter of fact: it has no global minimum at all. It has no global maximum, either: it goes up forever in the positive x-direction. To decide whether global max/min exist, we must check the behavior of the function at the ends, for very large and very small x. If the function does not go to innity anywhere, then a real global max exists. To nd it, we nd all the critical points, and compare their values. The good news is, we do not have to classify these: the one with biggest value is a maximum, and the one with smallest value is a minimum.

Figure 1: Graph of x3 3x. Example 2: Lets take f (x) = x4 + x2 , which is shown on Figure 2. For very large x, this function goes to innity. Same for very small x. Global max does not exist, but global min does. Lets nd critical points. f (x) = 4x3 + 2x = 2x(2x2 + 1). This is zero at x = 0 only, since the other factor, 2x2 + 1, is always positive. Therefore x = 0 is the only critical point, and it must be the global minimum, since we know that one exists. For general functions, this can be tricky. For example, ex is everywhere positive, but it has no global minimum. It decreases towards 0 as x increases: it gets closer and closer to it, but it never does reach the value 0.

Figure 2: Graph of x4 + x2 .

Global max/min with constraints

In this variant of the global max/min problem, we ask for global min/max on some interval, rather than considering the entire domain of the function. Example: Take the above function f (x) = x4 + x2 , on the interval from x = 1 to x = 2. This is actually easier than than considering all x: we do not have to worry about what the function does far away from the origin. For reasonable functions, global min and max will both exist. How do we nd them? First we look for critical points inside the interval (the inside part is quite important: a maximum somewhere outside of the interval were interested in does not help us any). We already found one, at x = 0, and we know its global min. What about global max? Its not at a local max, since there are none. It is at one of the endpoints, as shown on Figure 2. This is undetectable with the derivative, since the function does not have derivative zero at this point: it keeps increasing straight through, the point is a max because were cutting o the function there. To nd global max/min on an interval, we nd all the critical points and list them, add the endpoints to the list, and compare all their values. For the function f = x4 + x2 on 1 x 2, the candidates are x = 0, 1, 2. Values: f (0) = 0, f (1) = 2, f (2) = 20. Global minimum is at x = 0, and global maximum is at x = 2.

Badly behaved functions

There can be additional trouble with global min/max, whether on an interval or on the entire axis: this trouble happens where the function or its derivative are not dened. Example 1: Consider f (x) = 1/x, which is not dened at x = 0. The function goes to 0 for very large and very small x, but it has no global min or max: look at its behavior near 0 on Figure 3.

Figure 3: Graph of 1/x.

Example 2: Consider f (x) = |x|, the absolute value of x, as pictured in Figure 4. This function is dened everywhere, and its min is clearly at x = 0, but f is not dened at x = 0: it looks like +1 from the right, and 1 from the left, there is no value that satises both.

Figure 4: Graph of |x|. If either of these issues come up, the villain points must be included on the list of candidates. If the function is dened there, as in the cas of f = |x|, we can simply compare their values with all the other candidates. If the function is not dened there, such as with f = 1/x, we must examine the behavior of the function near this point, from both directions. This is usually even harder than checking the behavior of f far away from the origin, but it must be done.

S-ar putea să vă placă și