Average Error: 57.9 → 0.0
Time: 23.9s
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 r6438542 = x;
        double r6438543 = exp(r6438542);
        double r6438544 = -r6438542;
        double r6438545 = exp(r6438544);
        double r6438546 = r6438543 - r6438545;
        double r6438547 = r6438543 + r6438545;
        double r6438548 = r6438546 / r6438547;
        return r6438548;
}

double f(double x) {
        double r6438549 = x;
        double r6438550 = tanh(r6438549);
        return r6438550;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 57.9

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