How to find the solution and to explain why the following code fails

asked 2023-08-31 13:56:18 +0200

Cyrille gravatar image

I have other mean that works to solve the following problem. I am writting a note to explain how to use SageMath including what doesn't work as expected and the way to correct our program to successfully arrive to a solution.

How can I explain why this doesn't work and what shoud be done to arrive to the solution ? I do not remember if and how I can change the algorithm. Here it's only a Cobb-douglas utility with a budget constraint.

var('x_A y_A  p_x p_y x_T y_T x_Aa y_Aa  α β δ  λ_A λ_B');
assume(0<α)
assume(α<=1)
assume(0<β)
assume(β<=1)
assume(0<γ)
assume(γ<=1)
assume(0<δ)
assume(δ<=1)
assume(0<x_Aa)
assume(0<y_Aa)
assume(0<x_Ba)
assume(0<y_Ba)
assume(0<p_x)
assume(0<p_y)
U=x_A^(α)*y_A^(β);
V=x_B^(γ)*y_B^(δ);
show(LatexExpr(r"U(x_A, y_A) ="),U)
show(LatexExpr(r"V(x_B, y_B) ="),V)
d_A = x_A*p_x + y_A*p_y 
r_A = x_Aa*p_x + y_Aa*p_y
L_A = U- λ_A*(d_A - r_A)
L_Ax = diff(L_A,x_A)
L_Ay = diff(L_A,y_A)
L_Aλ = diff(L_A,λ_A)
show(L_Ax)
show(L_Ay)
show(L_Aλ)
sol = solve([L_Ax==0,L_Ay==0,L_Aλ==0],x_A,x_A,λ_A)
sol
edit retag flag offensive close merge delete