Hi Shivam, On Sun, Mar 8, 2015 at 5:13 AM, Shivam Vats <[email protected]> wrote: > Hi > > Sympy currently lacks a class based representation for series expansions. > Though the current approach works well, it has its problems, like- all types > of > series are lumped under one name, issues with infinite series, etc.
And it is slow. > Moreover, such > an implementation, if successful, can also be ported to C++, which will be > much > faster. It should be done in SymPy first, it will speed it up a lot, as well as allow us to figure out the best design. Then we should translate to C++ to get additional speed. > Hence, I would like to give series expansion a class representation. > > There has been a lot of dicussion here : > https://groups.google.com/forum/#!searchin/sympy/series/sympy/hiRuIHa8ImA/JLOBsMr9yUcJ > > This approach builds on ring_series.py and Ondrej's implementation here > https://github.com/certik/sympy/blob/59492520b443ea5f0ef31fc018e9bc700b93b818/a.py > > is even faster than the existing one based on ring_series. It's a little bit faster, but I think that's just because I sort the dictionaries first: https://github.com/certik/sympy/blob/59492520b443ea5f0ef31fc018e9bc700b93b818/a.py#L114 This can be done easily in ring_series as well. The two approaches are equivalent, as far as I can tell. > > I found another approach here > https://github.com/sympy/sympy/wiki/UD-Sequences-and-formal-power-series-prototype > > which uses sequences to construct power series. There was an attempt to > follow > this approach in https://github.com/sympy/sympy/pull/7846 using formula > based > power series, but the PR is yet to be merged. How fast is that approach? > > How do the two approaches compare? What are the expectations from such a > class > based representation? I think we should use ring_series in a new Series class, and implement any missing features in ring_series as needed. See the other thread you cited above. I think this is the most optimal way to represent and implement series expansion. It's what Piranha uses (except that Piranha does some clever optimizations in C++, but the overall structure, i.e. a hashtable is the same). The only other way that I know of is to use some kind of a dense representation (polys can do dense representation too, but overall the sparse representation seems about as fast or faster for most problems). So I would however use sparse representation, i.e. ring_series. So just doing the above will provide a very fast implementation, and it seems to me that any other datastructure/design will only provide minor algorithmic speedup. Once this is done, we should implement this in C++ and use some of the tricks from Piranha, that will provide a good constant speedup. You can try to implement the Kronecker trick with packing the exponents in Python as well. That provides good speedup, but it's an additional complexity. Ondrej -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVAopPhwS0UXO-9mV%2B8s%2BxNtrbnOs_1MtadxoMOR6SShbw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
