Average Error: 58.0 → 0.0
Time: 15.2s
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 r47998 = x;
        double r47999 = exp(r47998);
        double r48000 = -r47998;
        double r48001 = exp(r48000);
        double r48002 = r47999 - r48001;
        double r48003 = r47999 + r48001;
        double r48004 = r48002 / r48003;
        return r48004;
}

double f(double x) {
        double r48005 = x;
        double r48006 = tanh(r48005);
        return r48006;
}

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