Average Error: 58.2 → 0.0
Time: 1.0m
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 r2367733 = x;
        double r2367734 = exp(r2367733);
        double r2367735 = -r2367733;
        double r2367736 = exp(r2367735);
        double r2367737 = r2367734 - r2367736;
        double r2367738 = r2367734 + r2367736;
        double r2367739 = r2367737 / r2367738;
        return r2367739;
}

double f(double x) {
        double r2367740 = x;
        double r2367741 = tanh(r2367740);
        return r2367741;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.2

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