Average Error: 29.7 → 0.6
Time: 25.4s
Precision: 64
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right), \frac{1}{360}, \mathsf{fma}\left(\frac{1}{12}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), x \cdot x\right)\right)\]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right), \frac{1}{360}, \mathsf{fma}\left(\frac{1}{12}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), x \cdot x\right)\right)
double f(double x) {
        double r5085358 = x;
        double r5085359 = exp(r5085358);
        double r5085360 = 2.0;
        double r5085361 = r5085359 - r5085360;
        double r5085362 = -r5085358;
        double r5085363 = exp(r5085362);
        double r5085364 = r5085361 + r5085363;
        return r5085364;
}

double f(double x) {
        double r5085365 = x;
        double r5085366 = r5085365 * r5085365;
        double r5085367 = r5085366 * r5085366;
        double r5085368 = r5085367 * r5085366;
        double r5085369 = 0.002777777777777778;
        double r5085370 = 0.08333333333333333;
        double r5085371 = fma(r5085370, r5085367, r5085366);
        double r5085372 = fma(r5085368, r5085369, r5085371);
        return r5085372;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 29.7

    \[\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(\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right), \frac{1}{360}, \mathsf{fma}\left(\frac{1}{12}, \left(x \cdot x\right) \cdot \left(x \cdot x\right), x \cdot x\right)\right)}\]
  4. Final simplification0.6

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

Reproduce

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

  :herbie-target
  (* 4.0 (pow (sinh (/ x 2.0)) 2.0))

  (+ (- (exp x) 2.0) (exp (- x))))