How to make Minimize with Sqrt calculate faster?
Coding the square root in polynomial terms yields the result in 0.06 sec. on my laptop:
Minimize[{u + v,
u^2 == 3 + x && v^2 == 3 - x*y && x^2 + y^2 == 9 && u >= 0 &&
v >= 0}, {x, y, u, v}]
(*
{Root[9 - 54 #1^2 + 45 #1^4 - 12 #1^6 + #1^8 &, 5],
{x -> -3 + Root[9 - 54 #1^2 + 45 #1^4 - 12 #1^6 + #1^8 &, 5]^2,
y -> 3/(-3 + Root[9 - 54 #1^2 + 45 #1^4 - 12 #1^6 + #1^8 &, 5]^2),
u -> Root[9 - 54 #1^2 + 45 #1^4 - 12 #1^6 + #1^8 &, 5],
v -> 0}}
*)
It can do it if you give additional constraints and break the problem into 3 cases.
ClearAll[x, y];
Minimize[{Sqrt[3 + x] + Sqrt[3 - x*y], x^2 + y^2 == 9 && x > 0}, {x, y}]//N
(* {2.01754, {x -> 1.07047, y -> 2.80252}} *)
So by giving different combinations, it can give all answers
Minimize[{Sqrt[3 + x] + Sqrt[3 - x*y], x^2 + y^2 == 9 && x < 0}, {x, y}]//N
(* {0.444391, {x -> -2.80252, y -> -1.07047}} *)
And
Minimize[{Sqrt[3 + x] + Sqrt[3 - x*y], x^2 + y^2 == 9 && x == 0}, {x,y}]//N
(*{3.4641, {x -> 0., y -> 3.}}*)
So it looks like, from the above two results, that the second one is the min which is 0.444391
Show[
Plot3D[Sqrt[3 + x] + Sqrt[3 - x*y], {x, -3, 1}, {y, -3, 0},
PlotStyle -> Opacity[0.2]],
Graphics3D[{Red, PointSize[0.1],
Point[{-2.802517076888147`, -1.0704662693192697`,0.4443905074502075`}]}]
]
I noticed it is when x=0
is added, it hangs. Like this
Minimize[{Sqrt[3 + x] + Sqrt[3 - x*y], x^2 + y^2 == 9 && x <= 0}, {x,y}]
But this returns answer immediately
Minimize[{Sqrt[3 + x] + Sqrt[3 - x*y], x^2 + y^2 == 9 && x < 0}, {x,y}]
May be worth sending report to [email protected]
expr = Sqrt[3 + x] + Sqrt[3 - x*y];
fd = FunctionDomain[{expr, x^2 + y^2 == 9}, {x, y}] //
FullSimplify
(* x y <= 3 && x^2 + y^2 == 9 *)
Plot the function to find additional constraints on x
and y
to use in the Minimize
Plot3D[expr, {x, -3, 3}, {y, -3, 3},
RegionFunction -> (#1^2 + #2^2 <= 9 &),
AxesLabel -> Automatic]
Adding the constraints from the plot to the constraints from FunctionDomain
min = Minimize[{expr, fd && x < 0 && y < 0}, {x, y}] //
ToRadicals // Simplify
min // N
(* {0.444391, {x -> -2.80252, y -> -1.07047}} *)