我正在尝试使用 Wolfram Mathematica 13.1 解决柯布-道格拉斯偏好的受限消费者问题。这个问题很简单,可以解析解决。 但我的代码不起作用。
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]}]
这给了我以下输出:
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.
我尝试将代码简化为:
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]}]
但这不起作用,我遇到了同样的错误。我的方程看起来是正确的。我的代码中有错误或不一致吗?
Mathematica 并不假设一切都是实数,也不假设某些变量具有“明显”的域。我猜测您的分析解决方案确实在该过程中的某些关键步骤中做到了这一点。
我不知道你的假设是什么,但如果我猜的话
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,λ}]]
及时返回
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
如果您可以提供必要的领域信息,那么我希望 Mathematica 能够为您提供所需的解决方案,甚至可能比我的猜测更好。