# Revision history [back]

### how to properly substitute in a matrix?

Let's consider a modified example from Sage reference manual

f(x,y)=x^2*y+y^2+y

solutions=solve(list(f.diff()),[x,y])

the_solution=solutions

H=f.diff(2); # Hessian matrix

How can i properly substitute the_solution into H?

I have tried:

H(x,y).subs(the_solution) - does not work.

This will work for H(x,y).subs(x==0)

H(x,y).subs_expr(*the_solution) - does not work.

This will work for f(x,y).subs_expr(*the_solution) 2 No.2 Revision

### how to properly substitute in a matrix?

Let's consider a modified example from Sage reference manual

f(x,y)=x^2*y+y^2+y

solutions=solve(list(f.diff()),[x,y])

the_solution=solutions

f(x,y)=x^2*y+y^2+y
solutions=solve(list(f.diff()),[x,y])
the_solution=solutions
H=f.diff(2);  # Hessian matrixmatrix


How can i properly substitute the_solution into H?

I have tried:

H(x,y).subs(the_solution) - does not work.

This will work for H(x,y).subs(x==0)

H(x,y).subs_expr(*the_solution) - does not work.

This will work for f(x,y).subs_expr(*the_solution)