Average Error: 57.9 → 0.7
Time: 13.0s
Precision: 64
\[\frac{e^{x} - e^{-x}}{2}\]
\[\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x \cdot \frac{1}{3}, x, 2\right), \frac{1}{60} \cdot {x}^{5}\right)}{2}\]
\frac{e^{x} - e^{-x}}{2}
\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(x \cdot \frac{1}{3}, x, 2\right), \frac{1}{60} \cdot {x}^{5}\right)}{2}
double f(double x) {
        double r1151819 = x;
        double r1151820 = exp(r1151819);
        double r1151821 = -r1151819;
        double r1151822 = exp(r1151821);
        double r1151823 = r1151820 - r1151822;
        double r1151824 = 2.0;
        double r1151825 = r1151823 / r1151824;
        return r1151825;
}

double f(double x) {
        double r1151826 = x;
        double r1151827 = 0.3333333333333333;
        double r1151828 = r1151826 * r1151827;
        double r1151829 = 2.0;
        double r1151830 = fma(r1151828, r1151826, r1151829);
        double r1151831 = 0.016666666666666666;
        double r1151832 = 5.0;
        double r1151833 = pow(r1151826, r1151832);
        double r1151834 = r1151831 * r1151833;
        double r1151835 = fma(r1151826, r1151830, r1151834);
        double r1151836 = r1151835 / r1151829;
        return r1151836;
}

Error

Bits error versus x

Derivation

  1. Initial program 57.9

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

    \[\leadsto \frac{\color{blue}{2 \cdot x + \left(\frac{1}{3} \cdot {x}^{3} + \frac{1}{60} \cdot {x}^{5}\right)}}{2}\]
  3. Simplified0.7

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

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

Reproduce

herbie shell --seed 2019151 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic sine"
  (/ (- (exp x) (exp (- x))) 2))