As the first part of a demonstration on eigensystems, I was surprised to see that computing QQbar
polynomial roots was way slower that computing the roots of the same polynomial expressed as a symbolic expression, or solve
ing it :
# Relative timings of QQbar.roots and solve
from time import time as stime
BR = QQbar
Dim = 3
set_random_seed(0)
pM = MatrixSpace(BR, Dim).random_element()
sM = matrix([[SR(u.radical_expression()) for u in v] for v in pM])
sl = var("sl")
slI = sl*diagonal_matrix([1]*Dim)
sCM = sM - slI
sCP = sCM.det()
t0 = stime()
SS = solve(sCP, sl)
t1 = stime()
SR = sCP.roots()
t2 = stime()
R1.<pl> = BR[]
plI = pl*diagonal_matrix([1]*Dim)
pCM = pM - plI
pCP = pCM.det()
t3 = stime()
SP = pCP.roots()
t4 = stime()
print("solve : %7.2f, roots(symbolic) : %7.2f, roots(QQbar) : %7.2f"%\
(t1 -t0, t2 - t1, t4 - t3))
gives :
solve : 2.36, roots(symbolic) : 2.04, roots(QQbar) : 600.07
a quick check on Cocalc showed the same behavior in 9.1 ; so if it is a problem, it is not a recent one…
Is this the expected behavior ?
Forgot to add : pM.eigenvectors_right()
doesn’t returns after 5 hours… And, yes, all pM
‘s elements have a radical expression :
sage: sM
[ -sqrt(2) - 1 1/4*I*sqrt(759) - 1/4 -2*sqrt(3)]
[ 1/2*I*sqrt(3) + 1/2 1/8*sqrt(33) + 1/8 -1/5*sqrt(29) + 3/5]
[ 0 1/4 1/2*I*sqrt(23) + 1/2]
HTH,
OK. That was not an error of mine (nor my Sage installation), but a a genuine problem. So no indication to file a ticket.Note : Numerics with"standard" are not a problem :sage: %time matrix([[CDF(u) for u in v] for v in pM]).eigenvectors_right()CPU times: user 1.95 ms, sys: 15 µs, total: 1.96 msWall time: 1.85 ms[(-1.5855741097050124 - 1.9835895314317984*I,[(0.9524479486112228, -0.2837102376875301 - 0.11002559239003057*I, 0.011400252227268036 - 0.010761481586469179*I)],1),(0.10840730449357763 + 1.6730496133213792*I,[(0.8835538411020463, 0.2631022513327894 - 0.3627905504445216*I, 0.05890961187635257 + 0.12256626515553348*I)],1),(0.4060235736555931 + 2.708455679766778*I,[(0.8864942697472706, 0.26813150779882816 - 0.24992379361655742*I, -0.24416421274380526 - 0.14196949964794017*I)],1)]But if you need extended precision, there's a snag :```sage: C= ComplexField(200)sage: %time foo = matrix([[C(u) for u in v] for v in pM]).eigenvectors_right()<timed exec>:1: UserWarning: Using generic algorithm for an inexact ring, which may result in garbage from numerical precision issues.
--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/5b389532-91fb-4e33-b8f4-b7ad8e21e419n%40googlegroups.com.
Very nice ! I wasn’t aware of it… Now a couple questions/remarks :
Is there a reason for this being implemented for ComplexBallField
but not for ComplexField
(except CDF
) ? What about ComplexIntervalField
?
I am not aware of anything comparing the abilities of the various numerical tools available in Sagemath in the documentation. Did I miss it ?
At the very least, a tutorial illustrating them would be useful. A better (but possibly quite heavier) text would be additions to the numerical computing chapters of a new edition of Computational mathematics with Sagemath, which is more and more in order…
What do you think ?