Average Error: 58.0 → 0.0
Time: 1.8m
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 r14338593 = x;
        double r14338594 = exp(r14338593);
        double r14338595 = -r14338593;
        double r14338596 = exp(r14338595);
        double r14338597 = r14338594 - r14338596;
        double r14338598 = r14338594 + r14338596;
        double r14338599 = r14338597 / r14338598;
        return r14338599;
}

double f(double x) {
        double r14338600 = x;
        double r14338601 = tanh(r14338600);
        return r14338601;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

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