Average Error: 58.2 → 0.0
Time: 19.4s
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 r43203 = x;
        double r43204 = exp(r43203);
        double r43205 = -r43203;
        double r43206 = exp(r43205);
        double r43207 = r43204 - r43206;
        double r43208 = r43204 + r43206;
        double r43209 = r43207 / r43208;
        return r43209;
}

double f(double x) {
        double r43210 = x;
        double r43211 = tanh(r43210);
        return r43211;
}

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)))))