Average Error: 29.4 → 0.1
Time: 23.9s
Precision: 64
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.006660654438723100610741933991221230826341:\\ \;\;\;\;\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \left(\sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)} \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\\ \mathbf{elif}\;-2 \cdot x \le 5.083912517384328794752684776980800052115 \cdot 10^{-5}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 0.3333333333333333703407674875052180141211\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{e^{\left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} + \sqrt{1}\right) \cdot \left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} - \sqrt{1}\right)}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)\\ \end{array}\]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \le -0.006660654438723100610741933991221230826341:\\
\;\;\;\;\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \left(\sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)} \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\\

\mathbf{elif}\;-2 \cdot x \le 5.083912517384328794752684776980800052115 \cdot 10^{-5}:\\
\;\;\;\;1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 0.3333333333333333703407674875052180141211\right)\\

\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{e^{\left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} + \sqrt{1}\right) \cdot \left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} - \sqrt{1}\right)}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)\\

\end{array}
double f(double x, double __attribute__((unused)) y) {
        double r61025 = 2.0;
        double r61026 = 1.0;
        double r61027 = -2.0;
        double r61028 = x;
        double r61029 = r61027 * r61028;
        double r61030 = exp(r61029);
        double r61031 = r61026 + r61030;
        double r61032 = r61025 / r61031;
        double r61033 = r61032 - r61026;
        return r61033;
}

double f(double x, double __attribute__((unused)) y) {
        double r61034 = -2.0;
        double r61035 = x;
        double r61036 = r61034 * r61035;
        double r61037 = -0.006660654438723101;
        bool r61038 = r61036 <= r61037;
        double r61039 = 2.0;
        double r61040 = 1.0;
        double r61041 = exp(r61036);
        double r61042 = r61040 + r61041;
        double r61043 = r61039 / r61042;
        double r61044 = r61043 - r61040;
        double r61045 = exp(r61044);
        double r61046 = sqrt(r61045);
        double r61047 = log(r61046);
        double r61048 = cbrt(r61047);
        double r61049 = r61048 * r61048;
        double r61050 = r61049 * r61048;
        double r61051 = r61047 + r61050;
        double r61052 = 5.083912517384329e-05;
        bool r61053 = r61036 <= r61052;
        double r61054 = r61040 * r61035;
        double r61055 = 3.0;
        double r61056 = pow(r61035, r61055);
        double r61057 = 5.551115123125783e-17;
        double r61058 = r61057 * r61035;
        double r61059 = 0.33333333333333337;
        double r61060 = r61058 + r61059;
        double r61061 = r61056 * r61060;
        double r61062 = r61054 - r61061;
        double r61063 = sqrt(r61039);
        double r61064 = sqrt(r61042);
        double r61065 = r61063 / r61064;
        double r61066 = sqrt(r61040);
        double r61067 = r61065 + r61066;
        double r61068 = r61065 - r61066;
        double r61069 = r61067 * r61068;
        double r61070 = exp(r61069);
        double r61071 = sqrt(r61070);
        double r61072 = log(r61071);
        double r61073 = r61072 + r61047;
        double r61074 = r61053 ? r61062 : r61073;
        double r61075 = r61038 ? r61051 : r61074;
        return r61075;
}

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 3 regimes
  2. if (* -2.0 x) < -0.006660654438723101

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-log-exp0.0

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

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

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

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

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

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

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

    if -0.006660654438723101 < (* -2.0 x) < 5.083912517384329e-05

    1. Initial program 59.2

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

      \[\leadsto \color{blue}{1 \cdot x - \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot {x}^{4} + 0.3333333333333333703407674875052180141211 \cdot {x}^{3}\right)}\]
    3. Simplified0.0

      \[\leadsto \color{blue}{1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 0.3333333333333333703407674875052180141211\right)}\]

    if 5.083912517384329e-05 < (* -2.0 x)

    1. Initial program 0.1

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

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

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

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

      \[\leadsto \log \color{blue}{\left(e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right)}\]
    7. Using strategy rm
    8. Applied add-sqr-sqrt0.1

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

      \[\leadsto \color{blue}{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt0.1

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

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

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

      \[\leadsto \log \left(\sqrt{e^{\color{blue}{\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} \cdot \frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}}} - \sqrt{1} \cdot \sqrt{1}}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)\]
    15. Applied difference-of-squares0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;-2 \cdot x \le -0.006660654438723100610741933991221230826341:\\ \;\;\;\;\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right) + \left(\sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)} \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\right) \cdot \sqrt[3]{\log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)}\\ \mathbf{elif}\;-2 \cdot x \le 5.083912517384328794752684776980800052115 \cdot 10^{-5}:\\ \;\;\;\;1 \cdot x - {x}^{3} \cdot \left(5.5511151231257827021181583404541015625 \cdot 10^{-17} \cdot x + 0.3333333333333333703407674875052180141211\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{e^{\left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} + \sqrt{1}\right) \cdot \left(\frac{\sqrt{2}}{\sqrt{1 + e^{-2 \cdot x}}} - \sqrt{1}\right)}}\right) + \log \left(\sqrt{e^{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\right)\\ \end{array}\]

Reproduce

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