Average Error: 29.3 → 0.6
Time: 17.5s
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 r2913802 = x;
        double r2913803 = exp(r2913802);
        double r2913804 = 2.0;
        double r2913805 = r2913803 - r2913804;
        double r2913806 = -r2913802;
        double r2913807 = exp(r2913806);
        double r2913808 = r2913805 + r2913807;
        return r2913808;
}

double f(double x) {
        double r2913809 = 0.002777777777777778;
        double r2913810 = x;
        double r2913811 = r2913810 * r2913810;
        double r2913812 = r2913811 * r2913811;
        double r2913813 = r2913811 * r2913812;
        double r2913814 = 0.08333333333333333;
        double r2913815 = fma(r2913812, r2913814, r2913811);
        double r2913816 = fma(r2913809, r2913813, r2913815);
        return r2913816;
}

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(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.6

    \[\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 2019135 +o rules:numerics
(FPCore (x)
  :name "exp2 (problem 3.3.7)"

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

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