Average Error: 58.1 → 0.0
Time: 19.8s
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 r2250473 = x;
        double r2250474 = exp(r2250473);
        double r2250475 = -r2250473;
        double r2250476 = exp(r2250475);
        double r2250477 = r2250474 - r2250476;
        double r2250478 = r2250474 + r2250476;
        double r2250479 = r2250477 / r2250478;
        return r2250479;
}

double f(double x) {
        double r2250480 = x;
        double r2250481 = tanh(r2250480);
        return r2250481;
}

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