question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

implement polylog for arbitrarily large arguments.

See original GitHub issue

We’ve been running into an issue over at PlasmaPy, where when we try to use polylog to calculate the Fermi Integral we hit an implementation error:

import numpy as np
import mpmath
mpmath.polylog(1 + 0.5, -np.exp(3.89))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/anaconda3/lib/python3.6/site-packages/mpmath/ctx_mp_python.py", line 1016, in f_wrapped
    retval = f(ctx, *args, **kwargs)
  File "/home/user/anaconda3/lib/python3.6/site-packages/mpmath/functions/zeta.py", line 482, in polylog
    return polylog_general(ctx, s, z)
  File "/home/user/anaconda3/lib/python3.6/site-packages/mpmath/functions/zeta.py", line 449, in polylog_general
    raise NotImplementedError("polylog for arbitrary s and z")
NotImplementedError: polylog for arbitrary s and z

Would it be possible to implement polylog for large arguments? For our purposes it is fine to restrict it to an index of 1.5 for now.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
grozincommented, Sep 25, 2018

Can this help? https://arxiv.org/abs/1809.07084 Ordinary polylogarithms are a particular case of harmonic polylogarithms. And this paper provides a method to reduce (analytically) polylogarithms of any real argument to combinations of polylogarithms of arguments between 0 and $\sqrt{2}-1$. At least up to weight 8.

1reaction
fredrik-johanssoncommented, Aug 4, 2018

Yes, it would be possible. The decomposition in terms of the Hurwitz zeta function could be used for this. Here is code that should work at least in your case:

def polylogb(s,z):
    s = mpmathify(s)
    z = mpmathify(z)
    v = 1-s
    y = log(-z)/(2*pi*j)
    return gamma(v)*(1j**v*zeta(v,0.5+y) + 1j**-v*zeta(v,0.5-y))/(2*pi)**v

>>> polylogb(1+0.5, -exp(3.89))
mpc(real='-6.2729922293118188', imag='0.0')

Beware that there could be some ranges where this formula loses precision.

Read more comments on GitHub >

github_iconTop Results From Across the Web

implement polylog for arbitrarily large arguments. #390
We've been running into an issue over at PlasmaPy, where when we try to use polylog to calculate the Fermi Integral we hit...
Read more >
Polylogarithm
In mathematics, the polylogarithm is a special function Lis(z) of order s and argument z. ... arbitrary complex order s and for all...
Read more >
The Computation of Polylogarithms
The polylogarithm function, Lip(z), is defined, and a number of algorithms are derived for its computation, valid in different ranges of its real...
Read more >
Zeta functions, L-series and polylogarithms
The reflection formula for ℜ(s)<0 is implemented in some cases. ... zetazero() supports arbitrarily large n and arbitrary precision: > ...
Read more >
[2010.09860] The Polylogarithm Function in Julia
In this paper we present an algorithm for calculating polylogarithms for both complex parameter and argument and evaluate it thoroughly in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found