You need to define a polynomial ring:

sage: P.<x> = PolynomialRing(RR)
sage: f=x^24+34*x^12+45*x^3+9*x^18 +34*x^10+ 32*x^21
sage: time for i in range(10000):  a=f(x=RR.random_element())
CPU times: user 0.31 s, sys: 0.00 s, total: 0.31 s
Wall time: 0.32

sage: def g(y):
....:         return y^24+34*y^12+45*y^3+9*y^18 +34*y^10+ 32*y^21
....:
sage: time for i in range(10000):  a=g(RR.random_element())
CPU times: user 0.83 s, sys: 0.02 s, total: 0.85 s
Wall time: 0.86

In your example, x is a symbolic (== slow) variable. If you define your 
polynomial ring first things are much faster.

Martin

-- 
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_www: http://www.informatik.uni-bremen.de/~malb
_jab: [EMAIL PROTECTED]


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to