(* Copyright G. Cvetic, Sept. 2012, Unic.Tecnica Federico Santa Maria *)
(* This Mathematica routine is meant to be freely distributed *)
(*---------------------------------------------*)
(* The routine calculates polylog[nu, z] (=Li_{nu}(z)) for nu real and z complex. *)
(* Mathematica (9.0.1) PolyLog[nu,z](=Li_{nu}(z)) becomes unstable for |z|>10^8. *)
(* polylog[nu,z] uses at large |z| an identity [given in A.Erdelyi, W.Magnus et al., 1953, Higher transcendental functions Vol.1 (New York, McGraw-Hill)] which relates Li_{nu}(z) with Li_{nu}(1/z) *)
(* A.Erdelyi et al. use the notation with Lerch Phi function: Li_{nu}(z)= z Phi(z,nu,1)=F(z,nu) *)

  (*-------------------------------------------------------------------*)
  (* This program was first used in the calculations performed for the paper J.Phys.,G39, 065005 (2012) by G.Cvetic and A.V.Kotikov, in the calculation of {tilde A}_{nu}(Q^2) and A_{nu}(Q^2) for nu general noninteger, in analytic QCD models *)

  (*---------------------------------------------------*)
  (* polylog[nu,z]= coincides with Mathematica (9.01.) PolyLog[nu,z] for |z|< 10^8; Mathematica (9.0.1) PolyLog[nu,z] becomes unstable for |z|>10^8, while polylog[nu,z] remains stable and correct even for |z|>10^8 *)

(* In Mathematica 10.0.1 this problem is solved, PolyLog[nu,z] there gives even for very large values of |z| equal results as the present routine polylog[nu,z] *)
(*--------------------------------------------------_*)
GenLiaLOW[nup_,zp_]:=PolyLog[-nup,-zp];
GenLiaHIGH[nup_,zp_]:=If[Arg[zp] >= 0, - Exp[I nup Pi] PolyLog[-nup,-1/zp] + ((2 Pi)^(-nup)) Exp[I Pi nup/2] Zeta[1 + nup, (Log[Abs[1/zp]] + I Arg[-1/zp])/(2 Pi I)]/Gamma[-nup], - Exp[-I nup Pi] PolyLog[-nup,-1/zp] + ((2 Pi)^(-nup)) Exp[-I Pi nup/2] Zeta[1 + nup, -(Log[Abs[1/zp]] + I Arg[-1/zp])/(2 Pi I)]/Gamma[-nup]];

GenLia[nup_,zp_]:=If[Abs[zp]<=1,GenLiaLOW[nup,zp],GenLiaHIGH[nup,zp]];

polylog[nup_,zp_]:=If[Element[nup,Integers] && nup<2, PolyLog[nup,zp],GenLia[-nup,-zp]];

  (*--------------------------------------------*)
(* When in polylog[nu,z] nu is an integer, e.g., nu=-2, do not use nu=-2., but nu=-2: polylog[-2,z] evaluates fine; while polylog[-2.,z] gives indefinite expression *)


 
