Average Error: 58.3 → 0.0
Time: 4.4s
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 r53650 = x;
        double r53651 = exp(r53650);
        double r53652 = -r53650;
        double r53653 = exp(r53652);
        double r53654 = r53651 - r53653;
        double r53655 = r53651 + r53653;
        double r53656 = r53654 / r53655;
        return r53656;
}

double f(double x) {
        double r53657 = x;
        double r53658 = tanh(r53657);
        return r53658;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.3

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