6
$\begingroup$

FindMaximum in region is a new function in mma10,but when I tried the following example:

region = Polygon[{{0, 0}, {10, 0}, {10, 5}, {5, 5}, {5, 10}, {0, 10}}]
FindMaximum[{x + y, {x, y} \[Element] region}, {x, y}]

Mathematica 10.1 returns

{10., {x -> 5., y -> 5.}}

We can easily know that it is wrong. What's the story?

$\endgroup$
  • $\begingroup$ NMaximize[{x + y, {x, y} \[Element] region}, {x, y}] however does work? $\endgroup$ – dr.blochwave Apr 28 '15 at 11:34
  • $\begingroup$ You can also use Maximize[{x + y, {x, y} \[Element] region}, {x, y}] for this case as well. $\endgroup$ – dr.blochwave Apr 28 '15 at 11:43
  • $\begingroup$ @blochwave I have tried that,but I wonder why FindMaximum "goes wrong". $\endgroup$ – WateSoyan Apr 28 '15 at 11:50
  • 2
    $\begingroup$ The point {5,5} is a local maxima in the region when approached along the line x==y $\endgroup$ – Bob Hanlon Apr 28 '15 at 21:48
  • 3
    $\begingroup$ @BobHanlon why then, if you specify a starting point of e.g. {{x, 9.9}, {y, 4.9}}, does MMA still head off in the direction of {5,5}? $\endgroup$ – dr.blochwave Apr 29 '15 at 6:50
5
$\begingroup$

Defining just one of the points of the region with a decimal point helps, suggesting that the method chosen by FindMaximum for integer coordinates is a perhaps a linear programming method, and gets stuck at the observed {5, 5}.

Instead one can do:

region = Polygon[{{0., 0}, {10, 0}, {10, 5}, {5, 5}, {5, 10}, {0, 
     10}}];
result = Last@FindMaximum[{x + y, {x, y} \[Element] region}, {x, y}]
(* {x -> 10., y -> 5.} *)

Show[ContourPlot[x + y, {x, y} \[Element] region], 
 Graphics[{Red, PointSize[Large], Point[{x, y} /. result]}]]

enter image description here

$\endgroup$
  • $\begingroup$ It's obvious that we can't know how mma works unless we are members of Wolfram Research.It's a pity that mma returns a unexpectedly result.So how to get a good answer is just a technical task in some extents. $\endgroup$ – WateSoyan May 8 '15 at 7:31

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.