summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'math.c')
-rw-r--r--math.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/math.c b/math.c
index c900a0b7aa..ba5a12128a 100644
--- a/math.c
+++ b/math.c
@@ -88,6 +88,15 @@ math_atan(obj, x)
return rb_float_new(atan(RFLOAT(x)->value));
}
+#ifndef HAVE_COSH
+double
+cosh(x)
+ double x;
+{
+ return (exp(x) + exp(-x)) / 2;
+}
+#endif
+
static VALUE
math_cosh(obj, x)
VALUE obj, x;
@@ -96,6 +105,15 @@ math_cosh(obj, x)
return rb_float_new(cosh(RFLOAT(x)->value));
}
+#ifndef HAVE_SINH
+double
+sinh(x)
+ double x;
+{
+ return (exp(x) - exp(-x)) / 2;
+}
+#endif
+
static VALUE
math_sinh(obj, x)
VALUE obj, x;
@@ -104,6 +122,15 @@ math_sinh(obj, x)
return rb_float_new(sinh(RFLOAT(x)->value));
}
+#ifndef HAVE_SINH
+double
+tanh(x)
+ double x;
+{
+ return sinh(x) / cosh(x);
+}
+#endif
+
static VALUE
math_tanh(obj, x)
VALUE obj, x;