ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 03 May 2020 15:07:25 +0200Solving simple utility maximization problems in sage.https://ask.sagemath.org/question/51240/solving-simple-utility-maximization-problems-in-sage/Hi all im a new user to sage as a software. Im a mod on the economics.se so I understand if this question does not meet site requirements.
Im interested in solving standard utility maximization problems in economics of the form:
$$u(x_1,x_2)=x_1^{0.7}x_2^{0.3}$$
subject to:
$$p_1x_1+p_2x_2=m$$
the goal of solving this problem would be to solve for the marshallian demand equations:
$$x_1(p_1,p_2,m)$$
$$x_2(p_1,p_2,m)$$
I know how to solve this sort of problem with pen and paper however the appropriate sage code im not sure of.
Any help would be appreciated.Sun, 03 May 2020 05:47:19 +0200https://ask.sagemath.org/question/51240/solving-simple-utility-maximization-problems-in-sage/Answer by Cyrille for <p>Hi all im a new user to sage as a software. Im a mod on the economics.se so I understand if this question does not meet site requirements.</p>
<p>Im interested in solving standard utility maximization problems in economics of the form:</p>
<p>$$u(x_1,x_2)=x_1^{0.7}x_2^{0.3}$$
subject to:</p>
<p>$$p_1x_1+p_2x_2=m$$</p>
<p>the goal of solving this problem would be to solve for the marshallian demand equations:
$$x_1(p_1,p_2,m)$$
$$x_2(p_1,p_2,m)$$</p>
<p>I know how to solve this sort of problem with pen and paper however the appropriate sage code im not sure of.</p>
<p>Any help would be appreciated.</p>
https://ask.sagemath.org/question/51240/solving-simple-utility-maximization-problems-in-sage/?answer=51245#post-id-51245Sorry I have no time to adapt the solution exactly to your context but to go short you can remove alpha and beta from the variables and replace it by your values. Or you can also explicitely define U( x, y, l, alpha, beta) =... and specify in L U(....).
You should try this
%display latex
var('A, x, y, l, alpha, beta, R, p_x, p_y');
U= A*x^(alpha)*y^(beta);
D = p_x*x + p_y*y;
show(U)
show(D)
solve(D==R, y)
L = U-l*(D-R)
show(L)
L_x= L.diff(x)
show(L_x)
L_y= L.diff(y)
show(L_y)
L_l= L.diff(l)
show(L_l)
z=solve([L_x==0, L_y==0, L_l==0,], x, y, l, solution_dict=True)
z[0]Sun, 03 May 2020 15:07:25 +0200https://ask.sagemath.org/question/51240/solving-simple-utility-maximization-problems-in-sage/?answer=51245#post-id-51245