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 r1025288 = x;
        double r1025289 = exp(r1025288);
        double r1025290 = -r1025288;
        double r1025291 = exp(r1025290);
        double r1025292 = r1025289 - r1025291;
        double r1025293 = r1025289 + r1025291;
        double r1025294 = r1025292 / r1025293;
        return r1025294;
}

double f(double x) {
        double r1025295 = x;
        double r1025296 = tanh(r1025295);
        return r1025296;
}

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