Average Error: 58.0 → 0.0
Time: 20.3s
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 r2005377 = x;
        double r2005378 = exp(r2005377);
        double r2005379 = -r2005377;
        double r2005380 = exp(r2005379);
        double r2005381 = r2005378 - r2005380;
        double r2005382 = r2005378 + r2005380;
        double r2005383 = r2005381 / r2005382;
        return r2005383;
}

double f(double x) {
        double r2005384 = x;
        double r2005385 = tanh(r2005384);
        return r2005385;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

    \[\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 2019163 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic tangent"
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))