Alien
Alien

Reputation: 136

Solution of Consumer problem in Wolfram Mathematica doesn't work

I'm trying to solve a contrained consumer problem with Cobb-Douglas preferences with Wolfram Mathematica 13.1. This problem is simple and can be solved analyticaly. But my code doesn't work.

Utility = x1^\[Alpha] * x2^(1 - \[Alpha])

constraint = p1*x1 + p2*x2 - r

Lagrangian = Utility - \[Lambda]*constraint

Foc1 = D[Lagrangian, x1]

Foc2 = D[Lagrangian, x2]

Foc3 = D[Lagrangian, \[Lambda]]

sols = Solve[{Foc1 == 0, Foc2 == 0, Foc3 == 0}, {x1, x2, \[Lambda]}]

This give me the following output:

Solve::incnst: Inconsistent or redundant transcendental equation. After reduction, the bad equation is r-p1 x1-p2 x2 == 0.
Solve::svars: Equations may not give solutions for all "solve" variables.

I tried to simplify my code to:

Solve[{x1^(-1 + \[Alpha]) x2^(1 - \[Alpha]) \[Alpha] - p1 \[Lambda] == 0, 
       x1^\[Alpha] x2^-\[Alpha] (1 - \[Alpha]) - p2 \[Lambda] == 0, 
       r - p1 x1 - p2 x2 == 0}, 
       {x1, x2, \[Lambda]}]

But this doesn't work, I get the same error. My Equations looks correct. There is an error or inconsistecy in my code?

Upvotes: 0

Views: 89

Answers (1)

Bill
Bill

Reputation: 3977

Mathematica does not assume everything is Real or assume "obvious" domains for some of your variables. I am guessing that your analytical solution does do that at some key steps in the process.

I don't know what any of your assumptions are, but if I guess then

Utility = x1^α * x2^(1 - α);
constraint = p1*x1 + p2*x2 - r;
Lagrangian = Utility - λ*constraint;
Foc1 = D[Lagrangian, x1];
Foc2 = D[Lagrangian, x2];
Foc3 = D[Lagrangian, λ];
Simplify[Reduce[{Foc1==0,Foc2==0,Foc3==0,x1>=0,Element[x2,Reals],0<α<1,p1>0,p2>0,r>0},{x1,x2,λ}]]

promptly returns

Element[x2,Reals]&&p1>0&&p2>0&&r>0&&0<α<1&&
x1==(r*α)/p1 && x2==(r-p1*x1)/p2 && 
(x1^α*(-1+α))/(p2*((r-p1*x1)/p2)^α) + λ == 0

If you can provide the essential domain information then I am hoping that Mathematica will give you the desired solution, perhaps even better than my guessing.

Upvotes: 0

Related Questions