Average Error: 58.3 → 0.0
Time: 1.1m
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 r45644 = x;
        double r45645 = exp(r45644);
        double r45646 = -r45644;
        double r45647 = exp(r45646);
        double r45648 = r45645 - r45647;
        double r45649 = r45645 + r45647;
        double r45650 = r45648 / r45649;
        return r45650;
}

double f(double x) {
        double r45651 = x;
        double r45652 = tanh(r45651);
        return r45652;
}

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