amath
1.8.5
Simple command line calculator
|
Hyperbolic tangent function. More...
#include "prim.h"
Go to the source code of this file.
Functions | |
double | tanh (double x) |
Hyperbolic tangent function. More... | |
Variables | |
static const double | one = 1.0 |
static const double | two = 2.0 |
static const double | tiny = 1.0e-300 |
Hyperbolic tangent function.
Definition in file tanh.c.
double tanh | ( | double | x | ) |
Hyperbolic tangent function.
Method x -x e - e 0. tanh(x) is defined to be --------— x -x e + e
1. reduce x to non-negative by tanh(-x) = -tanh(x)
2. 0 <= x <= 2**-55 : tanh(x) = x*(one+x) -t 2**-55 < x <= 1 : tanh(x) = --—; t = expm1(-2x) t + 2 2 1 <= x <= 22.0 : tanh(x) = 1- --— ; t=expm1(2x) t + 2 22.0 < x <= INF : tanh(x) = 1
Special cases tanh(NaN) is NaN only tanh(0)=0 is exact for finite argument.
Definition at line 81 of file tanh.c.
References expm1(), fabs(), one, tiny, and two.
Referenced by RealNumber::HypTangent().