Average Error: 58.4 → 0.0
Time: 18.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 r2281395 = x;
        double r2281396 = exp(r2281395);
        double r2281397 = -r2281395;
        double r2281398 = exp(r2281397);
        double r2281399 = r2281396 - r2281398;
        double r2281400 = r2281396 + r2281398;
        double r2281401 = r2281399 / r2281400;
        return r2281401;
}

double f(double x) {
        double r2281402 = x;
        double r2281403 = tanh(r2281402);
        return r2281403;
}

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