Average Error: 58.1 → 0.0
Time: 16.6s
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 r2418491 = x;
        double r2418492 = exp(r2418491);
        double r2418493 = -r2418491;
        double r2418494 = exp(r2418493);
        double r2418495 = r2418492 - r2418494;
        double r2418496 = r2418492 + r2418494;
        double r2418497 = r2418495 / r2418496;
        return r2418497;
}

double f(double x) {
        double r2418498 = x;
        double r2418499 = tanh(r2418498);
        return r2418499;
}

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