Average Error: 58.2 → 0.0
Time: 19.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 r2601384 = x;
        double r2601385 = exp(r2601384);
        double r2601386 = -r2601384;
        double r2601387 = exp(r2601386);
        double r2601388 = r2601385 - r2601387;
        double r2601389 = r2601385 + r2601387;
        double r2601390 = r2601388 / r2601389;
        return r2601390;
}

double f(double x) {
        double r2601391 = x;
        double r2601392 = tanh(r2601391);
        return r2601392;
}

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