summaryrefslogtreecommitdiff
path: root/libm/float/atanhf.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/atanhf.c
parent22358dd7ce7bb49792204b698f01a6f69b9c8e08 (diff)
uClibc now has a math library. muahahahaha!
-Erik
Diffstat (limited to 'libm/float/atanhf.c')
-rw-r--r--libm/float/atanhf.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/libm/float/atanhf.c b/libm/float/atanhf.c
new file mode 100644
index 000000000..dfadad09e
--- /dev/null
+++ b/libm/float/atanhf.c
@@ -0,0 +1,92 @@
+/* atanhf.c
+ *
+ * Inverse hyperbolic tangent
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * float x, y, atanhf();
+ *
+ * y = atanhf( x );
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * Returns inverse hyperbolic tangent of argument in the range
+ * MINLOGF to MAXLOGF.
+ *
+ * If |x| < 0.5, a polynomial approximation is used.
+ * Otherwise,
+ * atanh(x) = 0.5 * log( (1+x)/(1-x) ).
+ *
+ *
+ *
+ * ACCURACY:
+ *
+ * Relative error:
+ * arithmetic domain # trials peak rms
+ * IEEE -1,1 100000 1.4e-7 3.1e-8
+ *
+ */
+
+/* atanh.c */
+
+
+/*
+Cephes Math Library Release 2.2: June, 1992
+Copyright (C) 1987, 1992 by Stephen L. Moshier
+Direct inquiries to 30 Frost Street, Cambridge, MA 02140
+*/
+
+/* Single precision inverse hyperbolic tangent
+ * test interval: [-0.5, +0.5]
+ * trials: 10000
+ * peak relative error: 8.2e-8
+ * rms relative error: 3.0e-8
+ */
+#include <math.h>
+extern float MAXNUMF;
+
+float logf( float );
+
+float atanhf( float xx )
+{
+float x, z;
+
+x = xx;
+if( x < 0 )
+ z = -x;
+else
+ z = x;
+if( z >= 1.0 )
+ {
+ if( x == 1.0 )
+ return( MAXNUMF );
+ if( x == -1.0 )
+ return( -MAXNUMF );
+ mtherr( "atanhl", DOMAIN );
+ return( MAXNUMF );
+ }
+
+if( z < 1.0e-4 )
+ return(x);
+
+if( z < 0.5 )
+ {
+ z = x * x;
+ z =
+ (((( 1.81740078349E-1 * z
+ + 8.24370301058E-2) * z
+ + 1.46691431730E-1) * z
+ + 1.99782164500E-1) * z
+ + 3.33337300303E-1) * z * x
+ + x;
+ }
+else
+ {
+ z = 0.5 * logf( (1.0+x)/(1.0-x) );
+ }
+return( z );
+}