Average Error: 58.1 → 0.0
Time: 1.0m
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 r3684773 = x;
        double r3684774 = exp(r3684773);
        double r3684775 = -r3684773;
        double r3684776 = exp(r3684775);
        double r3684777 = r3684774 - r3684776;
        double r3684778 = r3684774 + r3684776;
        double r3684779 = r3684777 / r3684778;
        return r3684779;
}

double f(double x) {
        double r3684780 = x;
        double r3684781 = tanh(r3684780);
        return r3684781;
}

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