Printing (large) symbolic matrices

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 close merge delete

Sort by » oldest newest most voted

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)
more