[SciPy-User] polylogarithm?

Ralf Gommers ralf.gommers at googlemail.com
Sun Sep 18 06:54:53 EDT 2011


On Fri, Sep 16, 2011 at 7:24 PM, Fredrik Johansson <
fredrik.johansson at gmail.com> wrote:

> On Fri, Sep 16, 2011 at 7:11 PM, Ralf Gommers
> <ralf.gommers at googlemail.com> wrote:
> >
> >
> > On Thu, Sep 15, 2011 at 8:09 AM, Johann Cohen-Tanugi
> > <johann.cohentanugi at gmail.com> wrote:
> >>
> >> hi there, any chance for a polylog implementation in scipy.special? I
> >> know it is there in mpmath, but I thought I would ask anyway.
> >>
> > If someone (you?) contributes a patch, that would be a great addition to
> > scipy.special imho. mpmath is nice, but it doesn't understand ndarrays
> and
> > is way too slow when you want to use the polylog for something like
> fitting
> > Bose-Einstein or Fermi-Dirac distributions.
> >
> > It looks like the implementation in mpmath is quite clean and could
> provide
> > a starting point for a Cython/C version.
>
> Maybe it's still too slow, but mpmath.fp.polylog is about 100 times
> faster than the multiprecision version (and usually gives nearly full
> double-precision accuracy anyway).
>

Thanks for the tip.

In [2]: %timeit mpmath.polylog(2, 10)
1000 loops, best of 3: 1.77 ms per loop

In [3]: %timeit mpmath.fp.polylog(2, 10)
10000 loops, best of 3: 66.6 us per loop

That's much better. Still a little slow for use in curve fitting perhaps,
but when wrapping it with numpy.vectorize it should be useable on reasonable
size ndarrays.

Ralf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110918/c162ca24/attachment.html>


More information about the SciPy-User mailing list