Average Error: 58.1 → 0.0
Time: 19.4s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\tanh x\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\tanh x
double f(double x) {
        double r2702880 = x;
        double r2702881 = exp(r2702880);
        double r2702882 = -r2702880;
        double r2702883 = exp(r2702882);
        double r2702884 = r2702881 - r2702883;
        double r2702885 = r2702881 + r2702883;
        double r2702886 = r2702884 / r2702885;
        return r2702886;
}

double f(double x) {
        double r2702887 = x;
        double r2702888 = tanh(r2702887);
        return r2702888;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.1

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