Average Error: 58.3 → 0.6
Time: 3.2s
Precision: binary64
\[\frac{e^{x} - e^{-x}}{2} \]
\[\frac{\mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)}{2} \]
\frac{e^{x} - e^{-x}}{2}
\frac{\mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)}{2}
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
(FPCore (x)
 :precision binary64
 (/ (fma 2.0 x (* 0.3333333333333333 (pow x 3.0))) 2.0))
double code(double x) {
	return (exp(x) - exp(-x)) / 2.0;
}
double code(double x) {
	return fma(2.0, x, (0.3333333333333333 * pow(x, 3.0))) / 2.0;
}

Error

Bits error versus x

Derivation

  1. Initial program 58.3

    \[\frac{e^{x} - e^{-x}}{2} \]
  2. Taylor expanded in x around 0 0.6

    \[\leadsto \frac{\color{blue}{0.3333333333333333 \cdot {x}^{3} + 2 \cdot x}}{2} \]
  3. Simplified0.6

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

    \[\leadsto \frac{\mathsf{fma}\left(2, x, 0.3333333333333333 \cdot {x}^{3}\right)}{2} \]

Reproduce

herbie shell --seed 2022125 
(FPCore (x)
  :name "Hyperbolic sine"
  :precision binary64
  (/ (- (exp x) (exp (- x))) 2.0))