-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Complex atanh is inaccurate near singularities #55266
Labels
domain:complex
Complex numbers
domain:maths
Mathematical functions
kind:bug
Indicates an unexpected problem or unintended behavior
Comments
giordano
added
kind:bug
Indicates an unexpected problem or unintended behavior
domain:maths
Mathematical functions
domain:complex
Complex numbers
labels
Jul 26, 2024
KristofferC
pushed a commit
that referenced
this issue
Aug 14, 2024
lazarusA
pushed a commit
to lazarusA/julia
that referenced
this issue
Aug 17, 2024
…#55268) fixes JuliaLang#55266, and use `inv(z)` rather than `1/z` and use `muladd` in a couple places. --------- Co-authored-by: Mosè Giordano <giordano@users.noreply.github.com>
KristofferC
pushed a commit
that referenced
this issue
Sep 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
domain:complex
Complex numbers
domain:maths
Mathematical functions
kind:bug
Indicates an unexpected problem or unintended behavior
real(atanh(1+y*im))
should be asymptotic tolog(2/abs(y))/2
for realy
asy
approches0
.For example, this suggests that
real(atanh(1+1e-200im))
should evaluate tolog(2/1e-200)/2=230.60508288968455
, but it currently evaluates to177.09910463306602
, which has no correct digits.This appears to be caused by a small positive perturbation,
ρ
, that is added to the imaginary part of the input in the atanh computationjulia/base/complex.jl
Lines 1040 to 1042 in 1dee000
julia/base/complex.jl
Lines 1067 to 1068 in 1dee000
so that
real(atanh(1+1e-200im))
in fact computeslog(2/ρ)=177.09910463306602
.This perturbation is suggested by Kahan 86, but as far as I can tell, it is not necessary in either of the places it is used, and in fact harms rather than helps accuracy when the real part of the input is
1
. It may be there to avoid division by 0 inatanh(1.0+0.0im)
, but the Julia implementation already handles this case with an explicit branch.For comparison, cpython computes the correct answer:
Version Info:
The text was updated successfully, but these errors were encountered: