Polylogarithm function and related special functions and sequences.
Author mroughan
8 Stars
Updated Last
5 Months Ago
Started In
August 2020



Build Status Coverage

This implements the Polylogarithm and some related functions that were needed (Harmonic numbers, Stieltjes constants, and Bernoulli numbers and polynomials, and Euler numbers).

The code is aimed at calculating Li_s(z) for all (complex) s and z.

This is still a little experimental, but there is a fairly large test set that all works nicely.

Note that the aimed for accuracy is 1.0e-12 relative error, but that occasional errors as large as 1.0e-11 have been seen.


  • polylog(s, z) the polylogarithm function

  • bernoulli(n) Provides the first 59 Bernoulli numbers as exact rationals

  • bernoulli(n,x) Provides the Bernoulli polynomials

  • euler(n) Provides the first 61 Euler numbers as BigInt

  • harmonic(n) Provides the Harmonic numbers

  • harmonic(n,r) Provides the generalised Harmonic numbers

  • stieltjes(n) Provides the first 10 Stieltjes constants (see Abramowitz and Stegun, 23.2.5), also known as the generalized Euler-Mascheroni constants.

  • dirichlet_beta(z) Provides the Dirichlet beta function


julia> using Polylogarithms
julia> polylog(2.0, 1.0)

Details and Accuracy

Extended details of the algorithms being used here are provided at https://arxiv.org/abs/2010.09860.

Accuracy has been tested over a wide range of scenarios. It starts to falter for large $z$ and $\Re(s) > 8$.


According to naming conventions, this package should have been called Polylogarithm, but there is already an older package doing polylogarithms, https://github.com/Expander/polylogarithm but it's using C/CPP/Fortran bindings, and only appears to do s=2,3,4,5,6.

There is a new package PolyLog, which does some newer stuff for dilogarithms, so that might be for you if you care about that case.