Average Error: 30.0 → 0.8
Time: 3.0s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -3767.415667512136224104324355721473693848 \lor \neg \left(-2 \cdot x \le 5.528584736659382565518668938546857280105 \cdot 10^{-21}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\frac{2}{1 + e^{-2 \cdot x}} \cdot \left(1 + \frac{2}{1 + e^{-2 \cdot x}}\right) + 1 \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -3767.415667512136224104324355721473693848 \lor \neg \left(-2 \cdot x \le 5.528584736659382565518668938546857280105 \cdot 10^{-21}\right):\\
\;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\frac{2}{1 + e^{-2 \cdot x}} \cdot \left(1 + \frac{2}{1 + e^{-2 \cdot x}}\right) + 1 \cdot 1}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r50816 = 2.0;
        double r50817 = 1.0;
        double r50818 = -2.0;
        double r50819 = x;
        double r50820 = r50818 * r50819;
        double r50821 = exp(r50820);
        double r50822 = r50817 + r50821;
        double r50823 = r50816 / r50822;
        double r50824 = r50823 - r50817;
        return r50824;
}

double f(double x, double __attribute__((unused)) y) {
        double r50825 = -2.0;
        double r50826 = x;
        double r50827 = r50825 * r50826;
        double r50828 = -3767.415667512136;
        bool r50829 = r50827 <= r50828;
        double r50830 = 5.5285847366593826e-21;
        bool r50831 = r50827 <= r50830;
        double r50832 = !r50831;
        bool r50833 = r50829 || r50832;
        double r50834 = 2.0;
        double r50835 = 1.0;
        double r50836 = exp(r50827);
        double r50837 = r50835 + r50836;
        double r50838 = r50834 / r50837;
        double r50839 = 3.0;
        double r50840 = pow(r50838, r50839);
        double r50841 = pow(r50835, r50839);
        double r50842 = r50840 - r50841;
        double r50843 = r50835 + r50838;
        double r50844 = r50838 * r50843;
        double r50845 = r50835 * r50835;
        double r50846 = r50844 + r50845;
        double r50847 = r50842 / r50846;
        double r50848 = r50835 * r50826;
        double r50849 = 5.551115123125783e-17;
        double r50850 = 4.0;
        double r50851 = pow(r50826, r50850);
        double r50852 = r50849 * r50851;
        double r50853 = 0.33333333333333337;
        double r50854 = pow(r50826, r50839);
        double r50855 = r50853 * r50854;
        double r50856 = r50852 + r50855;
        double r50857 = r50848 - r50856;
        double r50858 = r50833 ? r50847 : r50857;
        return r50858;
}

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) < -3767.415667512136 or 5.5285847366593826e-21 < (* -2.0 x)

    1. Initial program 1.1

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

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

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

    if -3767.415667512136 < (* -2.0 x) < 5.5285847366593826e-21

    1. Initial program 59.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -3767.415667512136224104324355721473693848 \lor \neg \left(-2 \cdot x \le 5.528584736659382565518668938546857280105 \cdot 10^{-21}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\frac{2}{1 + e^{-2 \cdot x}} \cdot \left(1 + \frac{2}{1 + e^{-2 \cdot x}}\right) + 1 \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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