diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-11-22 14:04:29 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-11-22 14:04:29 +0000 |
commit | 7ce331c01ce6eb7b3f5c715a38a24359da9c6ee2 (patch) | |
tree | 3a7e8476e868ae15f4da1b7ce26b2db6f434468c /libm/float/tanhf.c | |
parent | c117dd5fb183afb1a4790a6f6110d88704be6bf8 (diff) |
Totally rework the math library, this time based on the MacOs X
math library (which is itself based on the math lib from FreeBSD).
-Erik
Diffstat (limited to 'libm/float/tanhf.c')
-rw-r--r-- | libm/float/tanhf.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/libm/float/tanhf.c b/libm/float/tanhf.c deleted file mode 100644 index 4636192c2..000000000 --- a/libm/float/tanhf.c +++ /dev/null @@ -1,88 +0,0 @@ -/* tanhf.c - * - * Hyperbolic tangent - * - * - * - * SYNOPSIS: - * - * float x, y, tanhf(); - * - * y = tanhf( x ); - * - * - * - * DESCRIPTION: - * - * Returns hyperbolic tangent of argument in the range MINLOG to - * MAXLOG. - * - * A polynomial approximation is used for |x| < 0.625. - * Otherwise, - * - * tanh(x) = sinh(x)/cosh(x) = 1 - 2/(exp(2x) + 1). - * - * - * - * ACCURACY: - * - * Relative error: - * arithmetic domain # trials peak rms - * IEEE -2,2 100000 1.3e-7 2.6e-8 - * - */ - -/* -Cephes Math Library Release 2.2: June, 1992 -Copyright 1984, 1987, 1989, 1992 by Stephen L. Moshier -Direct inquiries to 30 Frost Street, Cambridge, MA 02140 -*/ - -/* Single precision hyperbolic tangent - * test interval: [-0.625, +0.625] - * trials: 10000 - * peak relative error: 7.2e-8 - * rms relative error: 2.6e-8 - */ -#include <math.h> - -extern float MAXLOGF; - -float expf( float ); - -float tanhf( float xx ) -{ -float x, z; - -if( xx < 0 ) - x = -xx; -else - x = xx; - -if( x > 0.5 * MAXLOGF ) - { - if( xx > 0 ) - return( 1.0 ); - else - return( -1.0 ); - } -if( x >= 0.625 ) - { - x = expf(x+x); - z = 1.0 - 2.0/(x + 1.0); - if( xx < 0 ) - z = -z; - } -else - { - z = x * x; - z = - (((( -5.70498872745E-3 * z - + 2.06390887954E-2) * z - - 5.37397155531E-2) * z - + 1.33314422036E-1) * z - - 3.33332819422E-1) * z * xx - + xx; - } -return( z ); -} |