Average Error: 58.2 → 0.0
Time: 4.9s
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 r31581 = x;
        double r31582 = exp(r31581);
        double r31583 = -r31581;
        double r31584 = exp(r31583);
        double r31585 = r31582 - r31584;
        double r31586 = r31582 + r31584;
        double r31587 = r31585 / r31586;
        return r31587;
}

double f(double x) {
        double r31588 = x;
        double r31589 = tanh(r31588);
        return r31589;
}

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