Average Error: 58.2 → 0.0
Time: 19.1s
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 r1902718 = x;
        double r1902719 = exp(r1902718);
        double r1902720 = -r1902718;
        double r1902721 = exp(r1902720);
        double r1902722 = r1902719 - r1902721;
        double r1902723 = r1902719 + r1902721;
        double r1902724 = r1902722 / r1902723;
        return r1902724;
}

double f(double x) {
        double r1902725 = x;
        double r1902726 = tanh(r1902725);
        return r1902726;
}

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