Ask Your Question
1

Printing (large) symbolic matrices

asked 2016-06-03 08:21:07 +0100

bertrand-caron gravatar image

I am interested in calculating analytical Hessian for multivariable functions (up to several hundred variables). My end game is solving this analytical Hessian against numerical ones.

I have successfully set up toy models for functions with a few variables like so:

k = var('k')
l = var('l')
h(x1, y1, z1, x2, y2, z2, x3, y3) = k * (sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z2)^2) - l)^2
H=f.diff(2)
print H(x1=0., y1=0., z1=0., x2=1., y2=1., z2=1.0)

However, trying it on a more complex function yields the following output when printing the symbolic matrix (I could include the function definition, but it is rather long ...):

27 x 27 dense matrix over Symbolic Ring

Are there intrinsic limitations to displaying such matrices, or am I just not calling the appropriate function for outputting it ?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2016-06-03 19:56:18 +0100

tmonteil gravatar image

Only small matrices are printed by default. If you want to see the coefficients of the matrix, you can do:

sage: print M.str()

If you want to get the LaTeX code of your matrix, you can do:

sage: latex(M)
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2016-06-03 08:21:07 +0100

Seen: 1,075 times

Last updated: Jun 03 '16