Average Error: 58.1 → 0.0
Time: 28.9s
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 r5200715 = x;
        double r5200716 = exp(r5200715);
        double r5200717 = -r5200715;
        double r5200718 = exp(r5200717);
        double r5200719 = r5200716 - r5200718;
        double r5200720 = r5200716 + r5200718;
        double r5200721 = r5200719 / r5200720;
        return r5200721;
}

double f(double x) {
        double r5200722 = x;
        double r5200723 = tanh(r5200722);
        return r5200723;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.1

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