Average Error: 58.2 → 0.0
Time: 32.1s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\tanh x\]
double f(double x) {
        double r8389376 = x;
        double r8389377 = exp(r8389376);
        double r8389378 = -r8389376;
        double r8389379 = exp(r8389378);
        double r8389380 = r8389377 - r8389379;
        double r8389381 = r8389377 + r8389379;
        double r8389382 = r8389380 / r8389381;
        return r8389382;
}

double f(double x) {
        double r8389383 = x;
        double r8389384 = tanh(r8389383);
        return r8389384;
}

\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 2019101 
(FPCore (x)
  :name "Hyperbolic tangent"
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))