First time here? Check out the FAQ!

Ask Your Question
1

How to do symbolic vector/matrix manipulations in Sage?

asked 11 years ago

Gravitus gravatar image

Hello,

So I have a 2x1 vector xR2, and a function on it called f(x)=log(1Tx) which of course, returns a scalar.

I would like to compute the Hessian of this function in Sage, symbolically. That is, I would like it so show me what the 2x2 Hessian matrix would look like, but in terms of the elements of x, or even better, in terms of the vector x.

Is there such a way? Thanks.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

tmonteil gravatar image

Does it answers your question ?

sage: x, y = var('x y')
sage: f = log(x+y)
sage: f.hessian()
[-1/(x + y)^2 -1/(x + y)^2]
[-1/(x + y)^2 -1/(x + y)^2]
Preview: (hide)
link

Comments

Almost, tmonteil. I would like to know how/if it can show it, in matrix form. For example, instead of declaring x and y as variables, we declare a 2x1 vector x, so it shows the hessian in terms of the _vector_ x...

Gravitus gravatar imageGravitus ( 11 years ago )

you can try this way. But with no guarantee. sage: from sympy import * sage: from mpmath import * sage: A = MatrixSymbol('A', 1, 2) sage: logm((Identity(2)*transpose(A))

moroplogo gravatar imagemoroplogo ( 11 years ago )

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: 11 years ago

Seen: 853 times

Last updated: Feb 17 '14