Exemple #1
0
double complex
catan(double complex z)
{
	double complex w;
	double a, t, x, x2, y;

	x = creal (z);
	y = cimag (z);

	if ((x == 0.0) && (y > 1.0))
		goto ovrf;

	x2 = x * x;
	a = 1.0 - x2 - (y * y);
	if (a == 0.0)
		goto ovrf;

	t = 0.5 * atan2 (2.0 * x, a);
	w = _redupi (t);

	t = y - 1.0;
	a = x2 + (t * t);
	if (a == 0.0)
	goto ovrf;

	t = y + 1.0;
	a = (x2 + (t * t))/a;
	w = w + (0.25 * log (a)) * I;
	return (w);

ovrf:
	/*mtherr ("catan", OVERFLOW);*/
	w = MAXNUM + MAXNUM * I;
	return (w);
}
Exemple #2
0
static double
_ctans(double complex z)
{
	double f, x, x2, y, y2, rn, t;
	double d;

	x = fabs (2.0 * creal (z));
	y = fabs (2.0 * cimag(z));

	x = _redupi(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.0;
		f *= rn;
		rn += 1.0;
		f *= rn;
		x2 *= x;
		y2 *= y;
		t = y2 + x2;
		t /= f;
		d += t;

		rn += 1.0;
		f *= rn;
		rn += 1.0;
		f *= rn;
		x2 *= x;
		y2 *= y;
		t = y2 - x2;
		t /= f;
		d += t;
	}
	while (fabs(t/d) > MACHEP)
		;
	return (d);
}
Exemple #3
0
double complex catan(double complex z)
{
	double complex w;
	double a, t, x, x2, y;

	x = creal(z);
	y = cimag(z);

	x2 = x * x;
	a = 1.0 - x2 - (y * y);

	t = 0.5 * atan2(2.0 * x, a);
	w = _redupi(t);

	t = y - 1.0;
	a = x2 + (t * t);

	t = y + 1.0;
	a = (x2 + t * t)/a;
	w = CMPLX(w, 0.25 * log(a));
	return w;
}