Average Error: 58.1 → 0.0
Time: 1.1m
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 r39278 = x;
        double r39279 = exp(r39278);
        double r39280 = -r39278;
        double r39281 = exp(r39280);
        double r39282 = r39279 - r39281;
        double r39283 = r39279 + r39281;
        double r39284 = r39282 / r39283;
        return r39284;
}

double f(double x) {
        double r39285 = x;
        double r39286 = tanh(r39285);
        return r39286;
}

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