Average Error: 58.0 → 0.0
Time: 21.0s
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 r2252289 = x;
        double r2252290 = exp(r2252289);
        double r2252291 = -r2252289;
        double r2252292 = exp(r2252291);
        double r2252293 = r2252290 - r2252292;
        double r2252294 = r2252290 + r2252292;
        double r2252295 = r2252293 / r2252294;
        return r2252295;
}

double f(double x) {
        double r2252296 = x;
        double r2252297 = tanh(r2252296);
        return r2252297;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

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