Average Error: 58.1 → 0.6
Time: 9.6s
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 r742035 = x;
        double r742036 = exp(r742035);
        double r742037 = -r742035;
        double r742038 = exp(r742037);
        double r742039 = r742036 - r742038;
        double r742040 = 2.0;
        double r742041 = r742039 / r742040;
        return r742041;
}

double f(double x) {
        double r742042 = x;
        double r742043 = 0.3333333333333333;
        double r742044 = r742042 * r742043;
        double r742045 = 2.0;
        double r742046 = fma(r742044, r742042, r742045);
        double r742047 = 0.016666666666666666;
        double r742048 = 5.0;
        double r742049 = pow(r742042, r742048);
        double r742050 = r742047 * r742049;
        double r742051 = fma(r742042, r742046, r742050);
        double r742052 = r742051 / r742045;
        return r742052;
}

Error

Bits error versus x

Derivation

  1. Initial program 58.1

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

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

    \[\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.6

    \[\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 2019156 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic sine"
  (/ (- (exp x) (exp (- x))) 2))