Average Error: 58.1 → 0.0
Time: 40.7s
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 r2808501 = x;
        double r2808502 = exp(r2808501);
        double r2808503 = -r2808501;
        double r2808504 = exp(r2808503);
        double r2808505 = r2808502 - r2808504;
        double r2808506 = r2808502 + r2808504;
        double r2808507 = r2808505 / r2808506;
        return r2808507;
}

double f(double x) {
        double r2808508 = x;
        double r2808509 = tanh(r2808508);
        return r2808509;
}

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