If on one hand:
N@Maximize[{Sqrt[y^2 - x^2], x + y^2 == 0 && 0 < y < 2 && -y < x < y}, {x, y}]
{0.5, {x -> -0.5, y -> 0.707107}}
which is what is desired, on the other hand:
NMaximize[{Sqrt[y^2 - x^2], x + y^2 == 0 && 0 < y < 2 && -y < x < y}, {x, y}]
produces a warning:
NMaximize::nrnum: The function value 4.15623 -1.34058 I is not a real number at {x,y} = {-1.35352,0.186697}.
and a consequent incorrect result:
{0.285088, {x -> -0.681805, y -> 0.739008}}
I can't understand why this behavior. Could you explain it to me? Thank you!
NMaximize[{Sqrt[y^2 - x^2]^2, y^2 - x^2 >= 0, x + y^2 == 0 && 0 < y < 2 && -y < x < y}, {x, y}]
$\endgroup$