# How do I find the minimum and maximum values of a function of two variable with constraints? [closed]

The question is find the minima and maxima of the function

$$f(x,y)= x^2+5y^2+11x-12y+30$$

on $$(x^2)/81+(y^2)/49 \leq 1.$$

I've been trying to use FindMaxValue and FindMaximum like this without success:

FindMaxValue[2 x^2 + 3 y^2 + 8 x - 18 y + 11, {x^2/81 + y^2/49 <= 1}]
FindMaximum[2 x^2 + 3 y^2 + 8 x - 18 y + 11, {x^2/81 + y^2/49 <= 1}]


\$Version

(* "13.0.1 for Mac OS X x86 (64-bit) (January 28, 2022)" *)

Clear["Global*"]

f[x_, y_] := x^2 + 5 y^2 + 11 x - 12 y + 30


Note that the objective and the constraint go in the same list and the variables must be specified.

{min, max} = #[{f[x, y], x^2/81 + y^2/49 <= 1}, {x, y}] & /@
{MinValue, MaxValue} // RootReduce

(* {-(149/20), Root[
24631233979464 - 6866750384574 # + 83692030225 #^2 - 335820832 #^3 +
430336 #^4& , 4, 0]} *)

{min, max} // N

(* {-7.45, 370.859} *)

{minN, maxN} = #[{f[x, y], x^2/81 + y^2/49 <= 1}, {x, y}] & /@
{FindMinValue, FindMaxValue}

(* {-7.45002, 370.859} *)


NMaxValue fails to find the global maximum

{minN2, maxN2} = #[{f[x, y], x^2/81 + y^2/49 <= 1}, {x, y}] & /@
{NMinValue, NMaxValue}

(* {-7.45002, 211.418} *)

f = x^2 + 5 y^2 + 11 x - 12 y + 30;
cons = (x^2)/81 + (y^2)/49 <= 1;

max = Maximize[{f, cons}, {x, y}] // N


{370.859, {x -> 2.14956, y -> -6.79741}}

min = Minimize[{f, cons}, {x, y}] // N


{-7.45, {x -> -5.5, y -> 1.2}}

For visualizing:

r = ImplicitRegion[x^2/81 + y^2/49 <= 1, {x, y}]

Show[
Plot3D[f, {x, y} \[Element] r]
, Graphics3D[{
AbsolutePointSize[12], Red
, Point[{x, y, max[[1]]} /. max[[2]]]
, Point[{x, y, min[[1]]} /. min[[2]]]
}]
]
`