
Local extreme values of a function of two variables
Just as we can search for local extreme values of a function of one variable by means of the command FindMinimum, we can also use this command to search for local extreme values of functions of more than one variable.
If f(x,y,...) is a function of the variables x, y, ..., then we can utilize the command FindMinimum to seek out a local minimum value of f from a seed value of x = x0, y = y0, ... as follows:
FindMinimum[f(x,y,...),{x,x0},{y,y0},...]
From this seed value, Mathematica will find the path of steepest downward slope and follow it until it reaches a local minimum value, or until its computations go beyond a specific point. If one modifies the command so that it is in the form
FindMinimum[f(x,y,...),{x,x0,xmin,xmax},{y,y0,ymin,ymax},...]
then the search for a local minimum value will stop if the value of x passes outside of the interval [xmin, xmax], or the value of y passes outside of the interval [ymin, ymax], etc.
-
Example 1: The function
f(x,y) = e-(2 x2 - 5 x + 7 y2 + 3 y)
has a unique local maximum value in its domain. Find the location of the point where this maximum occurs using Mathematica.
The local maximum values of f(x,y) occur at the same points as the local minimum values of g(x,y) = -f(x,y). Thus we can search for the location of a local maximum value of f(x,y) by applying the function FindMinimum to g(x,y). Using the point (0, 0) as a seed value, we search for the local maximum of f(x,y) as follows:
In[1]:= f[x_,y_]=Exp[-(2*x^2-5*x+7*y^2+3*y)];
FindMinimum[-f[x,y],{x,0},{y,0}]
Out[1]= {-31.3881, {x -> 1.25, y -> -0.214286}}
Thus we see that g(x,y) = -f(x,y) has a local minimum value of -31.3881 at x = 1.25 and y = -0.214286, which implies that f(x,y) has a local maximum value of 31.3881 at this point.
The graph of f(x,y).
-
Example 2: An island is to be stocked with deer and antelope. Due to limited space on the island, the weights of the animals at the end of the year are dependent upon the population densities of the animals. Let us use x to denote the number of deer and y to denote the number of antelope. It is found that the function
W1 = 180 - .135 x - .090 y
represents the average weight of a deer at the end of the year, and the function
W2 = 120 - .080 x - .160 y
represents the average weight of an antelope at the end of the year.
Assuming that the population of the animals remains constant during the course of the year, how should the island be stocked in order to maximize the total weight of the animals?
In order to solve this problem we must first find a function of our variables x and y that represents the maximum total weight of the animals. The total weight of the deer is given by the product of the number of deer and the average weight of each deer. Thus the total weight of the deer is x (180 - .135 x - .090 y). Similarly, the total weight of the antelope is the product of the number of antelope and the average weight of each antelope. Thus the total weight of the antelope is y (120 - .080 x - .160 y). The total weight of all of the animals is then given by the function
f(x,y) = x (180 - .135 x - .090 y) + y (120 - .080 x - .160 y)
= 180 x + 120 y - .135 x2 - .160 y2 - .17 x y .
Since the average weight of each deer must be positive, we can find the maximum number of deer that can exist on the island by letting y = 0 and solving W1 > 0 for x. We obtain
180 - .135 x > 0.
Thus we have 0
x
1333. The maximum number of antelope that can exist on the island is found by letting x = 0 and solving W2 > 0 for y. Then
120 - .160 y > 0.
Thus 0
y
750. Therefore we consider the function f(x,y) for x in the interval [0,1333] and for y in the interval [0,750]. By graphing this function on this domain
The graph of f(x,y) for values of x and y such that f(x,y)
0.
it appears that f(x,y) has a unique local maximum, and that this local maximum is the overall maximum value of the function on this domain.
Now we must find values for x and y so as to maximize f(x,y). We shall do this by finding the the location and the value of the unique local maximum. To find the local maximum value of f(x,y) by means of the function FindMinimum, we must search for the local minimum value of -f(x,y). We do this as follows:
In[2]:= f[x_,y_]=180*x+120*y-.135*x^2-.160*y^2-.17*x*y;
FindMinimum[-f[x,y],{x,0,0,1333},{y,0,0,750}]
Out[2]= {-60104.3, {x -> 646.957, y -> 31.3043}}
Thus we see that -f(x,y) has a local minimum value of -60104.3 when x = 646.957 and y = 31.3043. Therefore f(x,y) has a local maximum value of 60104.3 at these same values of x and y. Since this local maximum value of f(x,y) is also the global maximum value of f(x,y), we see that f(x,y) has a global maximum value of of 60104.3 when x = 646.957 and y = 31.3043. Since our problem actually requires that each of x and y be integers, we can experiment with some integer values of x and y near these respective values to find that our global maximum is 60104.335 when x = 647 and y = 31.
-
Example 3: The function
f(x,y) = x2 + 2 y2 - ln(x y)
has a unique local minimum on the region defined by x > 0 and y > 0. Let us utilize Mathematica to find the values of x and y where the local minimum occurs, and the value of the local minimum.
We shall use the point (2, 2) for a seed value, and now that we have specified a seed value, we can search for the local minimum as follows:
In[3]:= f[x_,y_]=x^2-3*Log[x*y]+2*y^2;
FindMinimum[f[x,y],{x,2},{y,2}]
Out[3]= {2.82333, {x -> 1.22474, y -> 0.866025}}
Thus we see that we have a local minimum value of 2.82333 when x = 1.22474 and y = 0.866025.
Exercises
Last modified: Thu Sep 27 2001