Average Error: 25.9 → 0.4
Time: 34.5s
Precision: 64
\[\frac{1}{1 - e^{\left(-n\right) \cdot d}}\]
\[\begin{array}{l} \mathbf{if}\;n \cdot \left(-d\right) \le -3006.2149340523856:\\ \;\;\;\;\frac{1}{1 - e^{n \cdot \left(-d\right)}}\\ \mathbf{elif}\;n \cdot \left(-d\right) \le 9.909994676161973 \cdot 10^{-10}:\\ \;\;\;\;\frac{1}{\left(n \cdot d - \left(\left(n \cdot d\right) \cdot \left(n \cdot d\right)\right) \cdot \frac{1}{2}\right) + \frac{1}{6} \cdot \left(\left(n \cdot d\right) \cdot \left(\left(n \cdot d\right) \cdot \left(n \cdot d\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - e^{n \cdot \left(-d\right)}}\\ \end{array}\]
\frac{1}{1 - e^{\left(-n\right) \cdot d}}
\begin{array}{l}
\mathbf{if}\;n \cdot \left(-d\right) \le -3006.2149340523856:\\
\;\;\;\;\frac{1}{1 - e^{n \cdot \left(-d\right)}}\\

\mathbf{elif}\;n \cdot \left(-d\right) \le 9.909994676161973 \cdot 10^{-10}:\\
\;\;\;\;\frac{1}{\left(n \cdot d - \left(\left(n \cdot d\right) \cdot \left(n \cdot d\right)\right) \cdot \frac{1}{2}\right) + \frac{1}{6} \cdot \left(\left(n \cdot d\right) \cdot \left(\left(n \cdot d\right) \cdot \left(n \cdot d\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{1 - e^{n \cdot \left(-d\right)}}\\

\end{array}
double f(double n, double d) {
        double r47989081 = 1.0;
        double r47989082 = n;
        double r47989083 = -r47989082;
        double r47989084 = d;
        double r47989085 = r47989083 * r47989084;
        double r47989086 = exp(r47989085);
        double r47989087 = r47989081 - r47989086;
        double r47989088 = r47989081 / r47989087;
        return r47989088;
}

double f(double n, double d) {
        double r47989089 = n;
        double r47989090 = d;
        double r47989091 = -r47989090;
        double r47989092 = r47989089 * r47989091;
        double r47989093 = -3006.2149340523856;
        bool r47989094 = r47989092 <= r47989093;
        double r47989095 = 1.0;
        double r47989096 = exp(r47989092);
        double r47989097 = r47989095 - r47989096;
        double r47989098 = r47989095 / r47989097;
        double r47989099 = 9.909994676161973e-10;
        bool r47989100 = r47989092 <= r47989099;
        double r47989101 = r47989089 * r47989090;
        double r47989102 = r47989101 * r47989101;
        double r47989103 = 0.5;
        double r47989104 = r47989102 * r47989103;
        double r47989105 = r47989101 - r47989104;
        double r47989106 = 0.16666666666666666;
        double r47989107 = r47989101 * r47989102;
        double r47989108 = r47989106 * r47989107;
        double r47989109 = r47989105 + r47989108;
        double r47989110 = r47989095 / r47989109;
        double r47989111 = r47989100 ? r47989110 : r47989098;
        double r47989112 = r47989094 ? r47989098 : r47989111;
        return r47989112;
}

Error

Bits error versus n

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (* (- n) d) < -3006.2149340523856 or 9.909994676161973e-10 < (* (- n) d)

    1. Initial program 0.2

      \[\frac{1}{1 - e^{\left(-n\right) \cdot d}}\]

    if -3006.2149340523856 < (* (- n) d) < 9.909994676161973e-10

    1. Initial program 60.4

      \[\frac{1}{1 - e^{\left(-n\right) \cdot d}}\]
    2. Taylor expanded around 0 18.4

      \[\leadsto \frac{1}{\color{blue}{\left(n \cdot d + \frac{1}{6} \cdot \left({n}^{3} \cdot {d}^{3}\right)\right) - \frac{1}{2} \cdot \left({n}^{2} \cdot {d}^{2}\right)}}\]
    3. Simplified0.7

      \[\leadsto \frac{1}{\color{blue}{\left(d \cdot n - \frac{1}{2} \cdot \left(\left(d \cdot n\right) \cdot \left(d \cdot n\right)\right)\right) + \left(\left(\left(d \cdot n\right) \cdot \left(d \cdot n\right)\right) \cdot \left(d \cdot n\right)\right) \cdot \frac{1}{6}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \cdot \left(-d\right) \le -3006.2149340523856:\\ \;\;\;\;\frac{1}{1 - e^{n \cdot \left(-d\right)}}\\ \mathbf{elif}\;n \cdot \left(-d\right) \le 9.909994676161973 \cdot 10^{-10}:\\ \;\;\;\;\frac{1}{\left(n \cdot d - \left(\left(n \cdot d\right) \cdot \left(n \cdot d\right)\right) \cdot \frac{1}{2}\right) + \frac{1}{6} \cdot \left(\left(n \cdot d\right) \cdot \left(\left(n \cdot d\right) \cdot \left(n \cdot d\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - e^{n \cdot \left(-d\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (n d)
  :name "1 / (1 - exp(-n * d))"
  (/ 1 (- 1 (exp (* (- n) d)))))