Average Error: 29.3 → 0.9
Time: 5.6s
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 \varepsilon - x} + e^{-\left(x + x \cdot \varepsilon\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 \varepsilon - x} + e^{-\left(x + x \cdot \varepsilon\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 eps) x)) (exp (- (+ x (* x eps))))) 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 * eps) - x) + exp(-(x + (x * eps)))) / 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.3

    \[\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 inf 0.9

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

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

Reproduce

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