ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 03 Jun 2016 12:56:18 -0500Printing (large) symbolic matriceshttp://ask.sagemath.org/question/33654/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 ?Fri, 03 Jun 2016 01:21:07 -0500http://ask.sagemath.org/question/33654/printing-large-symbolic-matrices/Answer by tmonteil for <p>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.</p>
<p>I have successfully set up toy models for functions with a few variables like so:</p>
<pre><code>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)
</code></pre>
<p>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 ...):</p>
<pre><code>27 x 27 dense matrix over Symbolic Ring
</code></pre>
<p>Are there intrinsic limitations to displaying such matrices, or am I just not calling the appropriate function for outputting it ?</p>
http://ask.sagemath.org/question/33654/printing-large-symbolic-matrices/?answer=33662#post-id-33662Only 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)
Fri, 03 Jun 2016 12:56:18 -0500http://ask.sagemath.org/question/33654/printing-large-symbolic-matrices/?answer=33662#post-id-33662