Ask Your Question
1

evaluation of hessian in some point

asked 2021-11-16 14:21:54 +0100

ErWinz gravatar image

hi this code works very well but i can not manage to make Sagemaths evaluate the matrix H in the critical points : this is the two lines with f

from sage.manifolds.operators import *
E.<x,y> = EuclideanSpace()
f(x,y)=exp(-y^2)+x^4-x^2
F = E.scalar_field(f)
show("3) f",f)
show("grad f=",grad(F)[:])
H=f(x,y).hessian()
show("H=",H)
Cr= solve([grad(f)[0]==0,grad(f)[1]==0],[x,y])
show("points critiques : ",Cr)

#for critique in Cr:
#    show(H(critique))#marche pas je comprend pas pourquoi
show("on voit les deux points-col et le max")
h(x,y,z)=f(x,y)-z
implicit_plot3d(h, (x, -4,4), (y, -4, 4), (z, -0.5, 5),color="blue",adaptive=True,mesh=True)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-11-16 15:45:30 +0100

rburing gravatar image

The return value of solve (when called in this way) is a list of lists of equations.

So, H(critique) is trying to evaluate H at a list of equations, which is not supported.

Instead, you can substitute a list of equations into H:

for critique in Cr:
    show(H.subs(critique))

Alternatively you can pass the keyword argument solution_dict=True to the solve command, so that the return value becomes a list of dictionaries, each of which can be passed into H.

edit flag offensive delete link more

Comments

wonderful thanks very much !

ErWinz gravatar imageErWinz ( 2021-11-17 04:38:51 +0100 )edit

@ErWinz: you can accept the answer by clicking the "accept" button (the one with a check mark to the top left of the answer). This will mark the question as solved in the list of questions.

slelievre gravatar imageslelievre ( 2021-11-17 11:48:34 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-11-16 14:21:54 +0100

Seen: 214 times

Last updated: Nov 17 '21