Average Error: 58.2 → 0.0
Time: 19.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 r1855414 = x;
        double r1855415 = exp(r1855414);
        double r1855416 = -r1855414;
        double r1855417 = exp(r1855416);
        double r1855418 = r1855415 - r1855417;
        double r1855419 = r1855415 + r1855417;
        double r1855420 = r1855418 / r1855419;
        return r1855420;
}

double f(double x) {
        double r1855421 = x;
        double r1855422 = tanh(r1855421);
        return r1855422;
}

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