\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\tanh x
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))
(FPCore (x) :precision binary64 (tanh x))
double code(double x) {
return (exp(x) - exp(-x)) / (exp(x) + exp(-x));
}
double code(double x) {
return tanh(x);
}






Bits error versus x
Results
| Alternative 1 | |
|---|---|
| Error | 1.4 |
| Cost | 385 |
| Alternative 2 | |
|---|---|
| Error | 59.1 |
| Cost | 385 |
| Alternative 3 | |
|---|---|
| Error | 60.6 |
| Cost | 64 |

Initial program 58.2
rmApplied tanh-undef_binary64_12960.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2021044
(FPCore (x)
:name "Hyperbolic tangent"
:precision binary64
(/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))