Average Error: 58.2 → 0.0
Time: 19.7s
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 r51185 = x;
        double r51186 = exp(r51185);
        double r51187 = -r51185;
        double r51188 = exp(r51187);
        double r51189 = r51186 - r51188;
        double r51190 = r51186 + r51188;
        double r51191 = r51189 / r51190;
        return r51191;
}

double f(double x) {
        double r51192 = x;
        double r51193 = tanh(r51192);
        return r51193;
}

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