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




Bits error versus x
Results
| Original | 14.9 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 3.47035771329e-5Initial program 29.8
Taylor expanded in x around 0 0.0
if 3.47035771329e-5 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) Initial program 0.1
Final simplification0.0
herbie shell --seed 2022068
(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))))