Hello,
what is wrong with this, please? I tried to sum some matrix elements
and got error below. I tried to sum by other means (comment # and ##
in example below) without problem. I even defined my own summation
function (analogic to ##), which at the end made similar error.
I don't think I try to evaluate numerically, so why this error?
I'm new to Sage and even to Python, so it may be trivial.
Input:
x=var('x')
lore4=matrix([[sinh(x),0,0,cosh(x)],[0,1,0,0],[0,0,1,0],[cosh(x),
0,0,sinh(x)]])
k = var('k')
#lore4[0,0]+lore4[1,1]+lore4[2,2]+lore4[3,3]
##z=var('z')
##z=0
##for k in range(0,4):
## z=z+lore4[k,k]
##z
sum(lore4[k,k],k,0,3)
Output:
Traceback (most recent call last): ##for k in range(0,4):
File "", line 1, in <module>
File "/tmp/tmpkNwukQ/___code___.py", line 12, in <module>
exec compile(u'sum(lore4[k,k],k,_sage_const_0 ,_sage_const_3 )
File "", line 1, in <module>
File "matrix0.pyx", line 847, in
sage.matrix.matrix0.Matrix.__getitem__ (sage/matrix/matrix0.c:4669)
File "expression.pyx", line 734, in
sage.symbolic.expression.Expression.__int__ (sage/symbolic/
expression.cpp:4597)
File "expression.pyx", line 4052, in
sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/
expression.cpp:18089)
TypeError: cannot evaluate symbolic expression numerically
Thank you.
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org