Average Error: 58.0 → 0.0
Time: 4.8s
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 r33998 = x;
        double r33999 = exp(r33998);
        double r34000 = -r33998;
        double r34001 = exp(r34000);
        double r34002 = r33999 - r34001;
        double r34003 = r33999 + r34001;
        double r34004 = r34002 / r34003;
        return r34004;
}

double f(double x) {
        double r34005 = x;
        double r34006 = tanh(r34005);
        return r34006;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

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