Average Error: 57.9 → 0.6
Time: 8.4s
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 r764973 = x;
        double r764974 = exp(r764973);
        double r764975 = -r764973;
        double r764976 = exp(r764975);
        double r764977 = r764974 - r764976;
        double r764978 = 2.0;
        double r764979 = r764977 / r764978;
        return r764979;
}

double f(double x) {
        double r764980 = x;
        double r764981 = 0.3333333333333333;
        double r764982 = r764980 * r764981;
        double r764983 = 2.0;
        double r764984 = fma(r764982, r764980, r764983);
        double r764985 = 0.016666666666666666;
        double r764986 = 5.0;
        double r764987 = pow(r764980, r764986);
        double r764988 = r764985 * r764987;
        double r764989 = fma(r764980, r764984, r764988);
        double r764990 = r764989 / r764983;
        return r764990;
}

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