From 01d29b92e61eb1091b02576c8b20e34f1c1484d2 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sat, 4 Sep 2021 13:41:27 +0900 Subject: [PATCH] libm: Hyperolibc trig functions --- libc/math/bad.c | 15 --------------- libc/math/math.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/libc/math/bad.c b/libc/math/bad.c index 2c4e3119..820eb9ec 100644 --- a/libc/math/bad.c +++ b/libc/math/bad.c @@ -15,11 +15,6 @@ double asin(double x) { return 0.0; } -double cosh(double x) { - BAD; - return 0.0; -} - double ldexp(double a, int exp) { double out = a; while (exp) { @@ -44,13 +39,3 @@ double log2(double x) { return 0.0; } -double sinh(double x) { - BAD; - return 0.0; -} - -double tanh(double x) { - BAD; - return 0.0; -} - diff --git a/libc/math/math.c b/libc/math/math.c index 89e81908..44bc406d 100644 --- a/libc/math/math.c +++ b/libc/math/math.c @@ -456,3 +456,16 @@ double frexp(double x, int *exp) { memcpy(&out, &out_double, sizeof(double)); return out; } + +double cosh(double x) { + return (exp(x) + exp(-x)) / 2.0; +} + +double sinh(double x) { + return (exp(x) - exp(-x)) / 2.0; +} + +double tanh(double x) { + return (exp(2.0*x) - 1.0) / (exp(2.0*x) + 1.0); +} +