Average Error: 58.1 → 0.0
Time: 34.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 r2468574 = x;
        double r2468575 = exp(r2468574);
        double r2468576 = -r2468574;
        double r2468577 = exp(r2468576);
        double r2468578 = r2468575 - r2468577;
        double r2468579 = r2468575 + r2468577;
        double r2468580 = r2468578 / r2468579;
        return r2468580;
}

double f(double x) {
        double r2468581 = x;
        double r2468582 = tanh(r2468581);
        return r2468582;
}

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