\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 1.8493523655100802 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(1.38778 \cdot 10^{-17}, \frac{\left(2 \cdot \log \left(\sqrt[3]{e^{x}}\right) + \log \left(\sqrt[3]{e^{x}}\right)\right) \cdot \sqrt[3]{{x}^{3}}}{\frac{\varepsilon}{x}}, 1 - 0.5 \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\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}\\
\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 <= 1.8493523655100802e-05)) {
temp = fma(1.3877787807814457e-17, ((((2.0 * log(cbrt(exp(x)))) + log(cbrt(exp(x)))) * cbrt(pow(x, 3.0))) / (eps / x)), (1.0 - (0.5 * pow(x, 2.0))));
} else {
temp = ((((1.0 + (1.0 / eps)) * exp(-((1.0 - eps) * x))) - (((1.0 / eps) - 1.0) * exp(-((1.0 + eps) * x)))) / 2.0);
}
return temp;
}



Bits error versus x



Bits error versus eps
Results
if x < 1.8493523655100802e-05Initial program 39.2
Simplified39.3
Taylor expanded around 0 7.1
Simplified7.1
rmApplied add-cube-cbrt7.1
Applied associate-/l*7.1
Simplified7.1
rmApplied add-log-exp2.8
Simplified2.8
rmApplied add-cube-cbrt2.6
Applied log-prod2.6
Simplified2.6
if 1.8493523655100802e-05 < x Initial program 1.6
Final simplification2.4
herbie shell --seed 2020053 +o rules:numerics
(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))