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 r26467 = x;
        double r26468 = exp(r26467);
        double r26469 = -r26467;
        double r26470 = exp(r26469);
        double r26471 = r26468 - r26470;
        double r26472 = r26468 + r26470;
        double r26473 = r26471 / r26472;
        return r26473;
}

double f(double x) {
        double r26474 = x;
        double r26475 = tanh(r26474);
        return r26475;
}

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)))))