Average Error: 58.2 → 0.0
Time: 13.6s
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 r28689 = x;
        double r28690 = exp(r28689);
        double r28691 = -r28689;
        double r28692 = exp(r28691);
        double r28693 = r28690 - r28692;
        double r28694 = r28690 + r28692;
        double r28695 = r28693 / r28694;
        return r28695;
}

double f(double x) {
        double r28696 = x;
        double r28697 = tanh(r28696);
        return r28697;
}

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