Average Error: 29.3 → 0.3
Time: 5.5s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -12083926.2470296454 \lor \neg \left(-2 \cdot x \le 8.21395792366333617 \cdot 10^{-4}\right):\\ \;\;\;\;\frac{\log \left(e^{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}} \cdot \left(2 \cdot \frac{2}{1 + e^{-2 \cdot x}}\right) - 1 \cdot 1}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + 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 -12083926.2470296454 \lor \neg \left(-2 \cdot x \le 8.21395792366333617 \cdot 10^{-4}\right):\\
\;\;\;\;\frac{\log \left(e^{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}} \cdot \left(2 \cdot \frac{2}{1 + e^{-2 \cdot x}}\right) - 1 \cdot 1}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + 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 r67693 = 2.0;
        double r67694 = 1.0;
        double r67695 = -2.0;
        double r67696 = x;
        double r67697 = r67695 * r67696;
        double r67698 = exp(r67697);
        double r67699 = r67694 + r67698;
        double r67700 = r67693 / r67699;
        double r67701 = r67700 - r67694;
        return r67701;
}

double f(double x, double __attribute__((unused)) y) {
        double r67702 = -2.0;
        double r67703 = x;
        double r67704 = r67702 * r67703;
        double r67705 = -12083926.247029645;
        bool r67706 = r67704 <= r67705;
        double r67707 = 0.0008213957923663336;
        bool r67708 = r67704 <= r67707;
        double r67709 = !r67708;
        bool r67710 = r67706 || r67709;
        double r67711 = 1.0;
        double r67712 = 1.0;
        double r67713 = exp(r67704);
        double r67714 = r67712 + r67713;
        double r67715 = sqrt(r67714);
        double r67716 = r67711 / r67715;
        double r67717 = 0.5;
        double r67718 = pow(r67714, r67717);
        double r67719 = r67716 / r67718;
        double r67720 = 2.0;
        double r67721 = r67720 / r67714;
        double r67722 = r67720 * r67721;
        double r67723 = r67719 * r67722;
        double r67724 = r67712 * r67712;
        double r67725 = r67723 - r67724;
        double r67726 = exp(r67725);
        double r67727 = log(r67726);
        double r67728 = r67721 + r67712;
        double r67729 = r67727 / r67728;
        double r67730 = r67712 * r67703;
        double r67731 = 5.551115123125783e-17;
        double r67732 = 4.0;
        double r67733 = pow(r67703, r67732);
        double r67734 = r67731 * r67733;
        double r67735 = 0.33333333333333337;
        double r67736 = 3.0;
        double r67737 = pow(r67703, r67736);
        double r67738 = r67735 * r67737;
        double r67739 = r67734 + r67738;
        double r67740 = r67730 - r67739;
        double r67741 = r67710 ? r67729 : r67740;
        return r67741;
}

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) < -12083926.247029645 or 0.0008213957923663336 < (* -2.0 x)

    1. Initial program 0.0

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

      \[\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 add-sqr-sqrt0.0

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    6. Applied *-un-lft-identity0.0

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{\color{blue}{1 \cdot 2}}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    7. Applied times-frac0.0

      \[\leadsto \frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \color{blue}{\left(\frac{1}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt{1 + e^{-2 \cdot x}}}\right)} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    8. Applied add-sqr-sqrt0.0

      \[\leadsto \frac{\frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} \cdot \left(\frac{1}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt{1 + e^{-2 \cdot x}}}\right) - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    9. Applied *-un-lft-identity0.0

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot 2}}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}} \cdot \left(\frac{1}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt{1 + e^{-2 \cdot x}}}\right) - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    10. Applied times-frac0.0

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt{1 + e^{-2 \cdot x}}}\right)} \cdot \left(\frac{1}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt{1 + e^{-2 \cdot x}}}\right) - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    11. Applied swap-sqr0.0

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{1}{\sqrt{1 + e^{-2 \cdot x}}}\right) \cdot \left(\frac{2}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt{1 + e^{-2 \cdot x}}}\right)} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    12. Simplified0.0

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}}} \cdot \left(\frac{2}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{2}{\sqrt{1 + e^{-2 \cdot x}}}\right) - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    13. Simplified0.0

      \[\leadsto \frac{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}} \cdot \color{blue}{\left(2 \cdot \frac{2}{1 + e^{-2 \cdot x}}\right)} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    14. Using strategy rm
    15. Applied add-log-exp0.0

      \[\leadsto \frac{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}} \cdot \left(2 \cdot \frac{2}{1 + e^{-2 \cdot x}}\right) - \color{blue}{\log \left(e^{1 \cdot 1}\right)}}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    16. Applied add-log-exp0.0

      \[\leadsto \frac{\color{blue}{\log \left(e^{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}} \cdot \left(2 \cdot \frac{2}{1 + e^{-2 \cdot x}}\right)}\right)} - \log \left(e^{1 \cdot 1}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    17. Applied diff-log0.0

      \[\leadsto \frac{\color{blue}{\log \left(\frac{e^{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}} \cdot \left(2 \cdot \frac{2}{1 + e^{-2 \cdot x}}\right)}}{e^{1 \cdot 1}}\right)}}{\frac{2}{1 + e^{-2 \cdot x}} + 1}\]
    18. Simplified0.0

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

    if -12083926.247029645 < (* -2.0 x) < 0.0008213957923663336

    1. Initial program 58.5

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

      \[\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.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -12083926.2470296454 \lor \neg \left(-2 \cdot x \le 8.21395792366333617 \cdot 10^{-4}\right):\\ \;\;\;\;\frac{\log \left(e^{\frac{\frac{1}{\sqrt{1 + e^{-2 \cdot x}}}}{{\left(1 + e^{-2 \cdot x}\right)}^{\frac{1}{2}}} \cdot \left(2 \cdot \frac{2}{1 + e^{-2 \cdot x}}\right) - 1 \cdot 1}\right)}{\frac{2}{1 + e^{-2 \cdot x}} + 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 2020065 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  :precision binary64
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))