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




Bits error versus x
Results
| Original | 29.8 |
|---|---|
| Target | 0.0 |
| Herbie | 0.1 |
if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 2.540759517e-6Initial program 30.2
Taylor expanded around 0 0.0
Simplified0.0
if 2.540759517e-6 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) Initial program 3.4
rmApplied exp-neg_binary643.3
Applied flip3--_binary647.6
Applied frac-add_binary647.7
Final simplification0.1
herbie shell --seed 2021118
(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))))