Average Error: 58.1 → 0.0
Time: 27.3s
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 r38722 = x;
        double r38723 = exp(r38722);
        double r38724 = -r38722;
        double r38725 = exp(r38724);
        double r38726 = r38723 - r38725;
        double r38727 = r38723 + r38725;
        double r38728 = r38726 / r38727;
        return r38728;
}

double f(double x) {
        double r38729 = x;
        double r38730 = tanh(r38729);
        return r38730;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.1

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