Average Error: 58.1 → 0.0
Time: 20.3s
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 r918224 = x;
        double r918225 = exp(r918224);
        double r918226 = -r918224;
        double r918227 = exp(r918226);
        double r918228 = r918225 - r918227;
        double r918229 = r918225 + r918227;
        double r918230 = r918228 / r918229;
        return r918230;
}

double f(double x) {
        double r918231 = x;
        double r918232 = tanh(r918231);
        return r918232;
}

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