Average Error: 58.2 → 0.0
Time: 9.1s
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 r52742 = x;
        double r52743 = exp(r52742);
        double r52744 = -r52742;
        double r52745 = exp(r52744);
        double r52746 = r52743 - r52745;
        double r52747 = r52743 + r52745;
        double r52748 = r52746 / r52747;
        return r52748;
}

double f(double x) {
        double r52749 = x;
        double r52750 = tanh(r52749);
        return r52750;
}

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