6

I am making a plotting function where I need to know the max value the function takes over the given 2D range. I noticed a difference between the behavior of NMinValue , NMaxValue , NMinimize and NMaximize when the constraint is given as a list of constraints versus as an ImplicitRegion.

If the region is not far from the actual maximum, they return the same value

{NMinValue[{x  Sinc[x]^2 y Sinc[y]^2, -# <= x <= # && -# <= 
       y <= #}, {x, y}],
   NMinValue[{x  Sinc[x]^2 y Sinc[y]^2, {x, y} ∈ 
      ImplicitRegion[-# <= x <= # && -# <= y <= #, {x, y}]}, {x, 
     y}]} & /@ {1, 2}
(* {{-0.501368, -0.501368}, {-0.525062, -0.525062}} *)

But if you go farther out, we get numerical instabilities without the ImplicitRegion,

{NMinValue[{x  Sinc[x]^2 y Sinc[y]^2, -# <= x <= # && -# <= 
       y <= #}, {x, y}],
   NMinValue[{x  Sinc[x]^2 y Sinc[y]^2, {x, y} ∈ 
      ImplicitRegion[-# <= x <= # && -# <= y <= #, {x, y}]}, {x, 
     y}]} & /@ Range[3, 10]
(* {{0.0000440668, -0.525062}, {3.84151*10^-34, -0.525062}, 
{-0.525062, -0.525062}, {-0.155546, -0.525062}, {-0.0446807, -0.525062}, {6.0828*10^-34, -0.525062}, {-0.525062, -0.525062}, 
{-0.0460792, -0.525062}} *)

Why is this? I can see the same behavior with the other functions listed in the post title. Is this a bug? Is there something special about the sinc^2 function? If I change the symmetry, and take away the linear parts of the function, i.e. find the minimum/maximum of Sinc[x]^2 Sinc[y]^2, there are no problems.

Jason B.
  • 68,381
  • 3
  • 139
  • 286
  • 1
    Checking the x and y variables of the NMinimize output shows that, with the list of constraints, the default method may get stuck to a stationary point with $y=\pi$ ($sinc(\pi)=0$). Changing the method parameters, e.g., as NMinimize[{x Sinc[x]^2 y Sinc[y]^2, -# <= x <= # && -# <= y <= #}, {x, y}, Method -> {"NelderMead", "InitialPoints" -> Flatten[Outer[List, Range[-#, #, 1], Range[-#, #, 1]], 1]}] & /@Range[3, 10] does manage to find the global minimum in all cases – Stelios Dec 19 '15 at 16:51

1 Answers1

3

The issue here is because the Automatic method can't find the global min value. A different method can provide a better answer:

f = x Sinc[x]^2 y Sinc[y]^2;
methods = {"NelderMead", "RandomSearch", "DifferentialEvolution"};
range = Range[1, 10];

solutions = Transpose[ Map[ {NMinValue[{f, -#[[2]] <= x <= #[[2]] && -#[[2]] <= y <= #[[2]] }, {x, y}, Method -> #[[1]]], NMinValue[{f, {x, y} [Element] ImplicitRegion[-#[[2]] <= x <= #[[2]] && -#[[2]] <= y <= #[[2]], {x, y}] }, {x, y}, Method -> #[[1]]]} &, #] ] & /@ Outer[List, methods, range];

The solutions of each method are the same with or without the ImplicitRegion definition for the constraints:

In[1]:= AllTrue[solutions, #[[1]] == #[[2]] &]

Out[1]= True

HeNeos
  • 306
  • 3
  • 3