Average Error: 58.1 → 0.0
Time: 4.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 r26474 = x;
        double r26475 = exp(r26474);
        double r26476 = -r26474;
        double r26477 = exp(r26476);
        double r26478 = r26475 - r26477;
        double r26479 = r26475 + r26477;
        double r26480 = r26478 / r26479;
        return r26480;
}

double f(double x) {
        double r26481 = x;
        double r26482 = tanh(r26481);
        return r26482;
}

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