[docs]classpolylog(Function):r""" Polylogarithm function. For :math:`|z| < 1` and :math:`s \in \mathbb{C}`, the polylogarithm is defined by .. math:: \operatorname{Li}_s(z) = \sum_{n=1}^\infty \frac{z^n}{n^s}, where the standard branch of the argument is used for :math:`n`. It admits an analytic continuation which is branched at :math:`z=1` (notably not on the sheet of initial definition), :math:`z=0` and :math:`z=\infty`. The name polylogarithm comes from the fact that for :math:`s=1`, the polylogarithm is related to the ordinary logarithm (see examples), and that .. math:: \operatorname{Li}_{s+1}(z) = \int_0^z \frac{\operatorname{Li}_s(t)}{t} \mathrm{d}t. The polylogarithm is a special case of the Lerch transcendent: .. math:: \operatorname{Li}_{s}(z) = z \Phi(z, s, 1) See Also ======== zeta, lerchphi Examples ======== For :math:`z \in \{0, 1, -1\}`, the polylogarithm is automatically expressed using other functions: >>> from sympy import polylog >>> from sympy.abc import s >>> polylog(s, 0) 0 >>> polylog(s, 1) zeta(s) >>> polylog(s, -1) dirichlet_eta(s) If :math:`s` is a negative integer, :math:`0` or :math:`1`, the polylogarithm can be expressed using elementary functions. This can be done using expand_func(): >>> from sympy import expand_func >>> from sympy.abc import z >>> expand_func(polylog(1, z)) -log(z*exp_polar(-I*pi) + 1) >>> expand_func(polylog(0, z)) z/(-z + 1) The derivative with respect to :math:`z` can be computed in closed form: >>> polylog(s, z).diff(z) polylog(s - 1, z)/z The polylogarithm can be expressed in terms of the lerch transcendent: >>> from sympy import lerchphi >>> polylog(s, z).rewrite(lerchphi) z*lerchphi(z, s, 1) """@classmethoddefeval(cls,s,z):ifz==1:returnzeta(s)elifz==-1:returndirichlet_eta(s)elifz==0:return0deffdiff(self,argindex=1):s,z=self.argsifargindex==2:returnpolylog(s-1,z)/zraiseArgumentIndexErrordef_eval_rewrite_as_lerchphi(self,s,z):returnz*lerchphi(z,s,1)def_eval_expand_func(self,**hints):fromsympyimportlog,expand_mul,Dummy,exp_polar,Is,z=self.argsifs==1:return-log(1+exp_polar(-I*pi)*z)ifs.is_Integerands<=0:u=Dummy('u')start=u/(1-u)for_inrange(-s):start=u*start.diff(u)returnexpand_mul(start).subs(u,z)returnpolylog(s,z)##################################################################################################### HURWITZ GENERALIZED ZETA FUNCTION #####################################################################################################