Average Error: 58.1 → 0.0
Time: 20.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 r39123 = x;
        double r39124 = exp(r39123);
        double r39125 = -r39123;
        double r39126 = exp(r39125);
        double r39127 = r39124 - r39126;
        double r39128 = r39124 + r39126;
        double r39129 = r39127 / r39128;
        return r39129;
}

double f(double x) {
        double r39130 = x;
        double r39131 = tanh(r39130);
        return r39131;
}

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