Average Error: 58.7 → 0.4
Time: 12.0s
Precision: 64
\[e^{x} - 1\]
\[x + \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) \cdot \left(x \cdot x\right)\]
double f(double x) {
        double r5417737 = x;
        double r5417738 = exp(r5417737);
        double r5417739 = 1.0;
        double r5417740 = r5417738 - r5417739;
        return r5417740;
}

double f(double x) {
        double r5417741 = x;
        double r5417742 = 0.16666666666666666;
        double r5417743 = r5417741 * r5417742;
        double r5417744 = 0.5;
        double r5417745 = r5417743 + r5417744;
        double r5417746 = r5417741 * r5417741;
        double r5417747 = r5417745 * r5417746;
        double r5417748 = r5417741 + r5417747;
        return r5417748;
}

e^{x} - 1
x + \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) \cdot \left(x \cdot x\right)

Error

Bits error versus x

Target

Original58.7
Target0.5
Herbie0.4
\[x \cdot \left(\left(1 + \frac{x}{2}\right) + \frac{x \cdot x}{6}\right)\]

Derivation

  1. Initial program 58.7

    \[e^{x} - 1\]
  2. Taylor expanded around 0 0.4

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

    \[\leadsto \color{blue}{x + \left(x \cdot x\right) \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right)}\]
  4. Final simplification0.4

    \[\leadsto x + \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) \cdot \left(x \cdot x\right)\]

Reproduce

herbie shell --seed 2019101 
(FPCore (x)
  :name "expm1 (example 3.7)"
  :pre (< -0.00017 x)

  :herbie-target
  (* x (+ (+ 1 (/ x 2)) (/ (* x x) 6)))

  (- (exp x) 1))