Average Error: 29.4 → 0.9
Time: 6.3s
Precision: 64
\[\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 10.6130564182300784:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\left(\sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)} \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{e^{-\left(1 + \varepsilon\right) \cdot x}}{2}, 1 - \frac{1}{\varepsilon}, \frac{1 + \frac{1}{\varepsilon}}{2 \cdot e^{\left(1 - \varepsilon\right) \cdot x}}\right)\\ \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 \le 10.6130564182300784:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\left(\sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)} \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{e^{-\left(1 + \varepsilon\right) \cdot x}}{2}, 1 - \frac{1}{\varepsilon}, \frac{1 + \frac{1}{\varepsilon}}{2 \cdot e^{\left(1 - \varepsilon\right) \cdot x}}\right)\\

\end{array}
double f(double x, double eps) {
        double r35161 = 1.0;
        double r35162 = eps;
        double r35163 = r35161 / r35162;
        double r35164 = r35161 + r35163;
        double r35165 = r35161 - r35162;
        double r35166 = x;
        double r35167 = r35165 * r35166;
        double r35168 = -r35167;
        double r35169 = exp(r35168);
        double r35170 = r35164 * r35169;
        double r35171 = r35163 - r35161;
        double r35172 = r35161 + r35162;
        double r35173 = r35172 * r35166;
        double r35174 = -r35173;
        double r35175 = exp(r35174);
        double r35176 = r35171 * r35175;
        double r35177 = r35170 - r35176;
        double r35178 = 2.0;
        double r35179 = r35177 / r35178;
        return r35179;
}

double f(double x, double eps) {
        double r35180 = x;
        double r35181 = 10.613056418230078;
        bool r35182 = r35180 <= r35181;
        double r35183 = 3.0;
        double r35184 = pow(r35180, r35183);
        double r35185 = 0.6666666666666667;
        double r35186 = 2.0;
        double r35187 = 1.0;
        double r35188 = 2.0;
        double r35189 = pow(r35180, r35188);
        double r35190 = r35187 * r35189;
        double r35191 = r35186 - r35190;
        double r35192 = fma(r35184, r35185, r35191);
        double r35193 = expm1(r35192);
        double r35194 = cbrt(r35193);
        double r35195 = r35194 * r35194;
        double r35196 = r35195 * r35194;
        double r35197 = log1p(r35196);
        double r35198 = r35197 / r35186;
        double r35199 = eps;
        double r35200 = r35187 + r35199;
        double r35201 = r35200 * r35180;
        double r35202 = -r35201;
        double r35203 = exp(r35202);
        double r35204 = r35203 / r35186;
        double r35205 = r35187 / r35199;
        double r35206 = r35187 - r35205;
        double r35207 = r35187 + r35205;
        double r35208 = r35187 - r35199;
        double r35209 = r35208 * r35180;
        double r35210 = exp(r35209);
        double r35211 = r35186 * r35210;
        double r35212 = r35207 / r35211;
        double r35213 = fma(r35204, r35206, r35212);
        double r35214 = r35182 ? r35198 : r35213;
        return r35214;
}

Error

Bits error versus x

Bits error versus eps

Derivation

  1. Split input into 2 regimes
  2. if x < 10.613056418230078

    1. Initial program 38.9

      \[\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.2

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)}}{2}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u1.2

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)\right)}}{2}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt1.2

      \[\leadsto \frac{\mathsf{log1p}\left(\color{blue}{\left(\sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)} \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}}\right)}{2}\]

    if 10.613056418230078 < x

    1. Initial program 0.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}\]
    2. Simplified0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 10.6130564182300784:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\left(\sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)} \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{expm1}\left(\mathsf{fma}\left({x}^{3}, 0.66666666666666674, 2 - 1 \cdot {x}^{2}\right)\right)}\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{e^{-\left(1 + \varepsilon\right) \cdot x}}{2}, 1 - \frac{1}{\varepsilon}, \frac{1 + \frac{1}{\varepsilon}}{2 \cdot e^{\left(1 - \varepsilon\right) \cdot x}}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020065 +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))