New to Mathematica, trying to solve a simple economics problem but having troubles with using Solve and Eliminate.
The question:
Now suppose that this agent makes two choices, expressed by x and y and that these choices come at a cost x+p y. Assume the agent has 5 units of budget to cover the cost and is required to spend their entire budget, and extracts a utility given by
U[x,y]=m1 x -R1/2 x^2+ C x y+m2 y -R2/2 y^2 for C>0, m1>0, m2>0, R1>0, R2>0.
b: Define the Lagrangian for the constrained optimization problem as a function Mathematica, calculate the optimal choices of x and y as an expression in m, R, k, and C as well as the resulting utility.
My code:
It seems like I cannot internally get rid of the choice variables in my final answers for x, y, and lambda. Google doesn't help in this regard and I have tried Eliminate to no avail :(
I am new to Mathematica and any help would be so amazing!
Copied code:
L(x, y, λ) = m1 x - (R1/2) x^2 + C x y + m2 y - (R2)/2 y^2 - λ(x + p y - 5)
eqn1 = Solve[ D[L[x, y, λ], x] == 0, x ]
eqn2 = Solve[D[L[x, y, λ], x] == 0, y]
eqn3 = Solve[D[L[x, y, λ], x] == 0, λ]
Solve[{equation1, equation2, equation3}, {x, y, λ}, {x, y,
λ}]
Solve[Eliminate[ x == (m1 + C y - λ)/R1 && y == (-m1 +
R1 x + λ)/C && λ ==
m1 - R1 x + C y , {x, y, λ} ]
{x, y, \[Lambda]},
in your fifth line of code. Also, what are you trying to accomplish by combilningEliminate
andSolve
. $\endgroup$