Average Error: 58.0 → 0.0
Time: 14.8s
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 r43538 = x;
        double r43539 = exp(r43538);
        double r43540 = -r43538;
        double r43541 = exp(r43540);
        double r43542 = r43539 - r43541;
        double r43543 = r43539 + r43541;
        double r43544 = r43542 / r43543;
        return r43544;
}

double f(double x) {
        double r43545 = x;
        double r43546 = tanh(r43545);
        return r43546;
}

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 2020046 
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))