Skip to content

Commit

Permalink
test real part of generalize li2(z)
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Oct 6, 2023
1 parent 92a5771 commit a9899dc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Li2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions test/Li2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a9899dc

Please sign in to comment.