Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function minimization with equality constraints in Mathematica 8

When using constraints with simple equality in Mathematica 8, minimization doesn't work. E.g.

FindMinimum[{x^2 + y^2,  y == 1}, {x, y}]

works ok in Mathematica 6, but gives errors in version 8. Can anyone else confirm (or explain) this? Looks like fixing one of the parameters with a constraint confuses version 8. Putting xy==1 is OK, also any inequality.

Any simple workaround on this? I have tried changing the Method, no luck. I would like to keep all the parameters in the parameter list, but hold some of them with simple constraint instead of removing the parameter name from the list. I have a working code in version 6, which does not work anymore in 8.

like image 776
Boocko Avatar asked May 20 '11 11:05

Boocko


2 Answers

Another workaround would be to use version 9.

In[1]:= FindMinimum[{x^2 + y^2, y == 1}, {x, y}]
Out[1]= {1., {x -> 0., y -> 1.}}

Which is to say, what you show above is a bug that has kindly fixed itself for a future release.

Daniel Lichtblau Wolfram Research

like image 50
Daniel Lichtblau Avatar answered Oct 03 '22 01:10

Daniel Lichtblau


Your syntax appears to be incorrect:

FindMinimum[{x^2 + y^2,  y == 1}, {x, y}]

which asks to start x with a value of y. This doesn't make much sense to me.

Perhaps you are attempting to do:

Minimize[{x^2 + y^2, y == 1}, {x, y}]
  Out:  {1, {x -> 0, y -> 1}}

Apparently your syntax is valid. Consider Minimize as shown above to be a possible work-around for your problem.

like image 32
Mr.Wizard Avatar answered Oct 03 '22 03:10

Mr.Wizard