Average Error: 58.2 → 0.0
Time: 21.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 r2091343 = x;
        double r2091344 = exp(r2091343);
        double r2091345 = -r2091343;
        double r2091346 = exp(r2091345);
        double r2091347 = r2091344 - r2091346;
        double r2091348 = r2091344 + r2091346;
        double r2091349 = r2091347 / r2091348;
        return r2091349;
}

double f(double x) {
        double r2091350 = x;
        double r2091351 = tanh(r2091350);
        return r2091351;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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