# Consumer Maximization Problem Doesn't Work in Wolfram Mathematica

I'm trying to solve a problem that can be seen in the paper "The Role of the Structural Transformation in Aggregate Productivity". The problem is:

Manually it is difficult to find the solution, but this problem has an analytical solution, and the solution is Real. So I'm using Wolfram Mathematica and I make the following code:

ClearAll["Global*"]

(*Define the utility function*)
Utility =
a*Log[ca - abar] + (1 - a)*(1/rho)*
Log[b*cm^rho + (1 - b)*(cs + sbar)^rho];
(*Define constraint*)

constraint = pa*ca + pm*cm + ps*cs - w *l;
(*Define the Lagrangian and its derivatives*)
Lagrangian = Utility - \[Lambda]*constraint;

Foc1 = D[Lagrangian, ca];
Foc2 = D[Lagrangian, cm];
Foc3 = D[Lagrangian, cs];
Foc4 = D[Lagrangian, \[Lambda]];

sols = Simplify[
Solve[{Foc1 == 0, Foc2 == 0, Foc3 == 0, Foc4 == 0}, {ca, cm,
cs, \[Lambda]},
Assumptions -> {pa > 0, pm > 0, ps > 0,
ca > 0, cm > 0, cs > 0,
abar > 0, sbar > 0,
w > 0, l > 0,
0 < a < 1 , 0 < b < 1, rho < -1}
]]



However, he does not find a symbolic solution to my problem, the code crashes. So, I tried other ways, and write my problem without Lagrange. But it returns this in a few seconds with no warnings, no helpful messages and no solution.

ClearAll["Global*"]

Utility =
a*Log[ca - abar] + (1 - a)*(1/rho)*
Log[b*cm^rho + (1 - b)*(cs + sbar)^rho];

(*Definir a restrição*)
constraint = pa*ca + pm*cm + ps*cs - w*l;

(*Definir o objetivo de maximização*)
Objective = -Utility;

(*Resolver o problema de maximização*)
Maximize[{Objective,
constraint > 0 && ca > 0 && cm > 0 && cs > 0 && \[Lambda] > 0 &&
0 < a < 1 && 0 < b < 1 && rho < -1, ca > abar}, {ca, cm, cs}]


The solution is real, but raising expressions to negative Real powers can causes problems? Is there something wrong in my code? What can I do to simplify or force Wolfram to find the solution?

• Give us a link for the paper where is analytical solution?Thanks Feb 15 at 21:53
• For first code and for: rho = -2 can be computed. Try: rho = -2; eq = ({Foc1 == 0, Foc2 == 0, Foc3 == 0, Foc4 == 0} // FullSimplify); Solve[eq, {ca, cm, cs, \[Lambda]}] . Feb 15 at 21:56
• The paper can be view here. In appendix A3 the autors provide an analytical solution to this problem.
– mjr
Feb 15 at 22:05
• The author also wrote that these are systems of nonlinear equations, and such systems cannot be solved analytically, only numerically. Feb 15 at 22:47
• But in appendix the authors provide an analytical solution to this problem. Equations A-3, A-4 and A-5. In the paper "The Role of the Structural Transformation in Aggregate Productivity", in fact, they don't provide analytical solution, only some of FOCs.
– mjr
Feb 15 at 22:55

Hint.

For $$f(x) > 0$$

$$\arg\max \log(f(x)) = \arg\max f(x)$$

ClearAll["Global*"]

(*Define the utility function*)
Utility = a*(ca - abar)^a (b*cm^rho + (1 - b)*(cs + sbar)^rho)^((1 - a)*(1/rho));
(*Define constraint*)

constraint = pa*ca + pm*cm + ps*cs - w*l;
(*Define the Lagrangian and its derivatives*)
Lagrangian = Utility - \[Lambda]*constraint;

Foc1 = D[Lagrangian, ca];
Foc2 = D[Lagrangian, cm];
Foc3 = D[Lagrangian, cs];
Foc4 = D[Lagrangian, \[Lambda]];

sols = Simplify[Solve[{Foc1 == 0, Foc2 == 0, Foc3 == 0, Foc4 == 0}, {ca, cm, cs, \[Lambda]}]]

• The problem is that he doesn't find a solution to all the unknowns.
– mjr
Feb 15 at 20:09
• Substituting the found values for ca and cm into the constraint, we can conclude that one of ca, cm, cs, depends of the others. Feb 15 at 20:55
• This doesn't work well. He cannot find a feasible value for cs. The closest solution I found was the provide by @MariuszIwaniuk where rho equal to -2, but I replace by 2. rho = 2; eq = ({Foc1 == 0, Foc2 == 0, Foc3 == 0, Foc4 == 0} // FullSimplify); Solve[eq, {ca, cm, cs, \[Lambda]}]`.
– mjr
Feb 17 at 12:28