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

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

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)))))