Skip to content

Commit 5d33031

Browse files
authored
Fix zeta sign flipping in some input regions (#420) (#422)
1 parent 2cbb4ae commit 5d33031

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/gamma.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ function _zeta(s::ComplexOrReal{Float64})
439439
lg = loggamma(1 - s)
440440
rehalf = real(s)*0.5
441441
return zeta(1 - s) * exp(lg + absim*halfπ + s*log2π) * inv2π * Complex(
442-
sinpi(rehalf), copysign(cospi(rehalf), imag(s))
442+
sinpi(rehalf), flipsign(cospi(rehalf), imag(s))
443443
)
444444
else
445445
return zeta(1 - s) * gamma(1 - s) * sinpi(s*0.5) * twoπ^s * invπ

test/gamma.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ end
262262
@test 1e-10 > relerr(zeta(.4 + 4053.0im), -0.1248993234383550+0.9195498409364987im)
263263
@test 1e-13 > relerr(zeta(.4 + 12.01im), 1.0233184799021265846512208845-0.8008078492939259287905322251im)
264264
@test zeta(.4 + 12.01im) == conj(zeta(.4 - 12.01im))
265+
266+
# issue #420
267+
@test zeta(-2+13im) conj(zeta(-2-13im)) -0.30019019877262619754737023564024299182018857012958761814433485-5.5583626885487917197617298283836431070419020764882132809770386im
268+
@test zeta(-6+13im) conj(zeta(-6-13im)) 133.4764526350263089084083707864441932569167866714712267139316498-54.15465727586582149098585229287107039070546786014930791081909684im
269+
@test 1e-12 > relerr(zeta(-2+13im, 3), 2.3621038290867825837364823054-3.9497600485207119519185591345im)
270+
@test 1e-12 > relerr(zeta(-2-13im, 3), 2.3621038290867825837364823054+3.9497600485207119519185591345im)
265271
end
266272

267273
@testset "logabsbinomial" begin

0 commit comments

Comments
 (0)