Average Error: 29.4 → 0.0
Time: 4.1m
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007589146813113095:\\ \;\;\;\;\left(\sqrt[3]{\left(-1 + \frac{\frac{2}{\sqrt[3]{1 + e^{x \cdot -2}}}}{\sqrt[3]{1 + e^{x \cdot -2}} \cdot \sqrt[3]{1 + e^{x \cdot -2}}}\right) + \log \left(e^{(-1 \cdot 1 + 1)_*}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\\ \mathbf{elif}\;x \le 0.007640382299006293:\\ \;\;\;\;(\left(\frac{-1}{3} \cdot x\right) \cdot \left(x \cdot x\right) + \left((\frac{2}{15} \cdot \left({x}^{5}\right) + x)_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\left(-1 + \frac{\frac{2}{\sqrt[3]{1 + e^{x \cdot -2}}}}{\sqrt[3]{1 + e^{x \cdot -2}} \cdot \sqrt[3]{1 + e^{x \cdot -2}}}\right) + \log \left(e^{(-1 \cdot 1 + 1)_*}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;x \le -0.007589146813113095:\\
\;\;\;\;\left(\sqrt[3]{\left(-1 + \frac{\frac{2}{\sqrt[3]{1 + e^{x \cdot -2}}}}{\sqrt[3]{1 + e^{x \cdot -2}} \cdot \sqrt[3]{1 + e^{x \cdot -2}}}\right) + \log \left(e^{(-1 \cdot 1 + 1)_*}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\\

\mathbf{elif}\;x \le 0.007640382299006293:\\
\;\;\;\;(\left(\frac{-1}{3} \cdot x\right) \cdot \left(x \cdot x\right) + \left((\frac{2}{15} \cdot \left({x}^{5}\right) + x)_*\right))_*\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{\left(-1 + \frac{\frac{2}{\sqrt[3]{1 + e^{x \cdot -2}}}}{\sqrt[3]{1 + e^{x \cdot -2}} \cdot \sqrt[3]{1 + e^{x \cdot -2}}}\right) + \log \left(e^{(-1 \cdot 1 + 1)_*}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r19635307 = 2.0;
        double r19635308 = 1.0;
        double r19635309 = -2.0;
        double r19635310 = x;
        double r19635311 = r19635309 * r19635310;
        double r19635312 = exp(r19635311);
        double r19635313 = r19635308 + r19635312;
        double r19635314 = r19635307 / r19635313;
        double r19635315 = r19635314 - r19635308;
        return r19635315;
}

double f(double x, double __attribute__((unused)) y) {
        double r19635316 = x;
        double r19635317 = -0.007589146813113095;
        bool r19635318 = r19635316 <= r19635317;
        double r19635319 = -1.0;
        double r19635320 = 2.0;
        double r19635321 = 1.0;
        double r19635322 = -2.0;
        double r19635323 = r19635316 * r19635322;
        double r19635324 = exp(r19635323);
        double r19635325 = r19635321 + r19635324;
        double r19635326 = cbrt(r19635325);
        double r19635327 = r19635320 / r19635326;
        double r19635328 = r19635326 * r19635326;
        double r19635329 = r19635327 / r19635328;
        double r19635330 = r19635319 + r19635329;
        double r19635331 = fma(r19635319, r19635321, r19635321);
        double r19635332 = exp(r19635331);
        double r19635333 = log(r19635332);
        double r19635334 = r19635330 + r19635333;
        double r19635335 = cbrt(r19635334);
        double r19635336 = r19635320 / r19635325;
        double r19635337 = r19635336 - r19635321;
        double r19635338 = exp(r19635337);
        double r19635339 = log(r19635338);
        double r19635340 = cbrt(r19635339);
        double r19635341 = r19635335 * r19635340;
        double r19635342 = r19635341 * r19635340;
        double r19635343 = 0.007640382299006293;
        bool r19635344 = r19635316 <= r19635343;
        double r19635345 = -0.3333333333333333;
        double r19635346 = r19635345 * r19635316;
        double r19635347 = r19635316 * r19635316;
        double r19635348 = 0.13333333333333333;
        double r19635349 = 5.0;
        double r19635350 = pow(r19635316, r19635349);
        double r19635351 = fma(r19635348, r19635350, r19635316);
        double r19635352 = fma(r19635346, r19635347, r19635351);
        double r19635353 = r19635344 ? r19635352 : r19635342;
        double r19635354 = r19635318 ? r19635342 : r19635353;
        return r19635354;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Split input into 2 regimes
  2. if x < -0.007589146813113095 or 0.007640382299006293 < x

    1. Initial program 0.0

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

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}}}\right)} - \log \left(e^{1}\right)\]
    5. Applied diff-log0.0

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

      \[\leadsto \log \color{blue}{\left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt0.0

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

      \[\leadsto \left(\sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - \color{blue}{1 \cdot 1}}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    11. Applied add-cube-cbrt0.0

      \[\leadsto \left(\sqrt[3]{\log \left(e^{\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 \cdot 1}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    12. Applied add-sqr-sqrt0.0

      \[\leadsto \left(\sqrt[3]{\log \left(e^{\frac{\color{blue}{\sqrt{2} \cdot \sqrt{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 \cdot 1}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    13. Applied times-frac0.0

      \[\leadsto \left(\sqrt[3]{\log \left(e^{\color{blue}{\frac{\sqrt{2}}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \frac{\sqrt{2}}{\sqrt[3]{1 + e^{-2 \cdot x}}}} - 1 \cdot 1}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    14. Applied prod-diff0.0

      \[\leadsto \left(\sqrt[3]{\log \left(e^{\color{blue}{(\left(\frac{\sqrt{2}}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}\right) \cdot \left(\frac{\sqrt{2}}{\sqrt[3]{1 + e^{-2 \cdot x}}}\right) + \left(-1 \cdot 1\right))_* + (\left(-1\right) \cdot 1 + \left(1 \cdot 1\right))_*}}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    15. Applied exp-sum0.0

      \[\leadsto \left(\sqrt[3]{\log \color{blue}{\left(e^{(\left(\frac{\sqrt{2}}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}\right) \cdot \left(\frac{\sqrt{2}}{\sqrt[3]{1 + e^{-2 \cdot x}}}\right) + \left(-1 \cdot 1\right))_*} \cdot e^{(\left(-1\right) \cdot 1 + \left(1 \cdot 1\right))_*}\right)}} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    16. Applied log-prod0.0

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

      \[\leadsto \left(\sqrt[3]{\color{blue}{\left(-1 + \frac{\frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}}}}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}\right)} + \log \left(e^{(\left(-1\right) \cdot 1 + \left(1 \cdot 1\right))_*}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]

    if -0.007589146813113095 < x < 0.007640382299006293

    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}{(\left(x \cdot \frac{-1}{3}\right) \cdot \left(x \cdot x\right) + \left((\frac{2}{15} \cdot \left({x}^{5}\right) + x)_*\right))_*}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.007589146813113095:\\ \;\;\;\;\left(\sqrt[3]{\left(-1 + \frac{\frac{2}{\sqrt[3]{1 + e^{x \cdot -2}}}}{\sqrt[3]{1 + e^{x \cdot -2}} \cdot \sqrt[3]{1 + e^{x \cdot -2}}}\right) + \log \left(e^{(-1 \cdot 1 + 1)_*}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\\ \mathbf{elif}\;x \le 0.007640382299006293:\\ \;\;\;\;(\left(\frac{-1}{3} \cdot x\right) \cdot \left(x \cdot x\right) + \left((\frac{2}{15} \cdot \left({x}^{5}\right) + x)_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\left(-1 + \frac{\frac{2}{\sqrt[3]{1 + e^{x \cdot -2}}}}{\sqrt[3]{1 + e^{x \cdot -2}} \cdot \sqrt[3]{1 + e^{x \cdot -2}}}\right) + \log \left(e^{(-1 \cdot 1 + 1)_*}\right)} \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\right) \cdot \sqrt[3]{\log \left(e^{\frac{2}{1 + e^{x \cdot -2}} - 1}\right)}\\ \end{array}\]

Reproduce

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