\left(e^{x} - 2\right) + e^{-x}
\begin{array}{l}
t_0 := e^{-x}\\
\mathbf{if}\;\left(e^{x} - 2\right) + t_0 \leq 0.003195701986808186:\\
\;\;\;\;\mathsf{fma}\left(0.08333333333333333, {x}^{4}, \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + \frac{{\left(e^{x}\right)}^{3} - 8}{\mathsf{fma}\left(e^{x}, e^{x} + 2, 4\right)}\\
\end{array}
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x)
:precision binary64
(let* ((t_0 (exp (- x))))
(if (<= (+ (- (exp x) 2.0) t_0) 0.003195701986808186)
(fma
0.08333333333333333
(pow x 4.0)
(fma
0.002777777777777778
(pow x 6.0)
(fma x x (* 4.96031746031746e-5 (pow x 8.0)))))
(+ t_0 (/ (- (pow (exp x) 3.0) 8.0) (fma (exp x) (+ (exp x) 2.0) 4.0))))))double code(double x) {
return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
double t_0 = exp(-x);
double tmp;
if (((exp(x) - 2.0) + t_0) <= 0.003195701986808186) {
tmp = fma(0.08333333333333333, pow(x, 4.0), fma(0.002777777777777778, pow(x, 6.0), fma(x, x, (4.96031746031746e-5 * pow(x, 8.0)))));
} else {
tmp = t_0 + ((pow(exp(x), 3.0) - 8.0) / fma(exp(x), (exp(x) + 2.0), 4.0));
}
return tmp;
}




Bits error versus x
| Original | 29.3 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 0.003195701986808186Initial program 29.7
Taylor expanded in x around 0 0.0
Simplified0.0
if 0.003195701986808186 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) Initial program 1.1
Applied flip3--_binary643.0
Simplified3.0
Simplified2.9
Final simplification0.0
herbie shell --seed 2021329
(FPCore (x)
:name "exp2 (problem 3.3.7)"
:precision binary64
:herbie-target
(* 4.0 (pow (sinh (/ x 2.0)) 2.0))
(+ (- (exp x) 2.0) (exp (- x))))