Until now, every tentative to create a function which solves analytically a constrained optimization problem fails to be general because if it works for analytical functions it fails for transcendental ones.

I was imagining to give the good substitution to help Mathematica to solve the first order conditions when there is a trick. I have constructed the following code :

u1[x_, y_, z_] := x^α y^β z^γ
u2[x_, y_, z_] := x y z
u3[x_, y_, z_] := α Log[x] + β Log[y] + γ Log[z]
u4[x_, y_, 
    z_] := (α x^((s - 1)/s) + β y^((s - 1)/
            s) + γ z^((s - 1)/s))^(s/(s - 1))

u[x_, y_, z_] := u3[x, y, z]

con[x_, y_, z_] := 
  Subscript[p, 1] x + Subscript[p, 2] y +  Subscript[p, 3] z
l[x_, y_, z_, λ_] := 
  u[x, y, z] - λ (con[x, y, z] - R)
ll = Simplify[
   Grad[l[x, y, z, λ], {x, y, 
      z, λ}] //. {x_^(-1 + α_)
              y_^β_ z_^γ_ -> α A/x}];
Solve[ll == {0, 0, 0, 0}, {x, y, z, λ}]

When I replace with u1, u2, u3 the code works fine --- it's normal for u2 and u3 since there is no need for substitution. But, with u4 the substitution is not effective.

1) is there a way to remedy this problem and to help Mathematica in all the non-algebraic cases;

2) the code is for functions of 3 arguments. How to define a function for an arbitrary number of variables which will do the job.

  • 2
    $\begingroup$ Your code doesn't work as pasted. Perhaps the code gets mangled because of the special formatting. Could you fix that? See also this Meta post. $\endgroup$ – MarcoB Feb 2 '17 at 20:15
  • $\begingroup$ MarcoB, my code was working on version 11.0.1. But I have erased all special formattings as you have required. $\endgroup$ – cyrille.piatecki Feb 3 '17 at 7:03
  • 1
    $\begingroup$ I'm voting to close this question as off-topic because it is too localized; i.e, it applies only to the local situation and needs of its poster and answers will not benefit others. $\endgroup$ – m_goldberg Feb 5 '17 at 7:05
  • $\begingroup$ m_Goldberg I do not understand your proposal to close this question. This is an important topic for economists who use Mathematica. Some presentations or articles on Mathematica says that they can solve constrained optimization. But when one try to use classical functions used in this field for which one knows a solution (obtained with a pencil) Mathematica fails mainly because there are transcendental elements in the problem. I was thinking that it was legitimate to ask others if they have found a way to find a solution. $\endgroup$ – cyrille.piatecki Feb 5 '17 at 8:01
  • $\begingroup$ Why is the solution for Solve[u3[x, y, z] == {0, 0, 0, 0}, {x, y, z, \[Lambda]}] acceptable, but Solve[u4[x, y, z] == {0, 0, 0, 0}, {x, y, z, \[Lambda]}] not? You can use u5[x__]:= for an arbitrary number of variables. $\endgroup$ – Feyre Feb 5 '17 at 15:42

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.