A standard optimization problem in economics is choosing a consumption bundle subject to prices and a budget constraint:
$$\max_{x,y} \sqrt{x} + \sqrt{y} \hspace{1cm} \text{s.t. } p_x \cdot x + p_y \cdot y \leq w $$
With the two goods, x
and y
, these solve easily in Mathematica:
assumptions = x >= 0 && y >= 0 && px > 0 && py > 0 && w > 0;
FullSimplify[ArgMax[{Sqrt[x] + Sqrt[y], px*x + py*y <= w && assumptions},
{x,y}], assumptions]
As it should, this yields: $$x^*=\frac{w p_y}{p_x (p_x+p_y)}, \hspace{2cm} y^*=\frac{w p_x}{p_y(p_x+p_y)}$$
The problem with three goods is:
$$\max_{x,y,z} \sqrt{x} + \sqrt{y} + \sqrt{z} \hspace{1cm} \text{s.t. } p_x \cdot x + p_y \cdot y + p_z \cdot z \leq w $$
Solving it analogously for some reason does not work for me:
assumptions = x >= 0 && y >= 0 && z >= 0 && px > 0 && py > 0 && pz > 0 && w > 0;
FullSimplify[ArgMax[{Sqrt[x] + Sqrt[y] + Sqrt[z], px*x + py*y + pz*z <= w && assumptions},
{x, y, z}], assumptions]
Mathematica accepts it and runs indefinitely without giving an answer. The problem is really only slightly more difficult than the two-variable case. You just get the optimality conditions from the Lagrangian and then solve as a system of four equations (instead of 3 as above) and get: $$x^*=\frac{w p_y p_z}{p_x (p_xp_y+p_xp_z+p_yp_z)}, \hspace{1cm} y^*=\frac{w p_x p_z}{p_y (p_xp_y+p_xp_z+p_yp_z)}$$ $$z^*=\frac{w p_x p_y}{p_z (p_xp_y+p_xp_z+p_yp_z)}$$
Why is Mathematica unable to work that out when it can handle the two-variable case almost instantaneously?