Average Error: 29.2 → 0.2
Time: 22.4s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.00459821061185296253714938075063400901854:\\ \;\;\;\;\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1 \cdot 1}{1 + \frac{2}{e^{-2 \cdot x} + 1}}\\ \mathbf{elif}\;-2 \cdot x \le 1.161789732782175467453026366524393816126 \cdot 10^{-12}:\\ \;\;\;\;1 \cdot x - \left(0.3333333333333333703407674875052180141211 \cdot x + \left(x \cdot x\right) \cdot 5.5511151231257827021181583404541015625 \cdot 10^{-17}\right) \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1 \cdot 1}{1 + \frac{2}{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.00459821061185296253714938075063400901854:\\
\;\;\;\;\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1 \cdot 1}{1 + \frac{2}{e^{-2 \cdot x} + 1}}\\

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

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

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r2472002 = 2.0;
        double r2472003 = 1.0;
        double r2472004 = -2.0;
        double r2472005 = x;
        double r2472006 = r2472004 * r2472005;
        double r2472007 = exp(r2472006);
        double r2472008 = r2472003 + r2472007;
        double r2472009 = r2472002 / r2472008;
        double r2472010 = r2472009 - r2472003;
        return r2472010;
}

double f(double x, double __attribute__((unused)) y) {
        double r2472011 = -2.0;
        double r2472012 = x;
        double r2472013 = r2472011 * r2472012;
        double r2472014 = -0.0045982106118529625;
        bool r2472015 = r2472013 <= r2472014;
        double r2472016 = 2.0;
        double r2472017 = exp(r2472013);
        double r2472018 = 1.0;
        double r2472019 = r2472017 + r2472018;
        double r2472020 = r2472016 / r2472019;
        double r2472021 = r2472020 * r2472020;
        double r2472022 = r2472018 * r2472018;
        double r2472023 = r2472021 - r2472022;
        double r2472024 = r2472018 + r2472020;
        double r2472025 = r2472023 / r2472024;
        double r2472026 = 1.1617897327821755e-12;
        bool r2472027 = r2472013 <= r2472026;
        double r2472028 = r2472018 * r2472012;
        double r2472029 = 0.33333333333333337;
        double r2472030 = r2472029 * r2472012;
        double r2472031 = r2472012 * r2472012;
        double r2472032 = 5.551115123125783e-17;
        double r2472033 = r2472031 * r2472032;
        double r2472034 = r2472030 + r2472033;
        double r2472035 = r2472034 * r2472031;
        double r2472036 = r2472028 - r2472035;
        double r2472037 = r2472027 ? r2472036 : r2472025;
        double r2472038 = r2472015 ? r2472025 : r2472037;
        return r2472038;
}

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) < -0.0045982106118529625 or 1.1617897327821755e-12 < (* -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 +-commutative0.4

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

    if -0.0045982106118529625 < (* -2.0 x) < 1.1617897327821755e-12

    1. Initial program 59.8

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

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

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

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

Reproduce

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