Skip to content

Commit

Permalink
extend tests for eta function
Browse files Browse the repository at this point in the history
  • Loading branch information
Expander committed Oct 5, 2023
1 parent c705fce commit f02f039
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 19 deletions.
12 changes: 10 additions & 2 deletions src/Eta.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const MINUS_ETA_NEG = (
)

# returns Li(n,-1) = (2^(1 - n) - 1)*zeta(n)
function neg_eta(n::Integer, T=Float64)
function neg_eta(n::Integer, T)
if T == Float64
neg_eta_f46(n)
else
Expand Down Expand Up @@ -90,7 +90,15 @@ function neg_eta_f46(n::Integer)::Float64
end

function neg_eta_big(n::Integer)::BigFloat
if n == 1
if n < 0
if iseven(n)
BigFloat("0")
else
(exp2(1 - n) - one(BigFloat))*zeta_big(n)
end
elseif n == 0
BigFloat("-0.5")
elseif n == 1
-log(big(2))
else
(exp2(1 - n) - one(BigFloat))*zeta_big(n)
Expand Down
41 changes: 24 additions & 17 deletions test/Eta.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
@testset "eta" begin
@test PolyLog.neg_eta(-222) == 0.0
@test PolyLog.neg_eta(-221) == -Inf
@test PolyLog.neg_eta(-220) == 0.0
@test PolyLog.neg_eta(-219) == Inf
@test PolyLog.neg_eta(-218) == 0.0
@test PolyLog.neg_eta(-217) == -1.8184610414701105e306
@test PolyLog.neg_eta( -4) == 0.0
@test PolyLog.neg_eta( -3) == 1/8
@test PolyLog.neg_eta( -2) == 0.0
@test PolyLog.neg_eta( -1) == -0.25
@test PolyLog.neg_eta( 1) == -0.69314718055994531
@test PolyLog.neg_eta( 2) == -0.82246703342411322
@test PolyLog.neg_eta( 52) == -0.9999999999999998
@test PolyLog.neg_eta( 53) == -0.9999999999999999
@test PolyLog.neg_eta( 54) == -0.9999999999999999
@test PolyLog.neg_eta( 55) == -1.0
@test PolyLog.neg_eta( 56) == -1.0
@test PolyLog.neg_eta(-222, Float64) == 0.0
@test PolyLog.neg_eta(-221, Float64) == -Inf
@test PolyLog.neg_eta(-220, Float64) == 0.0
@test PolyLog.neg_eta(-219, Float64) == Inf
@test PolyLog.neg_eta(-218, Float64) == 0.0
@test PolyLog.neg_eta(-217, Float64) == -1.8184610414701105e306
@test PolyLog.neg_eta( -4, Float64) == 0.0
@test PolyLog.neg_eta( -3, Float64) == 1/8
@test PolyLog.neg_eta( -2, Float64) == 0.0
@test PolyLog.neg_eta( -1, Float64) == -0.25
@test PolyLog.neg_eta( 0, Float64) == -0.5
@test PolyLog.neg_eta( 1, Float64) == -0.69314718055994531
@test PolyLog.neg_eta( 2, Float64) == -0.82246703342411322
@test PolyLog.neg_eta( 52, Float64) == -0.9999999999999998
@test PolyLog.neg_eta( 53, Float64) == -0.9999999999999999
@test PolyLog.neg_eta( 54, Float64) == -0.9999999999999999
@test PolyLog.neg_eta( 55, Float64) == -1.0
@test PolyLog.neg_eta( 56, Float64) == -1.0

@test PolyLog.neg_eta(-2, BigFloat) == BigFloat("0")
@test PolyLog.neg_eta(-1, BigFloat) == (big(2)^2 - one(BigFloat))*PolyLog.zeta(-1, BigFloat)
@test PolyLog.neg_eta( 0, BigFloat) == BigFloat("-0.5")
@test PolyLog.neg_eta( 1, BigFloat) == -log(big(2))
@test PolyLog.neg_eta( 2, BigFloat) == (inv(big(2)) - one(BigFloat))*PolyLog.zeta(2, BigFloat)
end

0 comments on commit f02f039

Please sign in to comment.