# Maximization subject to constraints

I want to solve for parameters and not specific values.

(* Define the objective function *)
U[c_, tl_] := Sqrt[c] * Sqrt[tl]

(* Define the constraint function *)
constraint[tc_, T_, p_, c_, k_, pp_, j_, tl_] := Sqrt[tc]*T - p*c - pr*k*tc - pp*j*tc - Sqrt[tc]*tl - Sqrt[tc]*tc == 0

(* Maximize the objective function subject to the constraint *)
maximized = Maximize[{U[c, tl], constraint[tc, T, p, c, k, pp, j, tl] && T > 0 && p > 0 && c > 0 && k > 0 && tc > 0 && tl > 0 && pr > 0 && pp > 0}, {c, tl, tc}]

(* Display the result *)
maximized

• Please manually edit your code to put an * in front of the ) on your second line, it looks like you might have had a space between the * and ) and posting ate the *. Then insert a literal * everywhere between pairs of symbols that being multiplied so that readers can be certain which are multicharacter names and which are multiplied. Then consider rethinking your code by making all your Sqrt[c] into c and thus bare c into c^2 and Sqrt[tc] into tc and thus bare tc into tc^2. Since all your variables are positive that should make your problem easier for MMA to solve.
– Bill
Commented May 29 at 18:46
• If you insert 4 spaces in front of each line of code the the posting process will understand that this is code and it will do less damage by not thinking that you are using * to tell it to flip from regular to italic. and back
– Bill
Commented May 29 at 19:22

maximized = Maximize[{Sqrt[c]*Sqrt[tl],

produces a result in terms of Roots of biquadratic equations which takes 1 MB of memory. The optimal value of the objective function equals
Piecewise[ {{-Root[-(j^4*pp^4*T^3) - 4*j^3*k*pp^3*pr*T^3 - 6*j^2*k^2*pp^2*pr^2* T^3 - 4*j*k^3*pp*pr^3*T^3 - k^4*pr^4*T^3 - 8*j^2*pp^2*T^4 - 16*j*k*pp*pr*T^4 - 8*k^2*pr^2*T^4 - 16*T^5 + (27*j^5*p*pp^5 + 135*j^4*k*p*pp^4*pr + 270*j^3*k^2*p*pp^3*pr^2 + 270*j^2*k^3*p*pp^2*pr^3 + 135*j*k^4*p*pp*pr^4 + 27*k^5*p*pr^5 + 225*j^3*p*pp^3*T + 675*j^2*k*p*pp^2*pr*T + 675*j*k^2*p*pp*pr^2* T + 225*k^3*p*pr^3*T + 500*j*p*pp*T^2 + 500*k*p*pr*T^2)*#1^2 + 3125*p^2*#1^4 & , 1], (pr > 0 && pp > 0 && k > 0 && j >= -((k*pr)/pp) && T > 0 && p > 0) || (pr > 0 && pp > 0 && k > 0 && j < -((k*pr)/pp) && T >= 2*j^2*pp^2 + 4*j*k*pp*pr + 2*k^2*pr^2 && p > 0) || (pr > 0 && pp > 0 && k > 0 && j < -((k*pr)/pp) && Inequality[0, Less, T, Less, 2*j^2*pp^2 + 4*j*k*pp*pr + 2*k^2*pr^2] && p > 0)}}, -Infinity]