Average Error: 29.3 → 0.6
Time: 20.9s
Precision: 64
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\mathsf{fma}\left(\frac{1}{360}, \left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right), \left(\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{1}{12}, \left(x \cdot x\right)\right)\right)\right)\]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(\frac{1}{360}, \left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right), \left(\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right), \frac{1}{12}, \left(x \cdot x\right)\right)\right)\right)
double f(double x) {
        double r2849546 = x;
        double r2849547 = exp(r2849546);
        double r2849548 = 2.0;
        double r2849549 = r2849547 - r2849548;
        double r2849550 = -r2849546;
        double r2849551 = exp(r2849550);
        double r2849552 = r2849549 + r2849551;
        return r2849552;
}

double f(double x) {
        double r2849553 = 0.002777777777777778;
        double r2849554 = x;
        double r2849555 = r2849554 * r2849554;
        double r2849556 = r2849555 * r2849555;
        double r2849557 = r2849555 * r2849556;
        double r2849558 = 0.08333333333333333;
        double r2849559 = fma(r2849556, r2849558, r2849555);
        double r2849560 = fma(r2849553, r2849557, r2849559);
        return r2849560;
}

Error

Bits error versus x

Target

Original29.3
Target0.0
Herbie0.6
\[4 \cdot {\left(\sinh \left(\frac{x}{2}\right)\right)}^{2}\]

Derivation

  1. Initial program 29.3

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

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

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

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

Reproduce

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

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

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