Average Error: 58.2 → 0.0
Time: 5.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 r63545 = x;
        double r63546 = exp(r63545);
        double r63547 = -r63545;
        double r63548 = exp(r63547);
        double r63549 = r63546 - r63548;
        double r63550 = r63546 + r63548;
        double r63551 = r63549 / r63550;
        return r63551;
}

double f(double x) {
        double r63552 = x;
        double r63553 = tanh(r63552);
        return r63553;
}

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