Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Expression of the hessian of a lagrangian

When I ask for the hessian of L in the following code, SageMath returns the functions of the derivatives as $(x,y,\lambda) \rightarrow expression\ of \ f_{xx}$ for example. But I need only $f_{xx}$. What can I do ?

I have search for hessian? but there is no entry in the online documentation.

 varx=var('x y') 
paramu=var('A α β U')
paramuc=tuple(list(paramu)+[U])
paramb=var('R p_x p_y')
varl=var('λ')
varg=tuple(list(varx)+[λ])

def Cobb_Douglas(x, y, A, α, β) :
    return A*x^α*y^β

def expense(x,y,p_x,p_y) :
    return p_x*x+ p_y*y

L(x,y,λ) = Cobb_Douglas(x,y,A, α, β) -λ*(expense(x,y,p_x,p_y)-R)
L.hessian()