File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change 174
174
end
175
175
176
176
@testset " zeta" begin
177
+ # Riemann zeta function
178
+ # https://en.wikipedia.org/wiki/Particular_values_of_the_Riemann_zeta_function
177
179
@test zeta (0 ) ≈ - 0.5
180
+ # Positive integers
181
+ @test isnan (zeta (1 ))
178
182
@test zeta (2 ) ≈ pi ^ 2 / 6
179
183
@test zeta (Complex {Float32} (2 )) ≈ zeta (2 )
184
+ @test zeta (3 ) ≈ 1.2020569031595942 # Apéry's constant
180
185
@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 (- 2 n) == 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
184
198
@test isnan (zeta (NaN ))
185
199
@test isnan (zeta (1.0e0 ))
186
200
@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. )
189
208
end
190
209
191
210
# (compared to Wolfram Alpha)
You can’t perform that action at this time.
0 commit comments