Average Error: 29.9 → 1.1
Time: 5.4s
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} \mathbf{if}\;x \leq 62.938531400520596:\\ \;\;\;\;\frac{\frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}} \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}} \cdot \frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + \frac{1 - \frac{1}{\varepsilon}}{e^{x \cdot \left(1 + \varepsilon\right)}}}{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}
\mathbf{if}\;x \leq 62.938531400520596:\\
\;\;\;\;\frac{\frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}} \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}} \cdot \frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}}}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + \frac{1 - \frac{1}{\varepsilon}}{e^{x \cdot \left(1 + \varepsilon\right)}}}{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
 (if (<= x 62.938531400520596)
   (/
    (*
     (/
      (*
       (cbrt
        (- (pow (+ (* (pow x 3.0) 0.6666666666666666) 2.0) 3.0) (pow x 6.0)))
       (cbrt
        (- (pow (+ (* (pow x 3.0) 0.6666666666666666) 2.0) 3.0) (pow x 6.0))))
      (sqrt
       (+
        (pow x 4.0)
        (*
         (+ (* (pow x 3.0) 0.6666666666666666) 2.0)
         (+ (+ (* (pow x 3.0) 0.6666666666666666) 2.0) (* x x))))))
     (/
      (cbrt
       (- (pow (+ (* (pow x 3.0) 0.6666666666666666) 2.0) 3.0) (pow x 6.0)))
      (sqrt
       (+
        (pow x 4.0)
        (*
         (+ (* (pow x 3.0) 0.6666666666666666) 2.0)
         (+ (+ (* (pow x 3.0) 0.6666666666666666) 2.0) (* x x)))))))
    2.0)
   (/
    (+
     (* (+ 1.0 (/ 1.0 eps)) (exp (* x (+ eps -1.0))))
     (/ (- 1.0 (/ 1.0 eps)) (exp (* x (+ 1.0 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) {
	double tmp;
	if (x <= 62.938531400520596) {
		tmp = (((cbrt(pow(((pow(x, 3.0) * 0.6666666666666666) + 2.0), 3.0) - pow(x, 6.0)) * cbrt(pow(((pow(x, 3.0) * 0.6666666666666666) + 2.0), 3.0) - pow(x, 6.0))) / sqrt(pow(x, 4.0) + (((pow(x, 3.0) * 0.6666666666666666) + 2.0) * (((pow(x, 3.0) * 0.6666666666666666) + 2.0) + (x * x))))) * (cbrt(pow(((pow(x, 3.0) * 0.6666666666666666) + 2.0), 3.0) - pow(x, 6.0)) / sqrt(pow(x, 4.0) + (((pow(x, 3.0) * 0.6666666666666666) + 2.0) * (((pow(x, 3.0) * 0.6666666666666666) + 2.0) + (x * x)))))) / 2.0;
	} else {
		tmp = (((1.0 + (1.0 / eps)) * exp(x * (eps + -1.0))) + ((1.0 - (1.0 / eps)) / exp(x * (1.0 + eps)))) / 2.0;
	}
	return tmp;
}

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. Split input into 2 regimes
  2. if x < 62.9385314005205956

    1. Initial program 39.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 0 1.3

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

      \[\leadsto \frac{\color{blue}{\left({x}^{3} \cdot 0.6666666666666666 + 2\right) - x \cdot x}}{2}\]
    4. Using strategy rm
    5. Applied flip3--_binary641.3

      \[\leadsto \frac{\color{blue}{\frac{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {\left(x \cdot x\right)}^{3}}{\left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left({x}^{3} \cdot 0.6666666666666666 + 2\right) + \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x\right)\right)}}}{2}\]
    6. Simplified1.3

      \[\leadsto \frac{\frac{\color{blue}{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left({x}^{3} \cdot 0.6666666666666666 + 2\right) + \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x\right)\right)}}{2}\]
    7. Simplified1.3

      \[\leadsto \frac{\frac{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}{\color{blue}{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)}}}{2}\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt_binary641.3

      \[\leadsto \frac{\frac{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}{\color{blue}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)} \cdot \sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)}}}}{2}\]
    10. Applied add-cube-cbrt_binary641.3

      \[\leadsto \frac{\frac{\color{blue}{\left(\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}} \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}\right) \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)} \cdot \sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)}}}{2}\]
    11. Applied times-frac_binary641.3

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}} \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)}} \cdot \frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)}}}}{2}\]
    12. Simplified1.3

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}} \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}}} \cdot \frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(x \cdot x + \left({x}^{3} \cdot 0.6666666666666666 + 2\right)\right)}}}{2}\]
    13. Simplified1.3

      \[\leadsto \frac{\frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}} \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}} \cdot \color{blue}{\frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}}}}{2}\]

    if 62.9385314005205956 < x

    1. Initial program 0.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. Using strategy rm
    3. Applied sub-neg_binary640.3

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

      \[\leadsto \frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{-\left(1 - \varepsilon\right) \cdot x} + \color{blue}{\frac{1 - \frac{1}{\varepsilon}}{e^{x \cdot \left(1 + \varepsilon\right)}}}}{2}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 62.938531400520596:\\ \;\;\;\;\frac{\frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}} \cdot \sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}} \cdot \frac{\sqrt[3]{{\left({x}^{3} \cdot 0.6666666666666666 + 2\right)}^{3} - {x}^{6}}}{\sqrt{{x}^{4} + \left({x}^{3} \cdot 0.6666666666666666 + 2\right) \cdot \left(\left({x}^{3} \cdot 0.6666666666666666 + 2\right) + x \cdot x\right)}}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + \frac{1}{\varepsilon}\right) \cdot e^{x \cdot \left(\varepsilon + -1\right)} + \frac{1 - \frac{1}{\varepsilon}}{e^{x \cdot \left(1 + \varepsilon\right)}}}{2}\\ \end{array}\]

Reproduce

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