Average Error: 29.3 → 0.2
Time: 14.3s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -107280.0323081880924291908740997314453125:\\ \;\;\;\;\frac{\frac{2}{\sqrt{e^{-2 \cdot x} + 1}}}{\sqrt{e^{-2 \cdot x} + 1}} - 1\\ \mathbf{elif}\;-2 \cdot x \le 9.922166503853619421490067642466215147579 \cdot 10^{-5}:\\ \;\;\;\;1 \cdot x - \left(x \cdot x\right) \cdot \left(0.3333333333333333703407674875052180141211 \cdot x + \left(x \cdot x\right) \cdot 5.5511151231257827021181583404541015625 \cdot 10^{-17}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{\sqrt{e^{-2 \cdot x} + 1}}}{\sqrt{e^{-2 \cdot x} + 1}} - 1\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -107280.0323081880924291908740997314453125:\\
\;\;\;\;\frac{\frac{2}{\sqrt{e^{-2 \cdot x} + 1}}}{\sqrt{e^{-2 \cdot x} + 1}} - 1\\

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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r2131642 = 2.0;
        double r2131643 = 1.0;
        double r2131644 = -2.0;
        double r2131645 = x;
        double r2131646 = r2131644 * r2131645;
        double r2131647 = exp(r2131646);
        double r2131648 = r2131643 + r2131647;
        double r2131649 = r2131642 / r2131648;
        double r2131650 = r2131649 - r2131643;
        return r2131650;
}

double f(double x, double __attribute__((unused)) y) {
        double r2131651 = -2.0;
        double r2131652 = x;
        double r2131653 = r2131651 * r2131652;
        double r2131654 = -107280.03230818809;
        bool r2131655 = r2131653 <= r2131654;
        double r2131656 = 2.0;
        double r2131657 = exp(r2131653);
        double r2131658 = 1.0;
        double r2131659 = r2131657 + r2131658;
        double r2131660 = sqrt(r2131659);
        double r2131661 = r2131656 / r2131660;
        double r2131662 = r2131661 / r2131660;
        double r2131663 = r2131662 - r2131658;
        double r2131664 = 9.92216650385362e-05;
        bool r2131665 = r2131653 <= r2131664;
        double r2131666 = r2131658 * r2131652;
        double r2131667 = r2131652 * r2131652;
        double r2131668 = 0.33333333333333337;
        double r2131669 = r2131668 * r2131652;
        double r2131670 = 5.551115123125783e-17;
        double r2131671 = r2131667 * r2131670;
        double r2131672 = r2131669 + r2131671;
        double r2131673 = r2131667 * r2131672;
        double r2131674 = r2131666 - r2131673;
        double r2131675 = r2131665 ? r2131674 : r2131663;
        double r2131676 = r2131655 ? r2131663 : r2131675;
        return r2131676;
}

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 2 regimes
  2. if (* -2.0 x) < -107280.03230818809 or 9.92216650385362e-05 < (* -2.0 x)

    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\]

    if -107280.03230818809 < (* -2.0 x) < 9.92216650385362e-05

    1. Initial program 58.9

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

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

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    5. Taylor expanded around 0 0.4

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

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

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

Reproduce

herbie shell --seed 2019171 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))