Average Error: 58.0 → 0.0
Time: 27.5s
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 r11371994 = x;
        double r11371995 = exp(r11371994);
        double r11371996 = -r11371994;
        double r11371997 = exp(r11371996);
        double r11371998 = r11371995 - r11371997;
        double r11371999 = r11371995 + r11371997;
        double r11372000 = r11371998 / r11371999;
        return r11372000;
}

double f(double x) {
        double r11372001 = x;
        double r11372002 = tanh(r11372001);
        return r11372002;
}

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