Average Error: 58.0 → 0.0
Time: 34.2s
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 r2747088 = x;
        double r2747089 = exp(r2747088);
        double r2747090 = -r2747088;
        double r2747091 = exp(r2747090);
        double r2747092 = r2747089 - r2747091;
        double r2747093 = r2747089 + r2747091;
        double r2747094 = r2747092 / r2747093;
        return r2747094;
}

double f(double x) {
        double r2747095 = x;
        double r2747096 = tanh(r2747095);
        return r2747096;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

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