Average Error: 58.2 → 0.0
Time: 23.4s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\tanh x\]
double f(double x) {
        double r6988733 = x;
        double r6988734 = exp(r6988733);
        double r6988735 = -r6988733;
        double r6988736 = exp(r6988735);
        double r6988737 = r6988734 - r6988736;
        double r6988738 = r6988734 + r6988736;
        double r6988739 = r6988737 / r6988738;
        return r6988739;
}

double f(double x) {
        double r6988740 = x;
        double r6988741 = tanh(r6988740);
        return r6988741;
}

\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\tanh x

Error

Bits error versus x

Derivation

  1. Initial program 58.2

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
  2. Using strategy rm
  3. Applied tanh-undef0.0

    \[\leadsto \color{blue}{\tanh x}\]
  4. Final simplification0.0

    \[\leadsto \tanh x\]

Reproduce

herbie shell --seed 2019102 
(FPCore (x)
  :name "Hyperbolic tangent"
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))