Average Error: 58.9 → 0.3
Time: 11.5s
Precision: 64
\[-1.700000000000000122124532708767219446599 \cdot 10^{-4} \lt x\]
\[e^{x} - 1\]
\[e^{\mathsf{fma}\left(\frac{1}{24}, x, \frac{1}{2}\right) \cdot x} \cdot x\]
e^{x} - 1
e^{\mathsf{fma}\left(\frac{1}{24}, x, \frac{1}{2}\right) \cdot x} \cdot x
double f(double x) {
        double r3711227 = x;
        double r3711228 = exp(r3711227);
        double r3711229 = 1.0;
        double r3711230 = r3711228 - r3711229;
        return r3711230;
}

double f(double x) {
        double r3711231 = 0.041666666666666664;
        double r3711232 = x;
        double r3711233 = 0.5;
        double r3711234 = fma(r3711231, r3711232, r3711233);
        double r3711235 = r3711234 * r3711232;
        double r3711236 = exp(r3711235);
        double r3711237 = r3711236 * r3711232;
        return r3711237;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 58.9

    \[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}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x\right)}\]
  4. Using strategy rm
  5. Applied add-exp-log34.5

    \[\leadsto \color{blue}{e^{\log \left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{6}, x, \frac{1}{2}\right), x\right)\right)}}\]
  6. Taylor expanded around 0 34.5

    \[\leadsto e^{\color{blue}{\frac{1}{2} \cdot x + \left(\frac{1}{24} \cdot {x}^{2} + \log x\right)}}\]
  7. Simplified34.5

    \[\leadsto e^{\color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{1}{24}, \frac{1}{2}\right), \log x\right)}}\]
  8. Taylor expanded around inf 34.5

    \[\leadsto \color{blue}{e^{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{1}{24}, \frac{1}{2}\right), \log x\right)}}\]
  9. Simplified0.3

    \[\leadsto \color{blue}{e^{\mathsf{fma}\left(\frac{1}{24}, x, \frac{1}{2}\right) \cdot x} \cdot x}\]
  10. Final simplification0.3

    \[\leadsto e^{\mathsf{fma}\left(\frac{1}{24}, x, \frac{1}{2}\right) \cdot x} \cdot x\]

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(FPCore (x)
  :name "expm1 (example 3.7)"
  :pre (< -0.00017 x)

  :herbie-target
  (* x (+ (+ 1.0 (/ x 2.0)) (/ (* x x) 6.0)))

  (- (exp x) 1.0))