Average Error: 30.1 → 0.7
Time: 27.9s
Precision: 64
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\mathsf{fma}\left(\frac{1}{360}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{12}, x \cdot x\right)\right)\]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(\frac{1}{360}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{12}, x \cdot x\right)\right)
double f(double x) {
        double r2649407 = x;
        double r2649408 = exp(r2649407);
        double r2649409 = 2.0;
        double r2649410 = r2649408 - r2649409;
        double r2649411 = -r2649407;
        double r2649412 = exp(r2649411);
        double r2649413 = r2649410 + r2649412;
        return r2649413;
}

double f(double x) {
        double r2649414 = 0.002777777777777778;
        double r2649415 = x;
        double r2649416 = r2649415 * r2649415;
        double r2649417 = r2649416 * r2649416;
        double r2649418 = r2649416 * r2649417;
        double r2649419 = 0.08333333333333333;
        double r2649420 = fma(r2649417, r2649419, r2649416);
        double r2649421 = fma(r2649414, r2649418, r2649420);
        return r2649421;
}

Error

Bits error versus x

Target

Original30.1
Target0.0
Herbie0.7
\[4 \cdot {\left(\sinh \left(\frac{x}{2}\right)\right)}^{2}\]

Derivation

  1. Initial program 30.1

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{360}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{12}, x \cdot x\right)\right)}\]
  4. Final simplification0.7

    \[\leadsto \mathsf{fma}\left(\frac{1}{360}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{12}, x \cdot x\right)\right)\]

Reproduce

herbie shell --seed 2019144 +o rules:numerics
(FPCore (x)
  :name "exp2 (problem 3.3.7)"

  :herbie-target
  (* 4 (pow (sinh (/ x 2)) 2))

  (+ (- (exp x) 2) (exp (- x))))