Average Error: 29.9 → 0.5
Time: 21.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 r2414920 = x;
        double r2414921 = exp(r2414920);
        double r2414922 = 2.0;
        double r2414923 = r2414921 - r2414922;
        double r2414924 = -r2414920;
        double r2414925 = exp(r2414924);
        double r2414926 = r2414923 + r2414925;
        return r2414926;
}

double f(double x) {
        double r2414927 = 0.002777777777777778;
        double r2414928 = x;
        double r2414929 = r2414928 * r2414928;
        double r2414930 = r2414929 * r2414929;
        double r2414931 = r2414929 * r2414930;
        double r2414932 = 0.08333333333333333;
        double r2414933 = fma(r2414930, r2414932, r2414929);
        double r2414934 = fma(r2414927, r2414931, r2414933);
        return r2414934;
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 29.9

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

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

    \[\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.5

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

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

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