Average Error: 58.0 → 0.0
Time: 40.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 r2387247 = x;
        double r2387248 = exp(r2387247);
        double r2387249 = -r2387247;
        double r2387250 = exp(r2387249);
        double r2387251 = r2387248 - r2387250;
        double r2387252 = r2387248 + r2387250;
        double r2387253 = r2387251 / r2387252;
        return r2387253;
}

double f(double x) {
        double r2387254 = x;
        double r2387255 = tanh(r2387254);
        return r2387255;
}

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