O (1)(2)O O (3)O 22M:28Spring 07J. SimonFinding local maxima and minimafor functions z=f(x,y)[the cookbook]with(plots):I want very much for you to understand all the math that goes in to the process of finding points (x0, y0) where a function z=f(x,y) might have a local max or local min, and the process of using the Hessianmatrix to try to decide if a given (smooth) critical point is indeed a local max or min or a saddle point. HOWEVER, I also know that students sometimes want to have a recipe to follow for complicated problems. So, here's the recipe that will work for most of your homework and exam problems on this topic.1. Calculate the partial derivatives df/dx and df/dy.2. Form a system of 2 equations in 2 unknowns by setting df/dx = 0 and df/dy = 0.3. Solve the system to find all points (x0, y0) at which both partial derivatives are 0.4. Calculate the second derivatives fxx, fxy (=fyx), and fyy.5. Form the Hessian matrix [[fxx, fxy], [fyx, fyy]] Remark: I know fxy = fyx for the functions we are likely to encounter in class; but writing fxy once and fyx the second time is a nice memory aide to help you learn what the Hessian looks like for functions of 3 or more variables. It is the *derivative* matrix of the vector function grad(f).6. Test each critical point according to the following "differential diagnosis" (borrowing that term from medicine, not from math): Hessian determinant = 0 ==> second derivative test for max vs. min vs saddle fails; try perturbing (x0, y0) to see the induced changes in f(x,y). Hessian determinant negative ==> definitely a saddle point Hessian determinant positive ==> definitely a local max or local min; consult fxx (or, equivalently, consult fyy) to see which.Here are some examples:Page 258 Problem 7f:=x*y + 8/x + 1/y;f := x y +8x+1yfx:=diff(f,x);fx := y $8x2fy:=diff(f,y);O O (11)O (9)(8)(7)(4)O (6)(10)O O (12)(5)(3)O O O fy := x $1y2SystemOfEquations:={fx=0, fy=0};SystemOfEquations := y $8x2= 0, x $1y2= 0The system is not linear, so I recommend always using substitution to try to solve. Here the first equation says y=8/x^2. Plug this into the second equation to make that x = 1/ (8/x^2)^2, i.e. x = x^4/64. Since x cannot be 0 (from the first equation), divide both sides by x to get1 = x^3/64, which says x = 4. Go back to the y=8/x^2 equation to see that if x=4 then y=8/16 = 1/2. So(4, 1/2) is the only critical point.Before going on, let's ask the computer to check our solution:solve(SystemOfEquations, {x,y});y =12, x = 4 , y =12 RootOf _Z2+_Z+1, label = _L1 ,x = 4 RootOf _Z2+_Z+1, label = _L1The only solution in real numbers is the one we found. The computer, being a bit of a showoff, also found complex number solutions.Next, to decide what kind of critical point this is, calculate the second derivatives.fxx:=diff(fx,x);fxx :=16x3fyy:=diff(fy,y);fyy :=2y3fxy:=diff(fx,y);fxy := 1fyx:=diff(fy,x);fyx := 1HessianMatrix:=matrix([[fxx,fxy], [fyx, fyy]]);HessianMatrix :=16x3112y3HessianDeterminant:=fxx*fyy - fxy*fyx;HessianDeterminant :=32x3 y3$ 1Check the sign of the Hessian determinant at the critical point...subs(x=4, y=1/2, HessianDeterminant);3O O (3)We see the determinant is positive ==> definitely a local max or local min. The second derivative fxx is positive, so the surface is concave up at the critical point.We conclude that there is just one critical point, (4, 1/2), and at that point, the function f has a local minimum.Let's graph the surface to see if the picture is consistent with our calculation (which it must be, but it isreassuring to see that 1+1=2 again).plot3d(f, x=4-1..4+1, y=(1/2)-1..(1/2)+1, axes=boxed);0y134x5Why does this graph look so strange; and notice the range of outputs = 10^16 ????In specifying the range of x and y values to consider, I allowed y to be 0. But the original function involves 1/x and 1/y; so the graph "blows up" in this range of y's. Let's try again, keeping the x's and y's symmetric around the critical point, but narrowing the focus:plot3d(f, x=4-2..4+2, y=(1/2)-.25..(1/2)+.25, axes=boxed, orientation = [62, 108]);O O (16)(13)(14)O (15)O (3)0.30.40.5y0.60.7238.58.04x7.57.056.566.0###############ANOTHER EXAMPLE###############Page 258Problem 21f:=(2*y^3 - 3*y^2-36*y+2)/(1+3*x^2);f :=2 y3$ 3 y2$ 36 y +21 +3 x2fx:=diff(f,x);fx := $6 2 y3$ 3 y2$ 36 y +2 x1 +3 x22fy:=diff(f,y);fy :=6 y2$ 6 y $ 361 +3 x2SystemOfEquations:={fx=0, fy=0};(18)(16)O O (20)O (17)O (3)(19)SystemOfEquations := $6 2 y3$ 3 y2$ 36 y +2 x1 +3 x22= 0,6 y2$ 6 y $ 361 +3 x2= 0First notice that the denominator factor (1+3x^2) is never 0. So we can multiply through both equationsby (1+3x^2). And the minus sign on the left side of the first equation does not matter, since the right side is 0. Also divide out the coefficient 6 from both equations.NewSystem:= {(2*y^3-3*y^2-36*y+2)*x/(1+3*x^2)^2=0, y^2-y-6=0};NewSystem :=2 y3$ 3 y2$ 36 y +2 x1 +3 x22= 0, y2$ y $ 6 = 0The (now) first equation says (by factoring)(which I did learn in junior high school) (but it included 9thgrade) (y-3)(y+2)=0, i.e. y=3 or y=-2.Now we have to be careful and find the *corresponding* x values.Substitute y=3 into the second equation to get an equation in x alone. Substitute y=2 into the second equation to get another equation in x alone. Solve for the value(s) of x corresponding to each value of y.For y=3...SolveForX1:=subs(y=3, NewSystem[2]);SolveForX1 := 0 = 0The denominator is never 0, so we can multiply both sides by (1+3x^2)^2 and get an equivalent equation:-79 x = 0 ==> x=0.SO the point (0, 3) is a critical point for this function f.For y=-2SolveForX1:=subs(y=-2, NewSystem[2]);SolveForX1 := 0 = 0This ends up just like the first case: x=0 is the only solution.So (0, -2) is the other critical point for function f.NEXT we use the second derivatives to try to decide what kinds of critical points these are.fxx:=diff(fx,x);fxx:=simplify(fxx);fxx :=72 2 y3$ 3 y2$ 36 y +2 x21 +3 x23$6 2 y3$ 3 y2$ 36 y +21 +3 x22fxx :=6 2 y3$ 3 y2$ 36 y +2 9 x2$ 11 +3 x23O O (27)(23)O (29)(16)O O (28)O O (26)(21)O O (25)(24)(3)(22)fyy:=diff(fy,y);fyy :=12 y $ 61 +3 x2fxy:=diff(fx,y);fxy := $6 6 y2$ 6 y $ 36 x1 +3 x22fyx:=diff(fy,x);fyx := $6 6 y2$ 6 y $ 36 x1 +3 x22HessianMatrix:=matrix([[fxx,fxy], [fyx, fyy]]);HessianMatrix :=6 2 y3$ 3 y2$ 36 y +2 9 x2$ 11 +3 x23$6 6 y2$ 6 y $ 36 x1 +3 x22$6 6 y2$ 6 y $ 36 x1 +3 x2212 y $ 61 +3 x2HessianDeterminant:=fxx*fyy -
View Full Document