Average Error: 30.1 → 0.7
Time: 15.0s
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 r1863833 = x;
        double r1863834 = exp(r1863833);
        double r1863835 = 2.0;
        double r1863836 = r1863834 - r1863835;
        double r1863837 = -r1863833;
        double r1863838 = exp(r1863837);
        double r1863839 = r1863836 + r1863838;
        return r1863839;
}

double f(double x) {
        double r1863840 = 0.002777777777777778;
        double r1863841 = x;
        double r1863842 = r1863841 * r1863841;
        double r1863843 = r1863842 * r1863842;
        double r1863844 = r1863842 * r1863843;
        double r1863845 = 0.08333333333333333;
        double r1863846 = fma(r1863843, r1863845, r1863842);
        double r1863847 = fma(r1863840, r1863844, r1863846);
        return r1863847;
}

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

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

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

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