Re: Local extrema of a function of two variables
- To: mathgroup at smc.vnet.net
- Subject: [mg90017] Re: Local extrema of a function of two variables
- From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
- Date: Thu, 26 Jun 2008 04:44:49 -0400 (EDT)
On Wed, Jun 25, 2008 at 4:56 PM, Barun von Doppeldecker <nikoi8888 at gmail.com> wrote: > if you still want to help. here is another problem i came across today: i > have a function f(x, y) = 4xy â?? x^4 â?? y^4 and i have to do three things. > First i have to find candidates for local extremes, then i have to exactly > pinpoint that extremes and finally plot a graf surrounding that point of > extremum. > I have found candidates, but the other two things i just can't....Here is > what i've done: > > f[x_,y_]:=4 x y-x^4-y^4 > > Solve[{D[f[x,y],x]Å 0,D[f[x,y],y]Å 0},{x,y}] > > if you could help me with other 2 things, i would be really grateful... if > not, thank you anyway.... ;) <snip> [... Reply cross-posted to MathGroup ...] You could follow the following "template". (* Say that the function we want to study is the following: *) f[x_, y_] := 4 x y - x^4 - y^4 (* We compute the first derivatives of f w.r.t.to x and y: *) gradient = D[f[x, y], {{x, y}, 1}] {-4 x^3 + 4 y, 4 x - 4 y^3} (* We equate each derivative to zero and solve for x and y: *) sols = Solve[gradient == 0] {{x -> -1, y -> -1}, {x -> 0, y -> 0}, {x -> -I, y -> I}, {x -> I, y -> -I}, {x -> 1, y -> 1}, {x -> -(-1)^(1/4), y -> -(-1)^(3/4)}, {x -> (-1)^(1/4), y -> (-1)^(3/4)}, {x -> -(-1)^(3/4), y -> -(-1)^(1/4)}, {x -> (-1)^(3/4), y -> (-1)^(1/4)}} (* We want only the real points,so we discard the complex \ solutions: *) pts = Cases[sols, {x -> vx_, y -> vy_} /; Im[vx] == 0 && Im[vy] == 0] {{x -> -1, y -> -1}, {x -> 0, y -> 0}, {x -> 1, y -> 1}} (* So we have the critical points. Now,we compute the Hessian matrix, *) hessian = D[f[x, y], {{x, y}, 2}] {{-12 x^2, 4}, {4, -12 y^2}} (* and take its determinant: *) d = hessian // Det -16 + 144 x^2 y^2 (* Then we compute the values of the Hessian determinant at \ the critical points: *) d /. pts {128, -16, 128} D[f[x, y], {x, 2}] /. pts {-12, 0, -12} (* We apply the second derivative test. Since the Hessian is negative at the point (0,0),we \ conclude that this is a saddle point. Since the Hessian is positive at \ the points (-1, -1) ant (1,1),and the second derivatives w.r.t. x at these points are negative, we conclude that those points are local maxima. *) (* We can "check" (or anticipate) these results by \ plotting the function: *) Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, PlotRange -> All] ContourPlot[f[x, y], {x, -2, 2}, {y, -2, 2}, ColorFunction -> "SunsetColors"] [keywords: function two variables local minimum maximum critical point Hessian calculus] Regards, -- Jean-Marc
- Follow-Ups:
- Re: Re: Local extrema of a function of two variables
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: Local extrema of a function of two variables