Average Error: 58.1 → 0.0
Time: 4.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 r56223 = x;
        double r56224 = exp(r56223);
        double r56225 = -r56223;
        double r56226 = exp(r56225);
        double r56227 = r56224 - r56226;
        double r56228 = r56224 + r56226;
        double r56229 = r56227 / r56228;
        return r56229;
}

double f(double x) {
        double r56230 = x;
        double r56231 = tanh(r56230);
        return r56231;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.1

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