Average Error: 30.2 → 0.6
Time: 5.1s
Precision: 64
\[\left(e^{x} - 2\right) + e^{-x}\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(\frac{1}{360}, {x}^{6}, \frac{1}{12} \cdot {x}^{4}\right)\right)\]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(x, x, \mathsf{fma}\left(\frac{1}{360}, {x}^{6}, \frac{1}{12} \cdot {x}^{4}\right)\right)
double code(double x) {
	return ((double) (((double) (((double) exp(x)) - 2.0)) + ((double) exp(((double) -(x))))));
}
double code(double x) {
	return ((double) fma(x, x, ((double) fma(0.002777777777777778, ((double) pow(x, 6.0)), ((double) (0.08333333333333333 * ((double) pow(x, 4.0))))))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.2

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

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

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

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

Reproduce

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

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

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