Average Error: 29.6 → 0.2
Time: 37.7s
Precision: 64
\[\frac{2.0}{1.0 + e^{-2.0 \cdot x}} - 1.0\]
\[\begin{array}{l} \mathbf{if}\;-2.0 \cdot x \le -1972.3938625414924:\\ \;\;\;\;\frac{\frac{2.0}{\sqrt{e^{-2.0 \cdot x} + 1.0}}}{\sqrt{e^{-2.0 \cdot x} + 1.0}} - 1.0\\ \mathbf{elif}\;-2.0 \cdot x \le 0.0002071702113622589:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(-\left(0.33333333333333337 \cdot x + \left(x \cdot x\right) \cdot 5.551115123125783 \cdot 10^{-17}\right)\right) + 1.0 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2.0}{\sqrt{e^{-2.0 \cdot x} + 1.0}}}{\sqrt{e^{-2.0 \cdot x} + 1.0}} - 1.0\\ \end{array}\]
\frac{2.0}{1.0 + e^{-2.0 \cdot x}} - 1.0
\begin{array}{l}
\mathbf{if}\;-2.0 \cdot x \le -1972.3938625414924:\\
\;\;\;\;\frac{\frac{2.0}{\sqrt{e^{-2.0 \cdot x} + 1.0}}}{\sqrt{e^{-2.0 \cdot x} + 1.0}} - 1.0\\

\mathbf{elif}\;-2.0 \cdot x \le 0.0002071702113622589:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(-\left(0.33333333333333337 \cdot x + \left(x \cdot x\right) \cdot 5.551115123125783 \cdot 10^{-17}\right)\right) + 1.0 \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{2.0}{\sqrt{e^{-2.0 \cdot x} + 1.0}}}{\sqrt{e^{-2.0 \cdot x} + 1.0}} - 1.0\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r2683267 = 2.0;
        double r2683268 = 1.0;
        double r2683269 = -2.0;
        double r2683270 = x;
        double r2683271 = r2683269 * r2683270;
        double r2683272 = exp(r2683271);
        double r2683273 = r2683268 + r2683272;
        double r2683274 = r2683267 / r2683273;
        double r2683275 = r2683274 - r2683268;
        return r2683275;
}

double f(double x, double __attribute__((unused)) y) {
        double r2683276 = -2.0;
        double r2683277 = x;
        double r2683278 = r2683276 * r2683277;
        double r2683279 = -1972.3938625414924;
        bool r2683280 = r2683278 <= r2683279;
        double r2683281 = 2.0;
        double r2683282 = exp(r2683278);
        double r2683283 = 1.0;
        double r2683284 = r2683282 + r2683283;
        double r2683285 = sqrt(r2683284);
        double r2683286 = r2683281 / r2683285;
        double r2683287 = r2683286 / r2683285;
        double r2683288 = r2683287 - r2683283;
        double r2683289 = 0.0002071702113622589;
        bool r2683290 = r2683278 <= r2683289;
        double r2683291 = r2683277 * r2683277;
        double r2683292 = 0.33333333333333337;
        double r2683293 = r2683292 * r2683277;
        double r2683294 = 5.551115123125783e-17;
        double r2683295 = r2683291 * r2683294;
        double r2683296 = r2683293 + r2683295;
        double r2683297 = -r2683296;
        double r2683298 = r2683291 * r2683297;
        double r2683299 = r2683283 * r2683277;
        double r2683300 = r2683298 + r2683299;
        double r2683301 = r2683290 ? r2683300 : r2683288;
        double r2683302 = r2683280 ? r2683288 : r2683301;
        return r2683302;
}

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) < -1972.3938625414924 or 0.0002071702113622589 < (* -2.0 x)

    1. Initial program 0.0

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

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

      \[\leadsto \color{blue}{\frac{\frac{2.0}{\sqrt{1.0 + e^{-2.0 \cdot x}}}}{\sqrt{1.0 + e^{-2.0 \cdot x}}}} - 1.0\]

    if -1972.3938625414924 < (* -2.0 x) < 0.0002071702113622589

    1. Initial program 58.6

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

      \[\leadsto \color{blue}{1.0 \cdot x - \left(0.33333333333333337 \cdot {x}^{3} + 5.551115123125783 \cdot 10^{-17} \cdot {x}^{4}\right)}\]
    3. Simplified0.3

      \[\leadsto \color{blue}{x \cdot \left(1.0 - 0.33333333333333337 \cdot \left(x \cdot x\right)\right) - \left(5.551115123125783 \cdot 10^{-17} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)}\]
    4. Using strategy rm
    5. Applied sub-neg0.3

      \[\leadsto x \cdot \color{blue}{\left(1.0 + \left(-0.33333333333333337 \cdot \left(x \cdot x\right)\right)\right)} - \left(5.551115123125783 \cdot 10^{-17} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\]
    6. Applied distribute-lft-in0.3

      \[\leadsto \color{blue}{\left(x \cdot 1.0 + x \cdot \left(-0.33333333333333337 \cdot \left(x \cdot x\right)\right)\right)} - \left(5.551115123125783 \cdot 10^{-17} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\]
    7. Applied associate--l+0.3

      \[\leadsto \color{blue}{x \cdot 1.0 + \left(x \cdot \left(-0.33333333333333337 \cdot \left(x \cdot x\right)\right) - \left(5.551115123125783 \cdot 10^{-17} \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\right)}\]
    8. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2.0 \cdot x \le -1972.3938625414924:\\ \;\;\;\;\frac{\frac{2.0}{\sqrt{e^{-2.0 \cdot x} + 1.0}}}{\sqrt{e^{-2.0 \cdot x} + 1.0}} - 1.0\\ \mathbf{elif}\;-2.0 \cdot x \le 0.0002071702113622589:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(-\left(0.33333333333333337 \cdot x + \left(x \cdot x\right) \cdot 5.551115123125783 \cdot 10^{-17}\right)\right) + 1.0 \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2.0}{\sqrt{e^{-2.0 \cdot x} + 1.0}}}{\sqrt{e^{-2.0 \cdot x} + 1.0}} - 1.0\\ \end{array}\]

Reproduce

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