summaryrefslogtreecommitdiff
path: root/lib/libm/catan.c
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-09 19:20:15 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-09 19:20:15 +0100
commit885f5974cdf65b59415837ae97f5a14ef1350670 (patch)
tree66ac13de29c7f4932c5fcae11773df574e4e256a /lib/libm/catan.c
parent8f9e448b2ef6db7cd905540c21f3c5b190e7a1e7 (diff)
feat: add gzip and new headers
Diffstat (limited to 'lib/libm/catan.c')
-rw-r--r--lib/libm/catan.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/libm/catan.c b/lib/libm/catan.c
new file mode 100644
index 00000000..b6880811
--- /dev/null
+++ b/lib/libm/catan.c
@@ -0,0 +1,35 @@
+#include <float.h>
+#include "__complex.h"
+
+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 overflow;
+
+ x2 = x * x;
+ a = 1.0 - x2 - (y * y);
+ if (a == 0.0)
+ goto overflow;
+
+ t = 0.5 * atan2(2.0 * x, a);
+ w = redupi(t);
+
+ t = y - 1.0;
+ a = x2 + (t * t);
+ if (a == 0.0)
+ goto overflow;
+
+ t = y + 1.0;
+ a = (x2 + (t * t)) / a;
+
+ return w + (0.25 * log(a)) * I;
+
+overflow:
+ return DBL_MAX + DBL_MAX * I;
+}