2
$\begingroup$

i need to find local extrema points of a function of two variables, but it doesnt work

FindMaximum[x^3 - 2 y^3 - 3 x + 6 y, {x, y}]

I have this error:

FindMaximum::fmgz: Encountered a gradient that is effectively zero. The result returned may not be a maximum; it may be a minimum or a saddle point.
$\endgroup$
4
  • 1
    $\begingroup$ saddle point. Plot3D[x^3 - 2 y^3 - 3 x + 6 y, {x, 0, 2}, {y, 0, 2}] It is always a good idea to plot the given functions to ge an overview. $\endgroup$
    – Akku14
    May 21 at 20:13
  • $\begingroup$ @Akku14 yes, i know it, but i need specific answer (number) of max local extreme point $\endgroup$
    – Casper
    May 21 at 20:18
  • $\begingroup$ Solve[Thread[D[x^3 - 2 y^3 - 3 x + 6 y, {{x, y}}] == 0], {x, y}] yields {{x -> -1, y -> -1}, {x -> 1, y -> -1}, {x -> -1, y -> 1}, {x -> 1, y -> 1}} Plot3D[x^3 - 2 y^3 - 3 x + 6 y, {x, -2, 2}, {y, -2, 2}] $\endgroup$
    – Akku14
    May 21 at 20:23
  • $\begingroup$ Just to compare: see SecondDerivativeTest of Maple. There is room for improvement in this topic in Mathematica. $\endgroup$
    – user64494
    May 22 at 5:55

1 Answer 1

3
$\begingroup$
  • If $D f(x,y)=0$ and $\mathrm{Hessian}f(x,y)$ is a positive definite matrix,then $f(x,y)$ get the local minimal.
  • If $D f(x,y)=0$ and $\mathrm{Hessian}f(x,y)$ is a negative definite matrix,then $f(x,y)$ get the local minimal.

We use Grad[f[x,y],{x,y}] or D[f[x,y],{{x,y},1}] and D[f[x,y],{{x,y},2} to calculate the Gradient and Hessian.

And we know that a matrix A={{a,b},{c,d}} is positive definite if a>0 and Det[A]>0, and a matrix A={{a,b},{c,d}} is negative definitee if a<0 and Det[A]>0.

Clear[f, localmin, localmax];
f[x_, y_] = x^3 - 2 y^3 - 3 x + 6 y;
localmin = 
  Solve[{D[f[x, y], {{x, y}, 1}] == 0, 
    Det[D[f[x, y], {{x, y}, 2}][[;; 1, ;; 1]]] > 0, 
    Det[D[f[x, y], {{x, y}, 2}][[;; 2, ;; 2]]] > 0}, {x, y}];
localmax = 
  Solve[{D[f[x, y], {{x, y}, 1}] == 0, 
    Det[D[f[x, y], {{x, y}, 2}][[;; 1, ;; 1]]] < 0, 
    Det[D[f[x, y], {{x, y}, 2}][[;; 2, ;; 2]]] > 0}, {x, y}];

Show[Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}], 
 Graphics3D[{AbsolutePointSize[20], {Blue, 
    Point[{x, y, f[x, y]}] /. localmin}, {Red, 
    Point[{x, y, f[x, y]}] /. localmax}, Arrowheads[.02], 
   Arrow[{# + {0, 0, 10}, #} &@{x, y, f[x, y]} /. localmin], 
   Text["local min", {x, y, f[x, y]} + {0, 0, 10} /. localmin, 
    Background -> Yellow],
   Arrow[{# + {0, 0, 10}, #} &@{x, y, f[x, y]} /. localmax], 
   Text["local max", {x, y, f[x, y]} + {0, 0, 10} /. localmax, 
    Background -> Yellow]}], PlotRange -> All]

enter image description here

  • The same as
FindMaximum[{x^3 - 2 y^3 - 3 x + 6 y, -5 <= x <= 5, -5 <= y <= 5}, {x,
   y}]
FindMinimum[{x^3 - 2 y^3 - 3 x + 6 y, -5 <= x <= 5, -5 <= y <= 5}, {x,
   y}]

{6., {x -> -1., y -> 1.}}

{-6., {x -> 1., y -> -1.}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.