These are chat archives for symengine/symengine

17th
Dec 2015
Isuru Fernando
@isuruf
Dec 17 2015 03:46
@certik, do we want to have Pow(Polynomial, Integer) or should it be automatically expanded to a Polynomial?
Isuru Fernando
@isuruf
Dec 17 2015 03:58
@certik, you are right, if integer is negative we need to keep it as a Pow.
Ondřej Čertík
@certik
Dec 17 2015 15:20
Right, and similarly for Pow(Series, Integer), where we have a choice --- we can either automatically expand the series, say 1/1-x=1+x+x^2+..., or keep it. If we want to hook this up into our general add function, we can use multiple dispatch to do this. I am not sure if we want to do it or not at the moment, but either way, we want Series and Polynomial (perhaps more specific like integer polynomial or PiranhaPolynomial, FlintPolynomial, ...) and I think we can just treat it as a special function in SymEngine for now, i.e. that Add(Polynomial, Symbol) would just keep it as is. Later we can figure out if we want it to automatically combine to Polynomial or not.
Ondřej Čertík
@certik
Dec 17 2015 15:26

Does anybody have access to Mathematica? In there, if you do

Series[Exp[x], {x, 0, 5}]

it returns SeriesData[x, 0, {1, 1, 1/2, 1/6, 1/24, 1/120}, 0, 6, 1] (https://reference.wolfram.com/language/ref/SeriesData.html). So what happens if you do

Series[Exp[x], {x, 0, 5}] + x

or if you do Series[Exp[x], {x, 0, 5}]^2 or 1/Series[Exp[x], {x, 0, 5}]?

@rwst I am thinking that we should have several representations for Series. Here is how Mathematica does it: https://reference.wolfram.com/language/tutorial/TheRepresentationOfPowerSeries.html, and that's probably just a list internally. I would like to have several different series implementations in SymEngine, so that we can try to optimize each out as much as we can, and allow the user to choose. So we can have one based on Piranha that you are working on, one similar to Mathematica, and one based on Flint (for univariate). That way if somebody figures out a better data structure + algorithm in the future, we can just add it in, along side our other implementations.
Ralf Stephan
@rwst
Dec 17 2015 16:17
The sqrt(1-x^3) is interesting. Puiseux series can be a list too if the common denominator of the exponent is known. I'm wondering if there are series where that is not the case. If not that would simplify a lot.
BTW is the symengine.py PR still missing something?
Isuru Fernando
@isuruf
Dec 17 2015 16:37
@certik, Mathematica simplifies all of them
In[1]:= Series[Exp[x], {x, 0, 5}] + x

Out[1]= SeriesData[x, 0, {1, 2, 
Rational[1, 2], 
Rational[1, 6], 
Rational[1, 24], 
Rational[1, 120]}, 0, 6, 1]

In[2]:= Series[Exp[x], {x, 0, 5}]^2

Out[2]= SeriesData[x, 0, {1, 2, 2, 
Rational[4, 3], 
Rational[2, 3], 
Rational[4, 15]}, 0, 6, 1]

In[3]:= 1/Series[Exp[x], {x, 0, 5}]

Out[3]= SeriesData[x, 0, {1, -1, 
Rational[1, 2], 
Rational[-1, 6], 
Rational[1, 24], 
Rational[-1, 120]}, 0, 6, 1]
Isuru Fernando
@isuruf
Dec 17 2015 16:42
What's interesting is the following which neither Sage nor SymPy does
In[7]:= 1/Series[Exp[x], {x, 0, 5}] + Sin[x] + x^7

Out[7]= SeriesData[x, 0, {1, 0, 
Rational[1, 2], 
Rational[-1, 3], 
Rational[1, 24]}, 0, 6, 1]
Ralf Stephan
@rwst
Dec 17 2015 16:46
@isuruf : Pari does it:
? 1/exp(x) + sin(x) + x^7
%1 = 1 + 1/2*x^2 - 1/3*x^3 + 1/24*x^4 + 1/720*x^6 + 2519/2520*x^7 + 1/40320*x^8 + 1/3628800*x^10 - 1/19958400*x^11 + 1/479001600*x^12 + 1/87178291200*x^14 - 1/653837184000*x^15 + 1/20922789888000*x^16 + O(x^17)
Isuru Fernando
@isuruf
Dec 17 2015 16:47
@certik, I'm looking at implementing a Series class right now. I'm subclassing Number for Series right now, because that is the closest class to Series we have right now in SymEngine in terms of functionality. (Immediate multiplication, addition, subtraction, etc.)
@rwst, I meant, 1/exp(x) already being a series.
Isuru Fernando
@isuruf
Dec 17 2015 16:57
Does pari have symbolic manipulation capabilities? If not the example wouldn't make sense
Ralf Stephan
@rwst
Dec 17 2015 18:44
@isuruf Pari has only series but goes quite far with that. It makes sense IMO in that they decided from the start not to support general expressions but series. Pari's strength however is number theory, and they don't need general expressions for that.
What you can do in Pari is put a general expression on the r.h.s. and a symbol on the left but that's all.