Average Error: 57.9 → 0.6
Time: 9.8s
Precision: 64
\[\frac{e^{x} - e^{-x}}{2}\]
\[\frac{\mathsf{fma}\left({x}^{5}, \frac{1}{60}, \mathsf{fma}\left(2, x, \left(x \cdot x\right) \cdot \left(\frac{1}{3} \cdot x\right)\right)\right)}{2}\]
\frac{e^{x} - e^{-x}}{2}
\frac{\mathsf{fma}\left({x}^{5}, \frac{1}{60}, \mathsf{fma}\left(2, x, \left(x \cdot x\right) \cdot \left(\frac{1}{3} \cdot x\right)\right)\right)}{2}
double f(double x) {
        double r1863091 = x;
        double r1863092 = exp(r1863091);
        double r1863093 = -r1863091;
        double r1863094 = exp(r1863093);
        double r1863095 = r1863092 - r1863094;
        double r1863096 = 2.0;
        double r1863097 = r1863095 / r1863096;
        return r1863097;
}

double f(double x) {
        double r1863098 = x;
        double r1863099 = 5.0;
        double r1863100 = pow(r1863098, r1863099);
        double r1863101 = 0.016666666666666666;
        double r1863102 = 2.0;
        double r1863103 = r1863098 * r1863098;
        double r1863104 = 0.3333333333333333;
        double r1863105 = r1863104 * r1863098;
        double r1863106 = r1863103 * r1863105;
        double r1863107 = fma(r1863102, r1863098, r1863106);
        double r1863108 = fma(r1863100, r1863101, r1863107);
        double r1863109 = 2.0;
        double r1863110 = r1863108 / r1863109;
        return r1863110;
}

Error

Bits error versus x

Derivation

  1. Initial program 57.9

    \[\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}^{5}, \frac{1}{60}, x \cdot \left(\left(\frac{1}{3} \cdot x\right) \cdot x + 2\right)\right)}}{2}\]
  4. Taylor expanded around 0 0.6

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

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

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

Reproduce

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