Average Error: 29.8 → 0.5
Time: 15.3s
Precision: binary64
\[\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} t_0 := e^{-x}\\ \frac{2 \cdot \left(x \cdot t_0\right) + 2 \cdot t_0}{2} \end{array} \]
\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}
t_0 := e^{-x}\\
\frac{2 \cdot \left(x \cdot t_0\right) + 2 \cdot t_0}{2}
\end{array}
(FPCore (x eps)
 :precision binary64
 (/
  (-
   (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x))))
   (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x)))))
  2.0))
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (exp (- x)))) (/ (+ (* 2.0 (* x t_0)) (* 2.0 t_0)) 2.0)))
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 t_0 = exp(-x);
	return ((2.0 * (x * t_0)) + (2.0 * t_0)) / 2.0;
}

Error

Bits error versus x

Bits error versus eps

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 29.8

    \[\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} \]
  2. Taylor expanded in eps around 0 0.5

    \[\leadsto \frac{\color{blue}{2 \cdot \left(x \cdot e^{-x}\right) + 2 \cdot e^{-x}}}{2} \]
  3. Final simplification0.5

    \[\leadsto \frac{2 \cdot \left(x \cdot e^{-x}\right) + 2 \cdot e^{-x}}{2} \]

Reproduce

herbie shell --seed 2022024 
(FPCore (x eps)
  :name "NMSE Section 6.1 mentioned, A"
  :precision binary64
  (/ (- (* (+ 1.0 (/ 1.0 eps)) (exp (- (* (- 1.0 eps) x)))) (* (- (/ 1.0 eps) 1.0) (exp (- (* (+ 1.0 eps) x))))) 2.0))