Hi Vincent, On Mon, Jan 19, 2015 at 11:30 AM, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > Hello Ondrej, > > For such questions of Sage usage, it is better to discuss on > ask.sagemath.org or sage-support. > > You can also deal with all algebraic numbers at once with QQbar > > sage: sqrt3 = QQbar(sqrt(3)) > sage: sqrt5 = QQbar(sqrt(5)) > > But then polynomials over QQbar are much slower.
Thanks, I'll ask there the next time. Since I started the thread here, I'll keep it here so that everything is in one place. So if you agree that I did things correctly, let's compare timings (and lengths of expressions --- any idea how to get the number of terms in a better way in Sage?): sage: K.<sqrt3> = QuadraticField(3) sage: L.<sqrt5> = K.extension(x^2-5) sage: R.<a1,a2,a3,a4,a5> = L[] sage: time f = (a1+a2+a3+sqrt5*a4+sqrt3*a5)^18 CPU times: user 2.43 s, sys: 3.94 ms, total: 2.44 s Wall time: 2.44 s sage: len(str(f).split("+")) 7315 Now compare this to CSymPy: In [1]: from csympy import * In [2]: var('a1 a2 a3 a4 a5 a6 a7') Out[2]: (a1, a2, a3, a4, a5, a6, a7) In [3]: %time f = ((a1+a2+a3+sqrt(5)*a4+sqrt(3)*a5)**18).expand() CPU times: user 125 ms, sys: 7.73 ms, total: 133 ms Wall time: 133 ms In [4]: len(f.args) Out[4]: 7315 You can also compare this to Sage symbolics (which should use the same algorithm as CSymPy): sage: var('a1 a2 a3 a4 a5 a6 a7') (a1, a2, a3, a4, a5, a6, a7) sage: %time f = ((a1+a2+a3+sqrt(5)*a4+sqrt(3)*a5)**18).expand() CPU times: user 4.98 s, sys: 76.4 ms, total: 5.05 s Wall time: 4.95 s sage: len(f.operands()) 7315 Which is also very slow. I will try this in ginac directly, as that's what pynac is forked from, maybe it's just the Python overhead. Also, I will carefully check that we don't have a bug in csympy. Ondrej -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.