Average Error: 58.1 → 0.7
Time: 15.2s
Precision: 64
\[\frac{e^{x} - e^{-x}}{2}\]
\[\frac{\mathsf{fma}\left(x, \mathsf{fma}\left(\frac{1}{3}, x \cdot 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(\frac{1}{3}, x \cdot x, 2\right), \frac{1}{60} \cdot {x}^{5}\right)}{2}
double f(double x) {
        double r3026951 = x;
        double r3026952 = exp(r3026951);
        double r3026953 = -r3026951;
        double r3026954 = exp(r3026953);
        double r3026955 = r3026952 - r3026954;
        double r3026956 = 2.0;
        double r3026957 = r3026955 / r3026956;
        return r3026957;
}

double f(double x) {
        double r3026958 = x;
        double r3026959 = 0.3333333333333333;
        double r3026960 = r3026958 * r3026958;
        double r3026961 = 2.0;
        double r3026962 = fma(r3026959, r3026960, r3026961);
        double r3026963 = 0.016666666666666666;
        double r3026964 = 5.0;
        double r3026965 = pow(r3026958, r3026964);
        double r3026966 = r3026963 * r3026965;
        double r3026967 = fma(r3026958, r3026962, r3026966);
        double r3026968 = r3026967 / r3026961;
        return r3026968;
}

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.7

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

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

Reproduce

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