gnuplot> print asinh(-1)
0.881373587019543
# asinh(-1) might be of the opposite sign...
gnuplot> print sinh(asinh(-1))
1.0
gnuplot> print sinh(-1*asinh(-1))
-1.0
Version 4.6 patch level 0
Ethan Merritt
2012-07-12
Ironically, the analogous bug was fixed over a year ago for sin/asin (Bug #2879772).
Apparently the same "fix" was also applied to the code for sinh/asinh even though it wasn't needed, thus breaking it rather than fixing it. So I think we can just revert that "fix".
thanks for the report
Ethan Merritt
2012-07-12
Ethan Merritt
2012-07-12
Bastiaan:
Could you have a look at this, revisiting your patch of May 2011?
Reverting it altogether would reintroduce the original problem, but the current code isn't correct either. Check for example
plot sinh(asinh(x)) / x # should equal 1 everywhere, right?
and
set xr [-10:10]; set yr [-10:10]; set cbr [-10:10]; set isosampl 50,50
set view map
splot '++' using 1:2:(imag((asin((sin( $1 + $2*{0,1} )))))) with pm3d
# should this really flip sign for different ranges of the real component?
Ethan Merritt
2012-07-12
Ethan Merritt
2012-07-12
I misread the but report. Sorry. I though the issue was asinh(x) for x with an imaginary component. That was the trigger for the earlier bug/fix that I referred to.
The specific case you give as an example is not a bug, since by definition asinh(x) > 0 for real x.
asinh(z) = ln( z + sqrt( z**2 + 1) )
Nevertheless there is a bug lurking here, so thank you for forcing me to look into these functions more deeply. I have attached a script that tests the various trig functions for complex input and output. It sets up a color map for the complex plane such that the resulting plots can be compared to the ones on wikipedia created using Mathematica:
http://en.wikipedia.org/wiki/Inverse_trigonometric_functions
http://en.wikipedia.org/wiki/Inverse_hyperbolic_function
http://en.wikipedia.org/wiki/Hyperbolic_function
The test script shows that asin(), sinh(), asinh() are working correctly, as are cosh(), acosh() and tanh(), atanh().
But acos() is broken. A fix is attached.
Prior to last year's fix, asin() and asinh() were also broken, as shown by running the test script though gnuplot version 4.4.0.
Ethan Merritt
2012-07-12
acos(z) returns incorrect values when imag(z) > 0
Ethan Merritt
2012-07-12
test script to exercise trig functions with complex input
Hans-Bernhard Broeker
2012-07-12
> since by definition asinh(x) > 0 for real x.
Huh? Surely you're joking. asin() is negative for negative arguments. It has to be.
Hans-Bernhard Broeker
2012-07-12
Bastian Märkisch
2012-07-12
Patch to sin and sinh, partially reverting the change of March 2011