\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - \left(\frac{1}{\varepsilon} - 1\right) \cdot e^{-\left(1 + \varepsilon\right) \cdot x}}{2}\begin{array}{l}
\mathbf{if}\;x \le 3.591957276208114:\\
\;\;\;\;\frac{\left(\left(0.66666666666666674 \cdot x\right) \cdot \left(x \cdot x\right) + 2\right) - 1 \cdot {x}^{2}}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} - 1 \cdot \left(\frac{e^{-\left(x \cdot \varepsilon + 1 \cdot x\right)}}{\varepsilon} - e^{-\left(x \cdot \varepsilon + 1 \cdot x\right)}\right)}{2}\\
\end{array}double code(double x, double eps) {
return ((((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0);
}
double code(double x, double eps) {
double temp;
if ((x <= 3.591957276208114)) {
temp = (((((0.6666666666666667 * x) * (x * x)) + 2.0) - (1.0 * pow(x, 2.0))) / 2.0);
} else {
temp = ((((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (1.0 * ((exp(-((x * eps) + (1.0 * x))) / eps) - exp(-((x * eps) + (1.0 * x)))))) / 2.0);
}
return temp;
}



Bits error versus x



Bits error versus eps
Results
if x < 3.591957276208114Initial program 39.0
Taylor expanded around 0 1.2
rmApplied cube-mult1.2
Applied associate-*r*1.2
if 3.591957276208114 < x Initial program 0.4
Taylor expanded around inf 0.4
Simplified0.4
Final simplification1.0
herbie shell --seed 2020057
(FPCore (x eps)
:name "NMSE Section 6.1 mentioned, A"
:precision binary64
(/ (- (* (+ 1 (/ 1 eps)) (exp (- (* (- 1 eps) x)))) (* (- (/ 1 eps) 1) (exp (- (* (+ 1 eps) x))))) 2))