From 885f5974cdf65b59415837ae97f5a14ef1350670 Mon Sep 17 00:00:00 2001 From: Kacper Date: Tue, 9 Dec 2025 19:20:15 +0100 Subject: feat: add gzip and new headers --- lib/libm/ctan.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lib/libm/ctan.c (limited to 'lib/libm/ctan.c') diff --git a/lib/libm/ctan.c b/lib/libm/ctan.c new file mode 100644 index 00000000..2bc6156c --- /dev/null +++ b/lib/libm/ctan.c @@ -0,0 +1,53 @@ +#include "__complex.h" + +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; +} + +double complex ctan(double complex z) +{ + double d = cos(2.0 * creal(z)) + cosh(2.0 * cimag(z)); + + if (fabs(d) < 0.25) + d = _ctans(z); + + if (d == 0.0) { + return HUGE_VAL + HUGE_VAL * (double complex)I; + } + + return sin(2.0 * creal(z)) / d + + (sinh(2.0 * cimag(z)) / d) * (double complex)I; +} -- cgit v1.2.3