Hi,
I've discovered Sage two days ago... I try to use it to compute
integral and to play with polynomials... but my program seems to be
very slow compared with swiginac library... Is that normal ?
Here is times to compute 10 double integrals (I repeat tests 3 times
and I keep the min time) :
* with swiginac : 0.002506
* with sympy : 0.554952
* with sage : 1.101324
###################################
##
## Tests with sympy and swigianc
##
###################################
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import sympy
import swiginac
def integSympy():
x1 = sympy.Symbol("x1")
x2 = sympy.Symbol("x2")
f = 3*x1*x2 + x1 - 2*x2 + 4
for _ in range(10):
sympy.integrate(f, (x2, -1, 1), (x1, -1, 1))
return 0
def integSwiginac():
x1 = swiginac.symbol("x1")
x2 = swiginac.symbol("x2")
f = 3*x1*x2 + x1 - 2*x2 + 4
for _ in range(10):
swiginac.integral(x2, -1, 1, swiginac.integral(x1, -1, 1,
f)).eval_integ()
return 0
if __name__ == "__main__":
from timeit import Timer
t = Timer('integSympy()', 'from __main__ import integSympy')
print "execution with sympy : %f" % min(t.repeat(3, 1))
t = Timer('integSwiginac()', 'from __main__ import integSwiginac')
print "execution with swiginac : %f" % min(t.repeat(3, 1))
sys.exit(0)
###################################
##
## Tests with sage
##
###################################
#!/usr/bin/env sage-python
# -*- coding: utf-8 -*-
import sys
from sage.all import *
def integ():
variables = var('x1,x2')
f = 3*x1*x2 + x1 - 2*x2 + 4
for _ in range(10):
integrate(integrate(f, x2, -1, 1), x1, -1, 1)
return 0
if __name__ == "__main__":
from timeit import Timer
t = Timer('integ()', 'from __main__ import integ')
print "execution with sage : %f" % min(t.repeat(3, 1))
sys.exit(0)
Thanks
--~--~---------~--~----~------------~-------~--~----~
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-forum
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---