Skip to content

Polylogarithm and assorted functions #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/polylog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ function Dbeta(s::Number)
β = 4.0^(-s) * ( zeta(s,0.25) - zeta(s,0.75) )
end

function polylog_zeta(s::Number, z::Number, accuracy=1.0e-18)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the accuracy argument isn't being used

# compute using the Hurwitz-zeta function identity
twopi = 2π
x = im * (log(complex(-z)) / twopi)
ss = 1-s
ip = im^ss
return ( gamma(ss)/twopi^(ss) ) * (ip * zeta(ss, 0.5-x) + conj(ip) * zeta(ss, 0.5+x))
end


function polylog_direct(s::Number, z::Number, accuracy=1.0e-18)
# calculate using direct definition
if abs(z) > 1 || ( abs(z) ≈ 1 && real(s) <= 2)
Expand Down Expand Up @@ -201,8 +211,16 @@ function polylog_series_mu(s::Number, z::Number, accuracy=1.0e-18)
else
error("Should not get this case")
end

# should have a case in here for when s is close to a real, positive integer
# seed Wood 9.4
# elseif abs(s - round(real(s))) < 0.01 # not sure where the right cut off is


# could also use Wood 14.1 (square formula) to extend the range over which we sum directly - maybe???

else
# equivalent of Crandalls 1.4 for s non-integer
# equivalent of Crandalls 1.4 for s non-integer, Wood (9.3)
total = gamma(1-s) * (-μ)^(s-1)
# println(" μ=$μ, total = $total")
tmp = 1
Expand Down
6 changes: 4 additions & 2 deletions test/polylog_test2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ for line in eachline(f)
z = parse(Float64, v[3]) + im*parse(Float64, v[4])
L = parse(Float64, v[5]) + im*parse(Float64, v[6])
L2 = SF.polylog(s,z,1.0e-18)
diff = L - L2
L3 = SF.polylog_zeta(s,z)
diff = L - L2
diff3 = L - L3
rel_diff = complex(real(diff)/real(L), imag(diff)/imag(L))

push!(S, s)
Expand All @@ -42,7 +44,7 @@ for line in eachline(f)
push!(rel_errors, rel_diff)

# println(" L = $L, L2 =$L2, diff = $diff, \t\t rel diff = $rel_diff")
println(" s=$s, z=$z, |error|=$(ceil(log10(abs(diff))))")
println(" s=$s, z=$z, |error|=$(ceil(log10(abs(diff)))), |error3|=$(ceil(log10(abs(diff3))))")
end
end

Expand Down