Minimizing rounding error on calculation of Complex Atanh I am trying to implement the calculation of the complex inverse tangens hyperbolicus function in my program in VB.NET. I am using the formula  : $\arctan(z)=\dfrac{1}{2}  {\rm Log}\left(\frac{1+z}{1-z}\right)$. This works but when checking the result against Mathematica I notice rounding errors (I'm using double precision).
So for example $\arctan(54+ 63 i)$ I get with my implementation:
$$0.00784264136408108 + 1.56164569254476i$$
versus the correct result
$$0.00784264136408112(65) + 1.56164569254476(05771)i$$
As you can see, the real part of the result is somewhat wrong due to rounding errors. I already tried writing the fraction as difference between two logarithms, pull the 0.5* into the logarithm, but it all gives not really a lot of precision. Now I would like to know how this function is usually implemented to avoid rounding errors as best as possible. Thank you.
Addition: My implementation of Complex.Log

If Input.Real > 0 Then Result.Imaginary = Atan(Input.Imaginary / Input.Real)
  If Input.Real < 0 Then
  {
    If Input.Imaginary >= 0 Then Result.Imaginary = PI + Atan(Input.Imaginary / Input.Real)
    If Input.Imaginary < 0 Then Result.Imaginary = -PI + Atan(Input.Imaginary / Input.Real)
  }
  If Input.Real = 0 Then
  {
    If Input.Imaginary > 0 Then Result.Imaginary = PI / 2
    If Input.Imaginary <= 0 Then Result.Imaginary = -PI / 2
  }
  Result.Real = 0.5 * Log(Input.Real^2 + Input.Imaginary^2)
  Return Result.Real + i*Result.Imaginary  

 A: That looks like a pretty good result to me:  you're out only by a handful of ULPs (units in the last place) in the real part.  You probably can't hope to do that much better without resorting to a much more sophisticated algorithm---for example, using extended precision for the intermediate computations and then rounding back to double precision, or using different polynomial or rational approximations for different regions of the complex plane.
That said, there's a classic reference from Kahan on the subject of implementing the basic complex functions, including atanh.  You might also take a look at Python's implementation here.  I believe this is about as much as you can reasonably do with a straightforward double-precision based algorithm.  (Disclaimer:  I wrote the Python implementation, so I'm biased.)  In this particular case, it gives this result:
>>> from cmath import atanh
>>> atanh(54+63j)
(0.007842641364081127+1.5616456925447606j)

which turns out to be the closest complex number representable in double-precision to the exact result (so has an error of less than 0.5 ulps in both the real and imaginary part).
