Average Error: 50.5 → 0.4
Time: 16.7s
Precision: 64
\[\frac{\left(e^{-x} - 1\right) + x}{{x}^{2}}\]
\[\begin{array}{l} \mathbf{if}\;x \le 0.001268301978204890243656643988856558280531:\\ \;\;\;\;\left(\frac{1}{24} \cdot {x}^{2} + \frac{1}{2}\right) - \frac{1}{6} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(e^{-x} - 1\right) + x}{{x}^{\left(\frac{2}{2}\right)}}}{{x}^{\left(\frac{2}{2}\right)}}\\ \end{array}\]
\frac{\left(e^{-x} - 1\right) + x}{{x}^{2}}
\begin{array}{l}
\mathbf{if}\;x \le 0.001268301978204890243656643988856558280531:\\
\;\;\;\;\left(\frac{1}{24} \cdot {x}^{2} + \frac{1}{2}\right) - \frac{1}{6} \cdot x\\

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

\end{array}
double f(double x) {
        double r693941 = x;
        double r693942 = -r693941;
        double r693943 = exp(r693942);
        double r693944 = 1.0;
        double r693945 = r693943 - r693944;
        double r693946 = r693945 + r693941;
        double r693947 = 2.0;
        double r693948 = pow(r693941, r693947);
        double r693949 = r693946 / r693948;
        return r693949;
}

double f(double x) {
        double r693950 = x;
        double r693951 = 0.0012683019782048902;
        bool r693952 = r693950 <= r693951;
        double r693953 = 0.041666666666666664;
        double r693954 = 2.0;
        double r693955 = pow(r693950, r693954);
        double r693956 = r693953 * r693955;
        double r693957 = 0.5;
        double r693958 = r693956 + r693957;
        double r693959 = 0.16666666666666666;
        double r693960 = r693959 * r693950;
        double r693961 = r693958 - r693960;
        double r693962 = -r693950;
        double r693963 = exp(r693962);
        double r693964 = 1.0;
        double r693965 = r693963 - r693964;
        double r693966 = r693965 + r693950;
        double r693967 = 2.0;
        double r693968 = r693967 / r693954;
        double r693969 = pow(r693950, r693968);
        double r693970 = r693966 / r693969;
        double r693971 = r693970 / r693969;
        double r693972 = r693952 ? r693961 : r693971;
        return r693972;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < 0.0012683019782048902

    1. Initial program 61.5

      \[\frac{\left(e^{-x} - 1\right) + x}{{x}^{2}}\]
    2. Taylor expanded around 0 0.5

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

    if 0.0012683019782048902 < x

    1. Initial program 29.7

      \[\frac{\left(e^{-x} - 1\right) + x}{{x}^{2}}\]
    2. Using strategy rm
    3. Applied sqr-pow29.7

      \[\leadsto \frac{\left(e^{-x} - 1\right) + x}{\color{blue}{{x}^{\left(\frac{2}{2}\right)} \cdot {x}^{\left(\frac{2}{2}\right)}}}\]
    4. Applied associate-/r*0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 0.001268301978204890243656643988856558280531:\\ \;\;\;\;\left(\frac{1}{24} \cdot {x}^{2} + \frac{1}{2}\right) - \frac{1}{6} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(e^{-x} - 1\right) + x}{{x}^{\left(\frac{2}{2}\right)}}}{{x}^{\left(\frac{2}{2}\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "(exp(-x) - 1 + x) / pow(x, 2)"
  :precision binary64
  (/ (+ (- (exp (- x)) 1) x) (pow x 2)))