summaryrefslogtreecommitdiff
path: root/libm/float/coshf.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-05-10 00:40:28 +0000
committerEric Andersen <andersen@codepoet.org>2001-05-10 00:40:28 +0000
commit1077fa4d772832f77a677ce7fb7c2d513b959e3f (patch)
tree579bee13fb0b58d2800206366ec2caecbb15f3fc /libm/float/coshf.c
parent22358dd7ce7bb49792204b698f01a6f69b9c8e08 (diff)
uClibc now has a math library. muahahahaha!
-Erik
Diffstat (limited to 'libm/float/coshf.c')
-rw-r--r--libm/float/coshf.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/libm/float/coshf.c b/libm/float/coshf.c
new file mode 100644
index 000000000..2b44fdeb3
--- /dev/null
+++ b/libm/float/coshf.c
@@ -0,0 +1,67 @@
+/* coshf.c
+ *
+ * Hyperbolic cosine
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * float x, y, coshf();
+ *
+ * y = coshf( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns hyperbolic cosine of argument in the range MINLOGF to
+ * MAXLOGF.
+ *
+ * cosh(x) = ( exp(x) + exp(-x) )/2.
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * Relative error:
+ * arithmetic domain # trials peak rms
+ * IEEE +-MAXLOGF 100000 1.2e-7 2.8e-8
+ *
+ *
+ * ERROR MESSAGES:
+ *
+ * message condition value returned
+ * coshf overflow |x| > MAXLOGF MAXNUMF
+ *
+ *
+ */
+
+/* cosh.c */
+
+/*
+Cephes Math Library Release 2.2: June, 1992
+Copyright 1985, 1987, 1992 by Stephen L. Moshier
+Direct inquiries to 30 Frost Street, Cambridge, MA 02140
+*/
+
+#include <math.h>
+extern float MAXLOGF, MAXNUMF;
+
+float expf(float);
+
+float coshf(float xx)
+{
+float x, y;
+
+x = xx;
+if( x < 0 )
+ x = -x;
+if( x > MAXLOGF )
+ {
+ mtherr( "coshf", OVERFLOW );
+ return( MAXNUMF );
+ }
+y = expf(x);
+y = y + 1.0/y;
+return( 0.5*y );
+}