does SYMENGINE have any effect on integration speed in sympy?

206 Views Asked by At

Using sympy 1.10.1 and latest symengine (all installed on Linux Manjaro using the package manager choosing latest versions), I noticed no difference in timing when using symegine vs. not.

Am I using it correctly? Or does symengine have no effect on symbolic integration at this time?

unset USE_SYMENGINE
>python
Python 3.10.5 (main, Jun  6 2022, 18:49:26) [GCC 12.1.0] on linux
from sympy import *
import timeit
x,k,a,b,n=symbols('x k a b n')
starttime=timeit.default_timer(); integrate(x**(-1+k)*(a+b*x**k)**n,x); timeit.default_timer()-starttime
Piecewise((log(x)/a, Eq(b, 0) & Eq(k, 0) & Eq(n, -1)), (a**n*x**k/k, Eq(b, 0)), ((a + b)**n*log(x), Eq(k, 0)), (log(a/b + x**k)/(b*k), Eq(n, -1)), (a*(a + b*x**k)**n/(b*k*n + b*k) + b*x**k*(a + b*x**k)**n/(b*k*n + b*k), True))

22.980282188999922
exit()

Now try again but set the environment variable to use symengine

>export USE_SYMENGINE=1
>python
Python 3.10.5 (main, Jun  6 2022, 18:49:26) [GCC 12.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import *
>>> x,k,a,b,n=symbols('x k a b n')
>>> import timeit
>>> starttime=timeit.default_timer(); integrate(x**(-1+k)*(a+b*x**k)**n,x); timeit.default_timer()-starttime
Piecewise((log(x)/a, Eq(b, 0) & Eq(k, 0) & Eq(n, -1)), (a**n*x**k/k, Eq(b, 0)), ((a + b)**n*log(x), Eq(k, 0)), (log(a/b + x**k)/(b*k), Eq(n, -1)), (a*(a + b*x**k)**n/(b*k*n + b*k) + b*x**k*(a + b*x**k)**n/(b*k*n + b*k), True))
22.583236744000033
>>> 
0

There are 0 best solutions below