Average Error: 58.3 → 0.0
Time: 38.3s
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 r11244527 = x;
        double r11244528 = exp(r11244527);
        double r11244529 = -r11244527;
        double r11244530 = exp(r11244529);
        double r11244531 = r11244528 - r11244530;
        double r11244532 = r11244528 + r11244530;
        double r11244533 = r11244531 / r11244532;
        return r11244533;
}

double f(double x) {
        double r11244534 = x;
        double r11244535 = tanh(r11244534);
        return r11244535;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.3

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