\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)\right)\right)}{e^{x} + e^{-x}}
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))
(FPCore (x)
:precision binary64
(/
(fma
0.016666666666666666
(pow x 5.0)
(fma
0.0003968253968253968
(pow x 7.0)
(fma 2.0 x (* 0.3333333333333333 (pow x 3.0)))))
(+ (exp x) (exp (- x)))))double code(double x) {
return (exp(x) - exp(-x)) / (exp(x) + exp(-x));
}
double code(double x) {
return fma(0.016666666666666666, pow(x, 5.0), fma(0.0003968253968253968, pow(x, 7.0), fma(2.0, x, (0.3333333333333333 * pow(x, 3.0))))) / (exp(x) + exp(-x));
}



Bits error versus x
Initial program 58.0
Taylor expanded in x around 0 1.9
Simplified1.9
Final simplification1.9
herbie shell --seed 2022130
(FPCore (x)
:name "Hyperbolic tangent"
:precision binary64
(/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))