# Minimization with the constraint that the minimum be the function of a positive odd integer

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.

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.

• excellent！ Now I know how to do this! thanks a lot – dr.bian May 10 '17 at 8:40