Average Error: 58.7 → 0.4
Time: 2.4s
Precision: 64
\[-1.700000000000000122124532708767219446599 \cdot 10^{-4} \lt x\]
\[e^{x} - 1\]
\[{\left(e^{x}\right)}^{\left(\mathsf{fma}\left(x, \frac{1}{24}, \frac{1}{2}\right)\right)} \cdot x\]
e^{x} - 1
{\left(e^{x}\right)}^{\left(\mathsf{fma}\left(x, \frac{1}{24}, \frac{1}{2}\right)\right)} \cdot x
double f(double x) {
        double r108235 = x;
        double r108236 = exp(r108235);
        double r108237 = 1.0;
        double r108238 = r108236 - r108237;
        return r108238;
}

double f(double x) {
        double r108239 = x;
        double r108240 = exp(r108239);
        double r108241 = 0.041666666666666664;
        double r108242 = 0.5;
        double r108243 = fma(r108239, r108241, r108242);
        double r108244 = pow(r108240, r108243);
        double r108245 = r108244 * r108239;
        return r108245;
}

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.5

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, {x}^{2}, \mathsf{fma}\left(\frac{1}{6}, {x}^{3}, x\right)\right)}\]
  4. Using strategy rm
  5. Applied add-exp-log34.7

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

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

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

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

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

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

Reproduce

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

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

  (- (exp x) 1))