Accurate computation of arcsec near branch points

104 Views Asked by At

The direct numerical implementations of the usual definitions of the complex $\mathrm{arcsec}(z)=\arccos(1/z)$ and similar for $\mathrm{arccsc}(z), \mathrm{arcsech}(z), $ etc are not accurate near the branch points $z=\pm1$ or $z=\pm i$. If $|z-1|$ is small I can use the branch point series

$$\mathrm{arcsec}(z) \approx \sqrt{2(z-1)}\left(1 -\frac{5}{12}(z-1) + \frac{43}{160}(z-1)^2 \cdots \right)$$

But this is not applicable if only the real or imaginary part of $z-1$ is small. For the mainly used functions $\arcsin, \arccos, \arctan\;$ Abramowitz/Stegun 4.4.37-39 or DLMF give formulas for the real and imaginary parts which can be used with accurate functions like $\mathrm{log1p}(x) = \ln(1+x)$ to build accurate functions for $\arcsin$ etc.

Unfortunately both references or internet search do not come up with such formulas for $\mathrm{arcsec}$ etc. Does someone know references or links to such formulas? Or give hints for accurate implementations near the branch points?

Update: Meanwhile I found monster formulas on the Wolfram function site, Section 'Complex characteristics' (http://functions.wolfram.com/01.18.19.0001.01 ff.). There are some common sub-expressions, but even then it looks quite impressive.

And the GNU Scientific Library has C implementations, but by inspection from the form $\mathrm{arcsec}(z)=\arccos(1/z)$ and some test values it is inaccurate as expected, e.g. for double precision the relative errors for $\mathrm{arcsec}(1+2^{-27}i\,$) are about $3.7\times10^{-9}$ for both Re and Im parts (the machine epsilon is $2.22\times 10^{-16})$.

Thus the slightly modified questions are for references with less complicated expressions or more accurate implementations.