These are chat archives for symengine/symengine

24th
Jan 2017
Mesut Karakoç
@mkarakoc
Jan 24 2017 16:48
%%time
import symengine as se
x = se.symbols('x')
ss = se.series(se.exp(-x), x, 0, 350).removeO()
ssCoeff = [ss.coeff(x,i) for i in range(350)]
#print(ssCoeff)

CPU times: user 5.03 s, sys: 4 ms, total: 5.03 s
Wall time: 5.06 s

%%time
import sympy as sym
x = sym.symbols('x')
ss = sym.series(sym.exp(-x), x, 0, 350).removeO()
ssCoeff = sym.poly(ss, x).coeffs()
ssCoeff.reverse()
#print(ssCoeff)

CPU times: user 4.32 s, sys: 12 ms, total: 4.34 s
Wall time: 4.41 s

These codes are giving almost same benchmark times. How can I benefit from symengine's speed in this case?

Isuru Fernando
@isuruf
Jan 24 2017 17:11
@mkarakoc, use
import symengine as se
x = se.symbols('x')
ss = se.series(se.exp(-x), x, 0, 350, method='symengine', removeO=True)
ssCoeff = sym.poly(ss, sym.symbols("x")).coeffs()
ssCoeff.reverse()
This should be fixed to give a symengine object by default

SymEngine

CPU times: user 824 ms, sys: 16 ms, total: 840 ms
Wall time: 835 ms

SymPy

CPU times: user 19.9 s, sys: 116 ms, total: 20 s
Wall time: 20.1 s
Isuru Fernando
@isuruf
Jan 24 2017 17:20
SymEngine compiled with Flint, same code
CPU times: user 116 ms, sys: 4 ms, total: 120 ms
Wall time: 118 ms
Mesut Karakoç
@mkarakoc
Jan 24 2017 17:30

I guess "true" should be "True"?
SymEngine

CPU times: user 2.27 s, sys: 20 ms, total: 2.29 s
Wall time: 2.32 s

It is 2x faster, now.

Isuru Fernando
@isuruf
Jan 24 2017 17:32
yes. I corrected the code
Did you compile symengine in Release mode?
Mesut Karakoç
@mkarakoc
Jan 24 2017 17:34
Relase mode means what? Latest version of symengine?
Isuru Fernando
@isuruf
Jan 24 2017 17:34
Did you compile symengine from source? If so what are the options you gave to cmake?
Mesut Karakoç
@mkarakoc
Jan 24 2017 17:35
No, I did not. Because, I am using symengine on SMC (sagemathcloud).
Isuru Fernando
@isuruf
Jan 24 2017 17:36
Ah, let me try that
Mesut Karakoç
@mkarakoc
Jan 24 2017 17:39

symengine in julia.

@time begin
    import SymEngine
    const se = SymEngine
    x = se.symbols("x")
    ss = se.series(se.exp(-x), x, 0, 350)
    print()
end

0.262122 seconds (99.04 k allocations: 3.781 MB)

I guess, I will try to go with Julia but I need to learn Julia. :smile:

6.327315 seconds (374.87 k allocations: 142.408 MB, 0.43% gc time)

for 5000 terms.

Isuru Fernando
@isuruf
Jan 24 2017 17:41
This must be the sympy overhead
In symengine.py, the expression is converted to a sympy expression
since we don't have much support for series in symengine.py
Christopher Rackauckas
@ChrisRackauckas
Jan 24 2017 17:44

I guess, I will try to go with Julia but I need to learn Julia. :smile:

It's a good option :smile:

Mesut Karakoç
@mkarakoc
Jan 24 2017 17:45
So, is it faster in Julia because the expression are not converted a sympy expression?
Isuru Fernando
@isuruf
Jan 24 2017 17:47
yes, let me give you an example to avoid that
import symengine as se
def series(expr, var, terms):
    t = [0]*terms
    ex = expr
    c = se.Integer(1)
    for i in range(terms):
        c *= (i+1)
        t[i] = ex.subs({var: 0})/c
        ex = ex.diff(var)
    return t

x = se.symbols('x')
ssCoeff = series(se.exp(-x), x, 350)
This runs in 148 ms in SMC
Mesut Karakoç
@mkarakoc
Jan 24 2017 17:57
Ok. Thanks! But then, I wonder why you do not do this in symengine.py by default...
Isuru Fernando
@isuruf
Jan 24 2017 17:58
we should. symengine.py needs some love

I didn't know SMC had julia.

using SymEngine
using DifferentialEquations

works

Mesut Karakoç
@mkarakoc
Jan 24 2017 18:00
:smile:
Christopher Rackauckas
@ChrisRackauckas
Jan 24 2017 18:00
that works on SMC?
Isuru Fernando
@isuruf
Jan 24 2017 18:00
yes
Christopher Rackauckas
@ChrisRackauckas
Jan 24 2017 18:03
huh, good to know
(I would've thought there would be repo size issues)
Isuru Fernando
@isuruf
Jan 24 2017 18:11
I think the preinstalled software are systemwide installations
Christopher Rackauckas
@ChrisRackauckas
Jan 24 2017 18:12
oh, it's preinstalled?
Isuru Fernando
@isuruf
Jan 24 2017 18:12
yes
Christopher Rackauckas
@ChrisRackauckas
Jan 24 2017 18:24
That's pretty cool :smile:
Shikhar Jaiswal
@ShikharJ
Jan 24 2017 18:35
@isuruf Can you stop the current build on #1178? I'd like to update it once and then synchronise it.
Isuru Fernando
@isuruf
Jan 24 2017 18:38
@ShikharJ, done
Shikhar Jaiswal
@ShikharJ
Jan 24 2017 18:38
Thanks.
Mesut Karakoç
@mkarakoc
Jan 24 2017 20:31
mpmath.polyroots(ctx, coeffs, maxsteps=50, cleanup=True, extraprec=10, error=False)
Computes all roots (real or complex) of a given polynomial.
is there an equivalent of polyroots in symengine?