Average Error: 58.1 → 0.0
Time: 41.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 r4659901 = x;
        double r4659902 = exp(r4659901);
        double r4659903 = -r4659901;
        double r4659904 = exp(r4659903);
        double r4659905 = r4659902 - r4659904;
        double r4659906 = r4659902 + r4659904;
        double r4659907 = r4659905 / r4659906;
        return r4659907;
}

double f(double x) {
        double r4659908 = x;
        double r4659909 = tanh(r4659908);
        return r4659909;
}

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