Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-20 Thread John Cremona
On 19 January 2015 at 23:03, mmarco mma...@unizar.es wrote: It is much faster to work with absolute fields instead of towers of extensions: sage: K.sqrt3=QuadraticField(3) sage: F.sqrt5=K.extension(x^2-5) sage: R.a1,a2,a3,a4,a5 = F[] sage: %time _=(a1+a2+a3+sqrt5*a4+sqrt3*a5)^25 CPU times:

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-20 Thread Jeroen Demeyer
On 2015-01-20 10:14, John Cremona wrote: ? Mod(x,x^2-3) + Mod(x,x^2-5) %1 = 0 That's a PARI feature: the result would lie in the ring QQ[x]/(x^2-3, x^2-5) = QQ[x]/(1) -- You received this message because you are subscribed to the Google Groups sage-devel group. To unsubscribe from this group

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-20 Thread Sébastien Labbé
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

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread mmarco
It is much faster to work with absolute fields instead of towers of extensions: sage: K.sqrt3=QuadraticField(3) sage: F.sqrt5=K.extension(x^2-5) sage: R.a1,a2,a3,a4,a5 = F[] sage: %time _=(a1+a2+a3+sqrt5*a4+sqrt3*a5)^25 CPU times: user 27.4 s, sys: 12 ms, total: 27.4 s Wall time: 27.5 s sage:

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Ondřej Čertík
Hi Miguel, On Mon, Jan 19, 2015 at 4:03 PM, mmarco mma...@unizar.es wrote: It is much faster to work with absolute fields instead of towers of extensions: sage: K.sqrt3=QuadraticField(3) sage: F.sqrt5=K.extension(x^2-5) sage: R.a1,a2,a3,a4,a5 = F[] sage: %time

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Nils Bruin
On Monday, January 19, 2015 at 9:27:44 PM UTC-8, Ondřej Čertík wrote: and your approach returns a wrong number of terms, so something is wrong. But it is quite fast. The term count doesn't tell you that. The representation of sqrt3 and sqrt5 doesn't consist of single term expressions:

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Ralf Stephan
What is here? AMD Phenom 3GHz, 8GB RAM, no other big jobs Since that expression is large, the cache size of the CPU might significantly impact performance. Wouldn't that affect any of the following? │ Sage Version 6.5.beta5, Release Date: 2015-01-05 │ │ Type

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Ralf Stephan
On Sunday, January 18, 2015 at 9:18:53 AM UTC+1, vdelecroix wrote: Your example can be reduced to polynomials sage: K.sqrt3 = QuadraticField(3) sage: R.a1,a2,a3,a4,a5 = K[] sage: timeit((a1+a2+a3+a4+sqrt3*a5)^25) 5 loops, best of 3: 81 ms per loop How do you get this speed? Here

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread William Stein
On Mon, Jan 19, 2015 at 8:55 AM, Ralf Stephan gtrw...@gmail.com wrote: On Sunday, January 18, 2015 at 9:18:53 AM UTC+1, vdelecroix wrote: Your example can be reduced to polynomials sage: K.sqrt3 = QuadraticField(3) sage: R.a1,a2,a3,a4,a5 = K[] sage: timeit((a1+a2+a3+a4+sqrt3*a5)^25) 5

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread William Stein
On Mon, Jan 19, 2015 at 9:46 AM, Ralf Stephan gtrw...@gmail.com wrote: What is here? AMD Phenom 3GHz, 8GB RAM, no other big jobs Since that expression is large, the cache size of the CPU might significantly impact performance. Wouldn't that affect any of the following? │ Sage Version

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Ondřej Čertík
On Mon, Jan 19, 2015 at 11:19 AM, Ondřej Čertík ondrej.cer...@gmail.com wrote: Hi Vincent, On Sun, Jan 18, 2015 at 10:06 AM, Vincent Delecroix 20100.delecr...@gmail.com wrote: Hi, 2015-01-18 18:03 UTC+01:00, Ondřej Čertík ondrej.cer...@gmail.com: Can you invent an example, that can't be

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Vincent Delecroix
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. Vincent

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Ondřej Čertík
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 =

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Ondřej Čertík
Hi Vincent, On Sun, Jan 18, 2015 at 10:06 AM, Vincent Delecroix 20100.delecr...@gmail.com wrote: Hi, 2015-01-18 18:03 UTC+01:00, Ondřej Čertík ondrej.cer...@gmail.com: Can you invent an example, that can't be converted to polynomials? Perhaps (a1+a2+a3+sqrt(5)*a4+sqrt(3)*a5)^25? Still

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Nils Bruin
On Monday, January 19, 2015 at 9:46:47 AM UTC-8, Ralf Stephan wrote: What is here? AMD Phenom 3GHz, 8GB RAM, no other big jobs On Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz I'm getting the same times as Vincent. That's on 6.5beta4 or 5. The difference you're reporting is very large. You

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread William Stein
On Mon, Jan 19, 2015 at 10:32 AM, Nils Bruin nbr...@sfu.ca wrote: On Monday, January 19, 2015 at 9:46:47 AM UTC-8, Ralf Stephan wrote: What is here? AMD Phenom 3GHz, 8GB RAM, no other big jobs On Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz I'm getting the same times as Vincent. That's on

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Nils Bruin
On Monday, January 19, 2015 at 10:35:42 AM UTC-8, William wrote: Nils, did you specifically try this **exact input**?? Full session: sage: sage: K.sqrt3 = QuadraticField(3) sage: sage: R.a1,a2,a3,a4,a5 = K[] sage: sage: timeit((a1+a2+a3+a4+sqrt3*a5)^25) 5 loops, best of 3: 79.9 ms per

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-19 Thread Vincent Delecroix
The computation in pari (directed from Sage): sage: x=pari(x) sage: y=pari(y) sage: sqrt3=pari(Mod)(x, x^2-3) sage: sqrt5=pari(Mod)(y, y^2-5) sage: a1=pari(a1) sage: a2=pari(a2) sage: a3=pari(a3) sage: a4=pari(a4) sage: a5=pari(a5) sage: time f = (a1+a2+a3+sqrt5*a4+sqrt3*a5)**18 CPU times: user

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-18 Thread Vincent Delecroix
Your example can be reduced to polynomials sage: K.sqrt3 = QuadraticField(3) sage: R.a1,a2,a3,a4,a5 = K[] sage: timeit((a1+a2+a3+a4+sqrt3*a5)^25) 5 loops, best of 3: 81 ms per loop (And just for completeness, the symbolic expansion on my laptop took 4.54s) Vincent 2015-01-18 7:26 UTC+01:00,

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-18 Thread Vincent Delecroix
Hi, 2015-01-18 18:03 UTC+01:00, Ondřej Čertík ondrej.cer...@gmail.com: Can you invent an example, that can't be converted to polynomials? Perhaps (a1+a2+a3+sqrt(5)*a4+sqrt(3)*a5)^25? Still doable. You need to involve log, exp, cos or similar transcendental functions. Vincent -- You received

Re: [sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-18 Thread Ondřej Čertík
Hi Vincent, On Sun, Jan 18, 2015 at 1:18 AM, Vincent Delecroix 20100.delecr...@gmail.com wrote: Your example can be reduced to polynomials sage: K.sqrt3 = QuadraticField(3) sage: R.a1,a2,a3,a4,a5 = K[] sage: timeit((a1+a2+a3+a4+sqrt3*a5)^25) 5 loops, best of 3: 81 ms per loop That's cool,

[sage-devel] The fastest way to expand((a1+a2+a3+a4+sqrt(3)*a5)^25)

2015-01-17 Thread Ondřej Čertík
Hi, I was wondering what the fastest way is to do this benchmark in Sage: ┌┐ │ Sage Version 6.4, Release Date: 2014-11-14 │ │ Enhanced for SageMathCloud.│