Average Error: 29.1 → 0.0
Time: 30.8s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.05005305256090602:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}, \frac{2}{\left(\sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}}\right) \cdot \sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}}}, -1\right)\\ \mathbf{elif}\;-2 \cdot x \le 0.0005413665455498676:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{3}, \left(x \cdot x\right) \cdot x, \mathsf{fma}\left({x}^{5}, \frac{2}{15}, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(\frac{2}{1 + e^{-2 \cdot x}}, \frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}}, -1\right)}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + \mathsf{fma}\left(\frac{2}{1 + e^{-2 \cdot x}}, \frac{2}{1 + e^{-2 \cdot x}}, 1\right)}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.05005305256090602:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}, \frac{2}{\left(\sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}}\right) \cdot \sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}}}, -1\right)\\

\mathbf{elif}\;-2 \cdot x \le 0.0005413665455498676:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{3}, \left(x \cdot x\right) \cdot x, \mathsf{fma}\left({x}^{5}, \frac{2}{15}, x\right)\right)\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r1863099 = 2.0;
        double r1863100 = 1.0;
        double r1863101 = -2.0;
        double r1863102 = x;
        double r1863103 = r1863101 * r1863102;
        double r1863104 = exp(r1863103);
        double r1863105 = r1863100 + r1863104;
        double r1863106 = r1863099 / r1863105;
        double r1863107 = r1863106 - r1863100;
        return r1863107;
}

double f(double x, double __attribute__((unused)) y) {
        double r1863108 = -2.0;
        double r1863109 = x;
        double r1863110 = r1863108 * r1863109;
        double r1863111 = -0.05005305256090602;
        bool r1863112 = r1863110 <= r1863111;
        double r1863113 = 1.0;
        double r1863114 = exp(r1863110);
        double r1863115 = r1863113 + r1863114;
        double r1863116 = cbrt(r1863115);
        double r1863117 = r1863116 * r1863116;
        double r1863118 = r1863113 / r1863117;
        double r1863119 = 2.0;
        double r1863120 = cbrt(r1863116);
        double r1863121 = r1863120 * r1863120;
        double r1863122 = r1863121 * r1863120;
        double r1863123 = r1863119 / r1863122;
        double r1863124 = -1.0;
        double r1863125 = fma(r1863118, r1863123, r1863124);
        double r1863126 = 0.0005413665455498676;
        bool r1863127 = r1863110 <= r1863126;
        double r1863128 = -0.3333333333333333;
        double r1863129 = r1863109 * r1863109;
        double r1863130 = r1863129 * r1863109;
        double r1863131 = 5.0;
        double r1863132 = pow(r1863109, r1863131);
        double r1863133 = 0.13333333333333333;
        double r1863134 = fma(r1863132, r1863133, r1863109);
        double r1863135 = fma(r1863128, r1863130, r1863134);
        double r1863136 = r1863119 / r1863115;
        double r1863137 = r1863136 * r1863136;
        double r1863138 = fma(r1863136, r1863137, r1863124);
        double r1863139 = exp(r1863138);
        double r1863140 = log(r1863139);
        double r1863141 = fma(r1863136, r1863136, r1863113);
        double r1863142 = r1863136 + r1863141;
        double r1863143 = r1863140 / r1863142;
        double r1863144 = r1863127 ? r1863135 : r1863143;
        double r1863145 = r1863112 ? r1863125 : r1863144;
        return r1863145;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 3 regimes
  2. if (* -2 x) < -0.05005305256090602

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-cube-cbrt0.0

      \[\leadsto \frac{2}{\color{blue}{\left(\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}\right) \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied *-un-lft-identity0.0

      \[\leadsto \frac{\color{blue}{1 \cdot 2}}{\left(\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}\right) \cdot \sqrt[3]{1 + e^{-2 \cdot x}}} - 1\]
    5. Applied times-frac0.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}}}} - 1\]
    6. Applied fma-neg0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}, \frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}}}, -1\right)}\]
    7. Simplified0.0

      \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}, \frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}}}, \color{blue}{-1}\right)\]
    8. Using strategy rm
    9. Applied add-cube-cbrt0.0

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

    if -0.05005305256090602 < (* -2 x) < 0.0005413665455498676

    1. Initial program 59.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{3}, \left(x \cdot x\right) \cdot x, \mathsf{fma}\left({x}^{5}, \frac{2}{15}, x\right)\right)}\]

    if 0.0005413665455498676 < (* -2 x)

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied flip3--0.0

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{2}{1 + e^{-2 \cdot x}}, \frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}}, -1\right)}}{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} + \left(1 \cdot 1 + \frac{2}{1 + e^{-2 \cdot x}} \cdot 1\right)}\]
    5. Simplified0.0

      \[\leadsto \frac{\mathsf{fma}\left(\frac{2}{1 + e^{-2 \cdot x}}, \frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}}, -1\right)}{\color{blue}{\mathsf{fma}\left(\frac{2}{1 + e^{-2 \cdot x}}, \frac{2}{1 + e^{-2 \cdot x}}, 1\right) + \frac{2}{1 + e^{-2 \cdot x}}}}\]
    6. Using strategy rm
    7. Applied add-log-exp0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.05005305256090602:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}, \frac{2}{\left(\sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}}\right) \cdot \sqrt[3]{\sqrt[3]{1 + e^{-2 \cdot x}}}}, -1\right)\\ \mathbf{elif}\;-2 \cdot x \le 0.0005413665455498676:\\ \;\;\;\;\mathsf{fma}\left(\frac{-1}{3}, \left(x \cdot x\right) \cdot x, \mathsf{fma}\left({x}^{5}, \frac{2}{15}, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(e^{\mathsf{fma}\left(\frac{2}{1 + e^{-2 \cdot x}}, \frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}}, -1\right)}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + \mathsf{fma}\left(\frac{2}{1 + e^{-2 \cdot x}}, \frac{2}{1 + e^{-2 \cdot x}}, 1\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019141 +o rules:numerics
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))