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$
10
  • $\begingroup$ NMaximize[{x + y, {x, y} \[Element] region}, {x, y}] however does work? $\endgroup$ Apr 28, 2015 at 11:34
  • $\begingroup$ You can also use Maximize[{x + y, {x, y} \[Element] region}, {x, y}] for this case as well. $\endgroup$ Apr 28, 2015 at 11:43
  • $\begingroup$ @blochwave I have tried that,but I wonder why FindMaximum "goes wrong". $\endgroup$
    – WateSoyan
    Apr 28, 2015 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, 2015 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$ Apr 29, 2015 at 6:50

1 Answer 1

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$
1
  • $\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, 2015 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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