Average Error: 29.2 → 0.0
Time: 6.2s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.00188039921904495084:\\ \;\;\;\;\log \left(e^{\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} - 1}\right)\\ \mathbf{elif}\;-2 \cdot x \le 0.00100794665255993514:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} - 1\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.00188039921904495084:\\
\;\;\;\;\log \left(e^{\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} - 1}\right)\\

\mathbf{elif}\;-2 \cdot x \le 0.00100794665255993514:\\
\;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} - 1\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r46804 = 2.0;
        double r46805 = 1.0;
        double r46806 = -2.0;
        double r46807 = x;
        double r46808 = r46806 * r46807;
        double r46809 = exp(r46808);
        double r46810 = r46805 + r46809;
        double r46811 = r46804 / r46810;
        double r46812 = r46811 - r46805;
        return r46812;
}

double f(double x, double __attribute__((unused)) y) {
        double r46813 = -2.0;
        double r46814 = x;
        double r46815 = r46813 * r46814;
        double r46816 = -0.0018803992190449508;
        bool r46817 = r46815 <= r46816;
        double r46818 = 2.0;
        double r46819 = 1.0;
        double r46820 = exp(r46815);
        double r46821 = r46819 + r46820;
        double r46822 = sqrt(r46821);
        double r46823 = r46818 / r46822;
        double r46824 = cbrt(r46822);
        double r46825 = r46824 * r46824;
        double r46826 = r46823 / r46825;
        double r46827 = r46826 / r46824;
        double r46828 = r46827 - r46819;
        double r46829 = exp(r46828);
        double r46830 = log(r46829);
        double r46831 = 0.0010079466525599351;
        bool r46832 = r46815 <= r46831;
        double r46833 = r46819 * r46814;
        double r46834 = 5.551115123125783e-17;
        double r46835 = 4.0;
        double r46836 = pow(r46814, r46835);
        double r46837 = r46834 * r46836;
        double r46838 = 0.33333333333333337;
        double r46839 = 3.0;
        double r46840 = pow(r46814, r46839);
        double r46841 = r46838 * r46840;
        double r46842 = r46837 + r46841;
        double r46843 = r46833 - r46842;
        double r46844 = r46832 ? r46843 : r46828;
        double r46845 = r46817 ? r46830 : r46844;
        return r46845;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

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

    1. Initial program 0.0

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.0

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.1

      \[\leadsto \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\color{blue}{\left(\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}\right) \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}} - 1\]
    7. Applied associate-/r*0.1

      \[\leadsto \color{blue}{\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}} - 1\]
    8. Using strategy rm
    9. Applied add-log-exp0.1

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

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

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

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

    if -0.0018803992190449508 < (* -2.0 x) < 0.0010079466525599351

    1. Initial program 59.0

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

      \[\leadsto \color{blue}{1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)}\]

    if 0.0010079466525599351 < (* -2.0 x)

    1. Initial program 0.1

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.1

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.1

      \[\leadsto \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\color{blue}{\left(\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}\right) \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}} - 1\]
    7. Applied associate-/r*0.1

      \[\leadsto \color{blue}{\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}} - 1\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.00188039921904495084:\\ \;\;\;\;\log \left(e^{\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} - 1}\right)\\ \mathbf{elif}\;-2 \cdot x \le 0.00100794665255993514:\\ \;\;\;\;1 \cdot x - \left(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}} \cdot \sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}}}{\sqrt[3]{\sqrt{1 + e^{-2 \cdot x}}}} - 1\\ \end{array}\]

Reproduce

herbie shell --seed 2020027 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  :precision binary64
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))