Average Error: 58.3 → 0.0
Time: 33.5s
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 r2064423 = x;
        double r2064424 = exp(r2064423);
        double r2064425 = -r2064423;
        double r2064426 = exp(r2064425);
        double r2064427 = r2064424 - r2064426;
        double r2064428 = r2064424 + r2064426;
        double r2064429 = r2064427 / r2064428;
        return r2064429;
}

double f(double x) {
        double r2064430 = x;
        double r2064431 = tanh(r2064430);
        return r2064431;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.3

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