0
$\begingroup$

I'm trying to perform a minimization for an arbitrary natural number. If I enter a specific number, Mathematica performs the correct minimization. Am I specifying k incorrectly, or is this beyond Mathematica's capability?

f[k_] := Module[{vars, eqn, n},
     n = 2;
     vars = Table[Subscript[x, i], {i, n}];
     eqn = Join[{Sum[Subscript[x, i], {i, n}], 
            2/(2 k + 1) == Sum[1/Subscript[x, i], {i, n}], 
            Subscript[x, 1] >= 2}, 
         Table[Subscript[x, i + 1] >= Subscript[x, i] + 1, {i, n - 1}]];
     soln = Minimize[eqn, vars, Integers]
     ];

f[4]
{24, {Subscript[x, 1] -> 6, Subscript[x, 2] -> 18}}

Assuming[k \[Element] Integers && k > 0, f[k]]

Minimize[{Subscript[x, 1] + Subscript[x, 2], 
    2/(1 + 2 k) == 1/Subscript[x, 1] + 1/Subscript[x, 2], 
    Subscript[x, 1] >= 2, 
    Subscript[x, 2] >= 1 + Subscript[x, 1]}, {Subscript[x, 1], 
    Subscript[x, 2]}, Integers]
$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.