Average Error: 29.4 → 0.6
Time: 20.4s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -25682837.7315442897379398345947265625:\\ \;\;\;\;\frac{\frac{2}{{1}^{3} + {\left(e^{-2 \cdot x}\right)}^{3}} \cdot \left(\left(e^{-2 \cdot x} \cdot \left(e^{-2 \cdot x} - 1\right) + 1 \cdot 1\right) \cdot \frac{2}{e^{-2 \cdot x} + 1}\right) - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\ \mathbf{elif}\;-2 \cdot x \le 5.646048818049403140931275689928456329447 \cdot 10^{-9}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(0.3333333333333333703407674875052180141211 + 5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{\frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}}{\sqrt{\sqrt[3]{1 + e^{-2 \cdot x}}} \cdot \sqrt{\sqrt[3]{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 -25682837.7315442897379398345947265625:\\
\;\;\;\;\frac{\frac{2}{{1}^{3} + {\left(e^{-2 \cdot x}\right)}^{3}} \cdot \left(\left(e^{-2 \cdot x} \cdot \left(e^{-2 \cdot x} - 1\right) + 1 \cdot 1\right) \cdot \frac{2}{e^{-2 \cdot x} + 1}\right) - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\\

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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r43486 = 2.0;
        double r43487 = 1.0;
        double r43488 = -2.0;
        double r43489 = x;
        double r43490 = r43488 * r43489;
        double r43491 = exp(r43490);
        double r43492 = r43487 + r43491;
        double r43493 = r43486 / r43492;
        double r43494 = r43493 - r43487;
        return r43494;
}

double f(double x, double __attribute__((unused)) y) {
        double r43495 = -2.0;
        double r43496 = x;
        double r43497 = r43495 * r43496;
        double r43498 = -25682837.73154429;
        bool r43499 = r43497 <= r43498;
        double r43500 = 2.0;
        double r43501 = 1.0;
        double r43502 = 3.0;
        double r43503 = pow(r43501, r43502);
        double r43504 = exp(r43497);
        double r43505 = pow(r43504, r43502);
        double r43506 = r43503 + r43505;
        double r43507 = r43500 / r43506;
        double r43508 = r43504 - r43501;
        double r43509 = r43504 * r43508;
        double r43510 = r43501 * r43501;
        double r43511 = r43509 + r43510;
        double r43512 = r43504 + r43501;
        double r43513 = r43500 / r43512;
        double r43514 = r43511 * r43513;
        double r43515 = r43507 * r43514;
        double r43516 = r43515 - r43510;
        double r43517 = r43501 + r43504;
        double r43518 = r43500 / r43517;
        double r43519 = r43518 + r43501;
        double r43520 = r43516 / r43519;
        double r43521 = 5.646048818049403e-09;
        bool r43522 = r43497 <= r43521;
        double r43523 = r43501 * r43496;
        double r43524 = pow(r43496, r43502);
        double r43525 = 0.33333333333333337;
        double r43526 = 5.551115123125783e-17;
        double r43527 = r43526 * r43496;
        double r43528 = r43525 + r43527;
        double r43529 = r43524 * r43528;
        double r43530 = r43523 - r43529;
        double r43531 = r43518 * r43518;
        double r43532 = r43531 - r43510;
        double r43533 = cbrt(r43517);
        double r43534 = r43533 * r43533;
        double r43535 = r43500 / r43534;
        double r43536 = sqrt(r43533);
        double r43537 = r43536 * r43536;
        double r43538 = r43535 / r43537;
        double r43539 = r43538 + r43501;
        double r43540 = r43532 / r43539;
        double r43541 = r43522 ? r43530 : r43540;
        double r43542 = r43499 ? r43520 : r43541;
        return r43542;
}

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) < -25682837.73154429

    1. Initial program 0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied flip--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. Using strategy rm
    5. Applied flip3-+0

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

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

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

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

    if -25682837.73154429 < (* -2.0 x) < 5.646048818049403e-09

    1. Initial program 58.5

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

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

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

    if 5.646048818049403e-09 < (* -2.0 x)

    1. Initial program 0.4

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

      \[\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. Using strategy rm
    5. Applied add-cube-cbrt0.4

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\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}\]
    6. Applied associate-/r*0.4

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\color{blue}{\frac{\frac{2}{\sqrt[3]{1 + e^{-2 \cdot x}} \cdot \sqrt[3]{1 + e^{-2 \cdot x}}}}{\sqrt[3]{1 + e^{-2 \cdot x}}}} + 1}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt0.4

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

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

Reproduce

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