Average Error: 29.1 → 0.4
Time: 3.0s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -14207516.1141591389 \lor \neg \left(-2 \cdot x \le 3.6425271859424674 \cdot 10^{-6}\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(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -14207516.1141591389 \lor \neg \left(-2 \cdot x \le 3.6425271859424674 \cdot 10^{-6}\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(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r47772 = 2.0;
        double r47773 = 1.0;
        double r47774 = -2.0;
        double r47775 = x;
        double r47776 = r47774 * r47775;
        double r47777 = exp(r47776);
        double r47778 = r47773 + r47777;
        double r47779 = r47772 / r47778;
        double r47780 = r47779 - r47773;
        return r47780;
}

double f(double x, double __attribute__((unused)) y) {
        double r47781 = -2.0;
        double r47782 = x;
        double r47783 = r47781 * r47782;
        double r47784 = -14207516.114159139;
        bool r47785 = r47783 <= r47784;
        double r47786 = 3.6425271859424674e-06;
        bool r47787 = r47783 <= r47786;
        double r47788 = !r47787;
        bool r47789 = r47785 || r47788;
        double r47790 = 2.0;
        double r47791 = 1.0;
        double r47792 = exp(r47783);
        double r47793 = r47791 + r47792;
        double r47794 = r47790 / r47793;
        double r47795 = 3.0;
        double r47796 = pow(r47794, r47795);
        double r47797 = pow(r47791, r47795);
        double r47798 = r47796 - r47797;
        double r47799 = r47792 + r47791;
        double r47800 = r47790 / r47799;
        double r47801 = r47791 + r47800;
        double r47802 = r47800 * r47801;
        double r47803 = r47791 * r47791;
        double r47804 = r47802 + r47803;
        double r47805 = r47798 / r47804;
        double r47806 = r47791 * r47782;
        double r47807 = 5.551115123125783e-17;
        double r47808 = 4.0;
        double r47809 = pow(r47782, r47808);
        double r47810 = r47807 * r47809;
        double r47811 = 0.33333333333333337;
        double r47812 = pow(r47782, r47795);
        double r47813 = r47811 * r47812;
        double r47814 = r47810 + r47813;
        double r47815 = r47806 - r47814;
        double r47816 = r47789 ? r47805 : r47815;
        return r47816;
}

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) < -14207516.114159139 or 3.6425271859424674e-06 < (* -2.0 x)

    1. Initial program 0.1

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied flip3--0.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. 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 -14207516.114159139 < (* -2.0 x) < 3.6425271859424674e-06

    1. Initial program 58.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -14207516.1141591389 \lor \neg \left(-2 \cdot x \le 3.6425271859424674 \cdot 10^{-6}\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(5.55112 \cdot 10^{-17} \cdot {x}^{4} + 0.33333333333333337 \cdot {x}^{3}\right)\\ \end{array}\]

Reproduce

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