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.
xandyvariables of theNMinimizeoutput 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., asNMinimize[{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