MATLAB Answers

error in computing atanh

52 views (last 30 days)
When computing atanh(3.1) in R2018.a and R2020.a the complex part has positive sign.
When computing in fortran (and Mathematica) the result is negative.

Accepted Answer

David Goodmanson
David Goodmanson on 13 Feb 2021
Edited: David Goodmanson on 13 Feb 2021
Hello Francisco,
The imaginary part is i*pi/2, so the two answers are a+i*pi/2 and a-i*pi/2, where a is real. Both answers are equally valid, so unless an answer is violating some prearranged standard set by the particular software invoked, there is not an error. Note that
tanh(a+i*b) = tanh(a+i*b+i*n*pi)
so there is an ambiguity modulo i*pi in the atahh function..
Francisco Peñuñuri
Francisco Peñuñuri on 13 Feb 2021
I agree with you. Still, is somehow awkward that sqrt(4) gives the principal value (regardless if this is positive or negative) while atanh(3.1) does not. I will accept the answer.
Thank you very much.

Sign in to comment.

More Answers (0)


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!