Average Error: 58.0 → 0.6
Time: 3.0s
Precision: binary64
\[\frac{e^{x} - e^{-x}}{2} \]
\[\mathsf{fma}\left(0.008333333333333333, {x}^{5}, \mathsf{fma}\left(0.16666666666666666, {x}^{3}, x\right)\right) \]
\frac{e^{x} - e^{-x}}{2}
\mathsf{fma}\left(0.008333333333333333, {x}^{5}, \mathsf{fma}\left(0.16666666666666666, {x}^{3}, x\right)\right)
(FPCore (x) :precision binary64 (/ (- (exp x) (exp (- x))) 2.0))
(FPCore (x)
 :precision binary64
 (fma
  0.008333333333333333
  (pow x 5.0)
  (fma 0.16666666666666666 (pow x 3.0) x)))
double code(double x) {
	return (exp(x) - exp(-x)) / 2.0;
}
double code(double x) {
	return fma(0.008333333333333333, pow(x, 5.0), fma(0.16666666666666666, pow(x, 3.0), x));
}

Error

Bits error versus x

Derivation

  1. Initial program 58.0

    \[\frac{e^{x} - e^{-x}}{2} \]
  2. Simplified58.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, e^{x}, \frac{-0.5}{e^{x}}\right)} \]
  3. Taylor expanded in x around 0 0.6

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.008333333333333333, {x}^{5}, \mathsf{fma}\left(0.16666666666666666, {x}^{3}, x\right)\right)} \]
  5. Final simplification0.6

    \[\leadsto \mathsf{fma}\left(0.008333333333333333, {x}^{5}, \mathsf{fma}\left(0.16666666666666666, {x}^{3}, x\right)\right) \]

Reproduce

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