2

I found a problem here enter image description here

How do we go about solving this in Mathematica? I did something like this:

NMinimize[(x^2 + y^2 - 1)^2, {x, y}] 

this gives {3.08149*10^-33, {x -> 0.865404, y -> 0.501074}}

And used this y -> 0.501074 and did this:

NMinimize[
 x^2 + 0.1*Cos[4 Pi x] + y^2 + 0.1*Sin[4 Pi y] /. 
  y -> 0.5010739136683062`, x]

which gave

{0.207832, {x -> -0.221351}}

Edit: Actually, I had tried this method and meant to post it today but got late:

F[x_, y_] := x^2 + 0.1*Cos[4 Pi x] + y^2 + 0.1*Sin[4 Pi y];
g[x_, y_] := (x^2 + y^2 - 1)^2;

NMinimize[{F[x, g[x, y]], Derivative[0, 1][g][x, y] == 0}, {x, y}]

I got {0.390615, {x -> -0.627901, y -> -0.778293}}

If plot this then I get:enter image description here This doesn't make sense

sra
  • 717
  • 4
  • 15

2 Answers2

3

I don't think this is a first, but I rarely answer a question I voted to close. In this case I found the wording of the problem to be convoluted (at least for me) so I opted to take a stab at it.

We need a function to do the inner optimization.

innerMin[x_?NumericQ] := 
 First[FindArgMin[{(x^2 + z^2 - 1)^2, 0 <= z <= 1}, {z, 1/2}]]

The actual objective function uses the inner optimization.

objFunc[x_] := 
 With[{y = innerMin[x]}, x^2 + 0.1*Cos[4 Pi x] + y^2 + 0.1*Sin[4 Pi y]]

Let's see what we get.

NMinimize[{objFunc[x], 0 <= x <= 1}, x]

(* Out[6]= {0.858145, {x -> 0.270149}} *)

Daniel Lichtblau
  • 58,970
  • 2
  • 101
  • 199
1
F[x_, y_] = x^2 + 1/10*Cos[4 Pi x] + y^2 + 1/10*Sin[4 Pi y]

g[x_, y_] = (x^2 + y^2 - 1)

nmin = NMinimize[{F[x, y], g[x, y] == 0, 0 <= x <= 1, 
0 <= y <= 1}, {x, y}, Method -> "DifferentialEvolution"]

Show[Plot3D[F[x, y], {x, 0, 1}, {y, 0, 1}, PlotRange -> All, 
RegionFunction -> Function[{x, y}, -.01 < g[x, y] < .01], 
PlotPoints -> 100], 
Graphics3D[{Red, 
Sphere[{x, y, F[x, y]} /. nmin[[2]], .03]}]]

sol = Flatten@
Solve[{g[x, y] == 0, 0 <= x <= 1, 0 <= y <= 1}, {x, y}, Reals]

(min = Minimize[{F[x, Sqrt[1 - x^2]], 0 <= x <= 1}, x, Reals])

Plot[F[x, Sqrt[1 - x^2]], {x, 0, 1}, 
GridLines -> {{x /. min[[2]]}, None}]
Akku14
  • 17,287
  • 14
  • 32
  • Isn't the definition of g[x_,y_] incorrect? – sra Feb 18 '22 at 00:43
  • y == ArgMin[{(x^2 + z^2 - 1)^2, 0 < z < 1 && 0 < x < 1}, z, Reals] // FullSimplify[#, 0 < x < 1] & yields Sqrt[1 - x^2] == y and sol = Flatten@ Solve[{g[x, y] == 0, 0 <= x <= 1, 0 <= y <= 1}, {x, y}, Reals] yields {y -> ConditionalExpression[Sqrt[1 - x^2], 0 <= x <= 1]} – Akku14 Feb 18 '22 at 06:49