I am trying to find a minimum of a function consisting of variables and parameters, where I only want to minimize with respect to the variables while defining constraints on the parameters. To illustrate, here a simple example:

I want to minimize the energy function

E = 2 A/Δ + 2 Ku Δ

with respect to Δ, assuming that A and K are positive. Here is my attempt:

Minimize[{2 A/Δ + 2 Ku Δ, {A > 0, Ku > 0, Δ > 0}}, Δ]

The code does yield a result that distinguishes between cases of A,K>0 and cases where that condition is not fulfilled, indicating to me that the constraints are not properly taken into account.

How do I properly define constraints on the parameters, such that the code yields only one solution:

{4 Sqrt[A Ku],{Δ ->Sqrt[A/Ku]}}

I could not find any documentation on minimizing functions with parameters.


In this case, the easiest approach is just to simplify the resulting expression with some assumptions noted:

   Minimize[{2 A/Δ + 2 Ku Δ, {A > 0, Ku > 0, Δ > 0}}, Δ],
   Assumptions -> {A > 0, Ku > 0, Δ > 0}]

{4 Sqrt[A Ku], {Δ -> Sqrt[A/Ku]}}

| improve this answer | |
  • $\begingroup$ +1 for this workaround. However, I still would like to see if there is a correct syntax for specifying the constraints such that they are properly considered already in the Minimize function. $\endgroup$ – Felix Aug 24 '16 at 18:48
  • $\begingroup$ The way you have expressed it is asking Mathematica to only find values of Delta that make Ku and A positive. $\endgroup$ – mikado Aug 24 '16 at 18:50

Very similar to @user21382, but wrapping the whole expression in Assuming. For some reason, the Minimise ignores the assumptions, so a Simplification step is still required.

Note that putting the Ku>0, A>0 is unnecessary (this is like asking Mathematica to find a Δ that satisfies these constraints.

Assuming[A > 0 && Ku > 0, Simplify[Minimize[{2 A/Δ + 2 Ku Δ, {Δ > 0}}, Δ]]]
| improve this answer | |
  • $\begingroup$ Does that mean that it is not possible to specify assumptions on the parameters within the Minimize function? $\endgroup$ – Felix Aug 24 '16 at 19:33
  • $\begingroup$ @Felix: I don't know of any way to do it. $\endgroup$ – mikado Aug 24 '16 at 19:35

To set global assumptions, you can do:

$Assumptions = A > 0 && Ku > 0

Then, this statement:

Simplify[Minimize[{2 A/Δ + 2 Ku Δ, {Δ > 0}}, Δ]]

returns the correct results. Strangely, this does NOT work without the Simplify:

Minimize[{2 A/Δ + 2 Ku Δ, {Δ > 0}}, Δ]

I do not know why. This seems like a bug.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.