Average Error: 29.6 → 0.5
Time: 12.6s
Precision: binary64
\[\left(e^{x} - 2\right) + e^{-x} \]
\[\mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right)\right) \]
\left(e^{x} - 2\right) + e^{-x}
\mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right)\right)
(FPCore (x) :precision binary64 (+ (- (exp x) 2.0) (exp (- x))))
(FPCore (x)
 :precision binary64
 (fma
  0.002777777777777778
  (pow x 6.0)
  (fma x x (* (pow x 4.0) 0.08333333333333333))))
double code(double x) {
	return (exp(x) - 2.0) + exp(-x);
}
double code(double x) {
	return fma(0.002777777777777778, pow(x, 6.0), fma(x, x, (pow(x, 4.0) * 0.08333333333333333)));
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 29.6

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

    \[\leadsto \color{blue}{0.08333333333333333 \cdot {x}^{4} + \left(0.002777777777777778 \cdot {x}^{6} + {x}^{2}\right)} \]
  3. Simplified0.5

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{6}\right)\right)} \]
  4. Applied add-cube-cbrt_binary641.3

    \[\leadsto \color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{6}\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{6}\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(0.08333333333333333, {x}^{4}, \mathsf{fma}\left(x, x, 0.002777777777777778 \cdot {x}^{6}\right)\right)}} \]
  5. Taylor expanded in x around 0 0.5

    \[\leadsto \color{blue}{0.08333333333333333 \cdot {x}^{4} + \left(0.002777777777777778 \cdot {x}^{6} + {x}^{2}\right)} \]
  6. Simplified0.5

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right)\right)} \]
  7. Final simplification0.5

    \[\leadsto \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \mathsf{fma}\left(x, x, {x}^{4} \cdot 0.08333333333333333\right)\right) \]

Reproduce

herbie shell --seed 2022024 
(FPCore (x)
  :name "exp2 (problem 3.3.7)"
  :precision binary64

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

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