Average Error: 58.5 → 0.0
Time: 37.4s
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 r57066 = x;
        double r57067 = exp(r57066);
        double r57068 = -r57066;
        double r57069 = exp(r57068);
        double r57070 = r57067 - r57069;
        double r57071 = r57067 + r57069;
        double r57072 = r57070 / r57071;
        return r57072;
}

double f(double x) {
        double r57073 = x;
        double r57074 = tanh(r57073);
        return r57074;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.5

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