Average Error: 57.9 → 0.0
Time: 47.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 r3655615 = x;
        double r3655616 = exp(r3655615);
        double r3655617 = -r3655615;
        double r3655618 = exp(r3655617);
        double r3655619 = r3655616 - r3655618;
        double r3655620 = r3655616 + r3655618;
        double r3655621 = r3655619 / r3655620;
        return r3655621;
}

double f(double x) {
        double r3655622 = x;
        double r3655623 = tanh(r3655622);
        return r3655623;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 57.9

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