Average Error: 58.1 → 0.0
Time: 16.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 r1871087 = x;
        double r1871088 = exp(r1871087);
        double r1871089 = -r1871087;
        double r1871090 = exp(r1871089);
        double r1871091 = r1871088 - r1871090;
        double r1871092 = r1871088 + r1871090;
        double r1871093 = r1871091 / r1871092;
        return r1871093;
}

double f(double x) {
        double r1871094 = x;
        double r1871095 = tanh(r1871094);
        return r1871095;
}

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