long double _ctansl(long double complex z) { long double f, x, x2, y, y2, rn, t; long double d; x = fabsl(2.0L * creall(z)); y = fabsl(2.0L * cimagl(z)); x = _redupil(x); x = x * x; y = y * y; x2 = 1.0; y2 = 1.0; f = 1.0; rn = 0.0; d = 0.0; do { rn += 1.0L; f *= rn; rn += 1.0L; f *= rn; x2 *= x; y2 *= y; t = y2 + x2; t /= f; d += t; rn += 1.0L; f *= rn; rn += 1.0L; f *= rn; x2 *= x; y2 *= y; t = y2 - x2; t /= f; d += t; } while (fabsl(t/d) > MACHEPL); return d; }
long double complex catanl(long double complex z) { long double complex w; long double a, t, x, x2, y; x = creall(z); y = cimagl(z); if ((x == 0.0L) && (y > 1.0L)) goto ovrf; x2 = x * x; a = 1.0L - x2 - (y * y); if (a == 0.0) goto ovrf; t = 0.5L * atan2l(2.0L * x, a); w = _redupil(t); t = y - 1.0L; a = x2 + (t * t); if (a == 0.0L) goto ovrf; t = y + 1.0L; a = (x2 + (t * t))/a; w = w + (0.25L * logl(a)) * I; return w; ovrf: #if 0 mtherr ("catanl", OVERFLOW); #endif w = HUGE_VALL + HUGE_VALL * I; return w; }