Average Error: 58.2 → 0.0
Time: 21.0s
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 r3674121 = x;
        double r3674122 = exp(r3674121);
        double r3674123 = -r3674121;
        double r3674124 = exp(r3674123);
        double r3674125 = r3674122 - r3674124;
        double r3674126 = r3674122 + r3674124;
        double r3674127 = r3674125 / r3674126;
        return r3674127;
}

double f(double x) {
        double r3674128 = x;
        double r3674129 = tanh(r3674128);
        return r3674129;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.2

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