Average Error: 29.6 → 0.1
Time: 20.1s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.001478341405381730123969052925758660421707:\\ \;\;\;\;e^{\log \left(\frac{\frac{4}{{\left(e^{-2 \cdot x} + 1\right)}^{2}} - 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\right)}\\ \mathbf{elif}\;-2 \cdot x \le 1.202042202386769937275221194206142882877 \cdot 10^{-6}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{\frac{4}{{\left(e^{-2 \cdot x} + 1\right)}^{2}} - 1} \cdot \sqrt[3]{\frac{4}{{\left(e^{-2 \cdot x} + 1\right)}^{2}} - 1}}{\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} + 1}}}{\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} + 1}} \cdot \frac{\sqrt[3]{\frac{4}{{\left(e^{-2 \cdot x} + 1\right)}^{2}} - 1}}{\sqrt[3]{\frac{2}{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.001478341405381730123969052925758660421707:\\
\;\;\;\;e^{\log \left(\frac{\frac{4}{{\left(e^{-2 \cdot x} + 1\right)}^{2}} - 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\right)}\\

\mathbf{elif}\;-2 \cdot x \le 1.202042202386769937275221194206142882877 \cdot 10^{-6}:\\
\;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r34524 = 2.0;
        double r34525 = 1.0;
        double r34526 = -2.0;
        double r34527 = x;
        double r34528 = r34526 * r34527;
        double r34529 = exp(r34528);
        double r34530 = r34525 + r34529;
        double r34531 = r34524 / r34530;
        double r34532 = r34531 - r34525;
        return r34532;
}

double f(double x, double __attribute__((unused)) y) {
        double r34533 = -2.0;
        double r34534 = x;
        double r34535 = r34533 * r34534;
        double r34536 = -0.0014783414053817301;
        bool r34537 = r34535 <= r34536;
        double r34538 = 4.0;
        double r34539 = exp(r34535);
        double r34540 = 1.0;
        double r34541 = r34539 + r34540;
        double r34542 = 2.0;
        double r34543 = pow(r34541, r34542);
        double r34544 = r34538 / r34543;
        double r34545 = r34544 - r34540;
        double r34546 = 2.0;
        double r34547 = r34540 + r34539;
        double r34548 = r34546 / r34547;
        double r34549 = r34548 + r34540;
        double r34550 = r34545 / r34549;
        double r34551 = log(r34550);
        double r34552 = exp(r34551);
        double r34553 = 1.20204220238677e-06;
        bool r34554 = r34535 <= r34553;
        double r34555 = r34540 * r34534;
        double r34556 = 5.551115123125783e-17;
        double r34557 = 4.0;
        double r34558 = pow(r34534, r34557);
        double r34559 = r34556 * r34558;
        double r34560 = 0.33333333333333337;
        double r34561 = 3.0;
        double r34562 = pow(r34534, r34561);
        double r34563 = r34560 * r34562;
        double r34564 = r34559 + r34563;
        double r34565 = r34555 - r34564;
        double r34566 = cbrt(r34545);
        double r34567 = r34566 * r34566;
        double r34568 = cbrt(r34549);
        double r34569 = r34567 / r34568;
        double r34570 = r34569 / r34568;
        double r34571 = r34566 / r34568;
        double r34572 = r34570 * r34571;
        double r34573 = r34554 ? r34565 : r34572;
        double r34574 = r34537 ? r34552 : r34573;
        return r34574;
}

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.0014783414053817301

    1. Initial program 0.0

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

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

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

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

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{1 + \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}}}\]
    8. Taylor expanded around inf 0.0

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

      \[\leadsto \frac{\color{blue}{\frac{4}{{\left(e^{-2 \cdot x} + 1\right)}^{2}} - 1}}{1 + \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}}\]
    10. Using strategy rm
    11. Applied add-exp-log1.0

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

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

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

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

    if -0.0014783414053817301 < (* -2.0 x) < 1.20204220238677e-06

    1. Initial program 59.5

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

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

    if 1.20204220238677e-06 < (* -2.0 x)

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}}\]
    4. Simplified0.2

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

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

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{1 + \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}}}\]
    8. Taylor expanded around inf 0.2

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

      \[\leadsto \frac{\color{blue}{\frac{4}{{\left(e^{-2 \cdot x} + 1\right)}^{2}} - 1}}{1 + \frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt0.2

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

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

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

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

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

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

Reproduce

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