4
$\begingroup$

How can I use Minimize with the constraint that the minimum be the function of a positive odd integer.

Say I want to minimize

M[l] = l

under the constraint of lis a positive integer and l is odd.

I tried this:

constraint = (l+1)/2 ∈ Integers
Minimize[{l, constraint}, {l}]

but failed with:

Invalid constraint (1+l)/2 ∈ Integers encountered. Constraints should be equations, inequalities, or variable domain specifications.

$\endgroup$
2
$\begingroup$

Here is one way to do it.

Minimize[{l, l == 2 k +1 && k >= 0 && {k, l} ∈ Integers}, {l, k}]

{1, {l -> 1, k -> 0}}

And is another.

Minimize[{l, l == 2 k + 1 && k >= 0}, {l, k}, Integers]

Both these solutions use an auxiliary variable k to enforce oddness.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ excellent! Now I know how to do this! thanks a lot $\endgroup$ – dr.bian May 10 '17 at 8:40

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.