Average Error: 58.2 → 0.0
Time: 20.8s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\tanh x\]
double f(double x) {
        double r11216137 = x;
        double r11216138 = exp(r11216137);
        double r11216139 = -r11216137;
        double r11216140 = exp(r11216139);
        double r11216141 = r11216138 - r11216140;
        double r11216142 = r11216138 + r11216140;
        double r11216143 = r11216141 / r11216142;
        return r11216143;
}

double f(double x) {
        double r11216144 = x;
        double r11216145 = tanh(r11216144);
        return r11216145;
}

\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\tanh x

Error

Bits error versus x

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