diff --git a/src/Li2.jl b/src/Li2.jl index b49bd70..d2032a9 100644 --- a/src/Li2.jl +++ b/src/Li2.jl @@ -102,6 +102,26 @@ function li2_approx(u::ComplexF64)::ComplexF64 end +# series expansion of Li2(z) for |z| <= 1 and Re(z) <= 0.5 +# in terms of u = -log(1-z) +function li2_approx(u::Complex{T})::Complex{T} where T + u2 = u*u + c0 = inv(4*big(pi)^2) + p = u2*c0^2 + sum = one(T)/72 + + for n in 2:typemax(Int64) + old_sum = sum + sgn = iseven(n) ? -1 : 1 + sum += sgn*p/(2*n + 1)*zeta(2*n, T) + sum == old_sum && break + p *= u2*c0 + end + + u + u2*(-one(T)/4 + 2*u*sum) +end + + """ reli2(x::Real) diff --git a/test/Li2.jl b/test/Li2.jl index ae0def7..d2dfbb0 100644 --- a/test/Li2.jl +++ b/test/Li2.jl @@ -4,6 +4,8 @@ setprecision(BigFloat, MAX_BINARY_DIGITS) do ep = 10*eps(BigFloat) + # @todo(alex): test imaginary part, too + test_function_on_data(z -> real(PolyLog.li2(z)), real_data, ep, ep) test_function_on_data(PolyLog.reli2, real_data, ep, ep) end