Average Error: 58.1 → 0.0
Time: 18.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 r1076644 = x;
        double r1076645 = exp(r1076644);
        double r1076646 = -r1076644;
        double r1076647 = exp(r1076646);
        double r1076648 = r1076645 - r1076647;
        double r1076649 = r1076645 + r1076647;
        double r1076650 = r1076648 / r1076649;
        return r1076650;
}

double f(double x) {
        double r1076651 = x;
        double r1076652 = tanh(r1076651);
        return r1076652;
}

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