GNOME Bugzilla – Bug 759169
Define tangent, inverse trigonometric functions and hyperbolic functions for complex arguments
Last modified: 2016-10-19 12:36:18 UTC
sin and cos work for complex arguments but non of the other trig functions do
When gnome-calculator was ported to mpfr in commit 0e863eeb12 the definition of tan was changed from returning sin/cos to using mpfr's tan one the real component. The inverse trig functions where and the hyperbolic functions were also changed from using explicit formulas that worked for complex numbers to using specific functions in mpfr and so were broken for complex numbers. As there is no commit message for commit 0e863eeb12 it's hard to know the reasons for this. I think the best plan is to use the following formulas when there are complex arguments tan(z)=sin(z)/cos(z) tanh(z)=i*tan(i*z) cosh(z)=cos(i*z) sinh(z)=-i*sin(i*z) asin(z)=-i*ln(i*z+sqrt(1-z*z)) acos(z)=-i*ln(z+sqrt(z*z-1)) atan(z)=i*ln((i+z)/(i-z))/2 asinh(z)=-i*asin(i*z) acosh(z)=-i*acos(z) atanh(z)=i*atan(i*z) and add some tests for these functions with complex arguments. I might have time to do this sometime over Christmas or early in the new year.
Having spent some time reading the MPFR documentation and thinking about how to implement the inverse trig functions without losing precision or overflowing the intermediate results I thought ‘surely someone has done this before’ and of course they have. Using MPC¹ (a libray for complex numbers built on top of MPFR) would be the best way to fix this - see bug 759439. ¹http://www.multiprecision.org/index.php?prog=mpc
@Philip: we have moved to MPC thanks to your patch from bug 759439, and the functions seem to be supported now (implemented using mpc), so I think we can close this as fixed, or did I miss something?
Hi Robert, yes I think it should be fine to close this, using MPC should take care of it.