Skip to content

Commit f5adefc

Browse files
committed
test: add more test for zeta(s)
1 parent 18cef75 commit f5adefc

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

test/gamma.jl

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,37 @@
174174
end
175175

176176
@testset "zeta" begin
177+
# Riemann zeta function
178+
# https://en.wikipedia.org/wiki/Particular_values_of_the_Riemann_zeta_function
177179
@test zeta(0) -0.5
180+
# Positive integers
181+
@test isnan(zeta(1))
178182
@test zeta(2) pi^2/6
179183
@test zeta(Complex{Float32}(2)) zeta(2)
184+
@test zeta(3) 1.2020569031595942 # Apéry's constant
180185
@test zeta(4) pi^4/90
181-
@test zeta(1,Float16(2.)) zeta(1,2.)
182-
@test zeta(1.,Float16(2.)) zeta(1,2.)
183-
@test zeta(Float16(1.),Float16(2.)) zeta(1,2.)
186+
@test zeta(6) pi^6/945
187+
@test zeta(8) pi^8/9450
188+
# Negative integers
189+
for n in 1:10
190+
# trivial zeros
191+
@test zeta(-2n) == 0
192+
end
193+
@test zeta(-1) -1/12
194+
@test zeta(-3) 1/120
195+
@test zeta(-5) -1/252
196+
@test zeta(-7) 1/240
197+
# NaN
184198
@test isnan(zeta(NaN))
185199
@test isnan(zeta(1.0e0))
186200
@test isnan(zeta(1.0f0))
187-
@test isnan(zeta(complex(0,Inf)))
188-
@test isnan(zeta(complex(-Inf,0)))
201+
@test isnan(zeta(complex(0, Inf)))
202+
@test isnan(zeta(complex(-Inf, 0)))
203+
204+
# Hurwitz zeta function
205+
@test zeta(1, Float16(2.)) zeta(1, 2.)
206+
@test zeta(1., Float16(2.)) zeta(1, 2.)
207+
@test zeta(Float16(1.), Float16(2.)) zeta(1, 2.)
189208
end
190209

191210
#(compared to Wolfram Alpha)

0 commit comments

Comments
 (0)