Message Boards Message Boards

0
|
2812 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

The value returned by NMaximize increases as the domain decreases?

Posted 2 years ago

Definition of the function g:

f2[x_] := (x*(FresnelC[x] + FresnelS[x]) + (Cos[Pi*x^2/2] - 
       Sin[Pi*x^2/2])/Pi)/2

g[x1_, x2_, y1_, y2_] := 
 2*(f2[x2 - y1] - f2[x1 - y1] - f2[x2 - y2] + f2[x1 - y2])/(x2 - x1 + 
     y2 - y1)

First maximization with a suitable domain:

NMaximize[{g[x1, x2, y1, y2],  0 < x1 < x2 < 7 && -7 < y1 < y2 < 0}, {x1, x2, y1, y2}]


Out[33]= {0.00937548, {x1 -> 1.60404, x2 -> 5.27857, y1 -> -2.89746, 
  y2 -> -0.0330524}}

Second maximization with a smaller domain: why the maximum is larger???

In[34]:= NMaximize[{g[x1, x2, y1, y2],  0 < x1 < x2 < 5 && -5 < y1 < y2 < 0}, {x1, x2, y1, y2}]


Out[34]= {0.0260921, {x1 -> 1.63214, x2 -> 3.49276, y1 -> -1.26015, 
  y2 -> -0.0177181}}
POSTED BY: Bruno Galvan
2 Replies
Posted 2 years ago

Thank you! I am new to Mathematica, but I see that the situation is more complicated than I thought.

POSTED BY: Bruno Galvan

NMaximize likely got trapped in a local max. Might try different Method option settings to see if it can be made to do better. Here is one such attempt. Note that it pushes some variables to the boundary of the allowed region.

In[9]:= NMaximize[{g[x1, x2, y1, y2], 
  0 < x1 < x2 < 7 && -7 < y1 < y2 < 0}, {x1, x2, y1, y2}, 
 Method -> "DifferentialEvolution"]

Out[9]= {0.401025, {x1 -> 0., x2 -> 0.707106, y1 -> -0.707108, 
  y2 -> 0.}}
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract