# NMinValue , NMaxValue , NMinimize and NMaximize behave poorly for 2-dimensional function unless the constraint is posed as an ImplicitRegion

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.

• 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 Commented Dec 19, 2015 at 16:51

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;
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