Average Error: 29.1 → 0.8
Time: 5.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} \]
\[\frac{e^{-x} \cdot \left(2 + x \cdot 2\right)}{2} \]
\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}
\frac{e^{-x} \cdot \left(2 + x \cdot 2\right)}{2}
(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 (/ (* (exp (- x)) (+ 2.0 (* x 2.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) {
	return (exp(-x) * (2.0 + (x * 2.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.1

    \[\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 around 0 0.7

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

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

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

Reproduce

herbie shell --seed 2021205 
(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))