In looking to the page https://doc.sagemath.org/html/en/reference/calculus/sage/calculus/tests.html
by accident, I have discovered an incredible feature of Sagemath : tghe fact that a variable can be transformed in a function and vis-versa. It is very nice for an economist (not only but it is what I am) in the following code
var('x y p_x p_y R λ')
U(x,y)= x*y
L(x,y,λ)= U(x,y)+λ*(R-p_x*x-p_y*y)
sol = solve([L(x,y,λ).diff(x)==0,L(x,y,λ).diff(y)==0,L(x,y,λ).diff(λ)==0], (x,y,λ))
show(sol[0][0])
x = function('x')
x = sol[0][0].rhs()
show(LatexExpr(r'\frac{dx}{dR} = '),x.diff(R).simplify())
My question : is there a shorten way to have access to x
than writting x = sol[0][0].rhs()
since show(sol[0][0])
display the relation correctly (but without x = sol[0][0].rhs()
, I can't obtain the desired result.
Incidently, I think that this incredible feature is not enough publicized.