Average Error: 29.8 → 0.3
Time: 13.6s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le \frac{-6901245910886571}{34359738368} \lor \neg \left(-2 \cdot x \le \frac{4011494913400865}{4611686018427387904}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(\frac{1}{18014398509481984} \cdot {x}^{4} + \frac{3002399751580331}{9007199254740992} \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le \frac{-6901245910886571}{34359738368} \lor \neg \left(-2 \cdot x \le \frac{4011494913400865}{4611686018427387904}\right):\\
\;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot x - \left(\frac{1}{18014398509481984} \cdot {x}^{4} + \frac{3002399751580331}{9007199254740992} \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r55810 = 2.0;
        double r55811 = 1.0;
        double r55812 = -2.0;
        double r55813 = x;
        double r55814 = r55812 * r55813;
        double r55815 = exp(r55814);
        double r55816 = r55811 + r55815;
        double r55817 = r55810 / r55816;
        double r55818 = r55817 - r55811;
        return r55818;
}

double f(double x, double __attribute__((unused)) y) {
        double r55819 = -2.0;
        double r55820 = x;
        double r55821 = r55819 * r55820;
        double r55822 = -6901245910886571.0;
        double r55823 = 34359738368.0;
        double r55824 = r55822 / r55823;
        bool r55825 = r55821 <= r55824;
        double r55826 = 4011494913400865.0;
        double r55827 = 4.611686018427388e+18;
        double r55828 = r55826 / r55827;
        bool r55829 = r55821 <= r55828;
        double r55830 = !r55829;
        bool r55831 = r55825 || r55830;
        double r55832 = 2.0;
        double r55833 = 1.0;
        double r55834 = exp(r55821);
        double r55835 = r55833 + r55834;
        double r55836 = r55832 / r55835;
        double r55837 = 3.0;
        double r55838 = pow(r55836, r55837);
        double r55839 = pow(r55833, r55837);
        double r55840 = r55838 - r55839;
        double r55841 = r55834 + r55833;
        double r55842 = r55832 / r55841;
        double r55843 = r55833 + r55842;
        double r55844 = r55842 * r55843;
        double r55845 = r55833 * r55833;
        double r55846 = r55844 + r55845;
        double r55847 = r55840 / r55846;
        double r55848 = r55833 * r55820;
        double r55849 = 18014398509481984.0;
        double r55850 = r55833 / r55849;
        double r55851 = 4.0;
        double r55852 = pow(r55820, r55851);
        double r55853 = r55850 * r55852;
        double r55854 = 3002399751580331.0;
        double r55855 = 9007199254740992.0;
        double r55856 = r55854 / r55855;
        double r55857 = pow(r55820, r55837);
        double r55858 = r55856 * r55857;
        double r55859 = r55853 + r55858;
        double r55860 = r55848 - r55859;
        double r55861 = r55831 ? r55847 : r55860;
        return r55861;
}

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) < -200852.69093066952 or 0.0008698543000047537 < (* -2.0 x)

    1. Initial program 0.0

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

      \[\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. Simplified0.0

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

    if -200852.69093066952 < (* -2.0 x) < 0.0008698543000047537

    1. Initial program 58.5

      \[\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. Simplified0.5

      \[\leadsto \color{blue}{1 \cdot x - \left(\frac{1}{18014398509481984} \cdot {x}^{4} + \frac{3002399751580331}{9007199254740992} \cdot {x}^{3}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le \frac{-6901245910886571}{34359738368} \lor \neg \left(-2 \cdot x \le \frac{4011494913400865}{4611686018427387904}\right):\\ \;\;\;\;\frac{{\left(\frac{2}{1 + e^{-2 \cdot x}}\right)}^{3} - {1}^{3}}{\frac{2}{e^{-2 \cdot x} + 1} \cdot \left(1 + \frac{2}{e^{-2 \cdot x} + 1}\right) + 1 \cdot 1}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x - \left(\frac{1}{18014398509481984} \cdot {x}^{4} + \frac{3002399751580331}{9007199254740992} \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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