Average Error: 58.4 → 0.0
Time: 5.2s
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 r60509 = x;
        double r60510 = exp(r60509);
        double r60511 = -r60509;
        double r60512 = exp(r60511);
        double r60513 = r60510 - r60512;
        double r60514 = r60510 + r60512;
        double r60515 = r60513 / r60514;
        return r60515;
}

double f(double x) {
        double r60516 = x;
        double r60517 = tanh(r60516);
        return r60517;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.4

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