Average Error: 58.2 → 0.0
Time: 22.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 r6414173 = x;
        double r6414174 = exp(r6414173);
        double r6414175 = -r6414173;
        double r6414176 = exp(r6414175);
        double r6414177 = r6414174 - r6414176;
        double r6414178 = r6414174 + r6414176;
        double r6414179 = r6414177 / r6414178;
        return r6414179;
}

double f(double x) {
        double r6414180 = x;
        double r6414181 = tanh(r6414180);
        return r6414181;
}

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