[Mpc-discuss] mpc_sin and mpc_sinh slow cases

Joseph S. Myers joseph at codesourcery.com
Fri Dec 20 17:12:13 CET 2013

On Fri, 20 Dec 2013, Zimmermann Paul wrote:

> In the meantime I have improved the scheme for increasing precision: instead
> of adding log2(prec) each time, we now add prec/2. On my laptop, the above
> example goes from 36 seconds to 0.35 second now.

Thanks.  I note there are other loops following the log2(prec) approach, 
e.g. in mpc_acos, though I don't know if they are relevant to known 
slowness of such functions - but it looks plausible, for acos of 1 + 
tiny*i for example, where subtraction of a number close to pi/2 from pi/2 
is involved and mpc_acos seems much slower for such inputs than mpc_asin.

(That acos case is one where it would be better to call not mpc_asin but 
an internal function taking a flag telling it to call mpc_log on an 
appropriately adjusted value and so avoid any need to subtract from pi/2 
explicitly - a case of slowness that doesn't need a whole separate 
algorithm for slow cases, unlike some underlying problems with mpc_asin 
slowness.  glibc has a function __kernel_casinh for this cancellation 
issue, "Return the complex inverse hyperbolic sine of finite nonzero Z, 
with the imaginary part of the result subtracted from pi/2 if ADJ is 
nonzero.", and the main casin / casinh / cacos / cacosh functions then use 
that, directly or indirectly.)

Joseph S. Myers
joseph at codesourcery.com

More information about the Mpc-discuss mailing list