Average Error: 58.2 → 0.0
Time: 21.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 r2357030 = x;
        double r2357031 = exp(r2357030);
        double r2357032 = -r2357030;
        double r2357033 = exp(r2357032);
        double r2357034 = r2357031 - r2357033;
        double r2357035 = r2357031 + r2357033;
        double r2357036 = r2357034 / r2357035;
        return r2357036;
}

double f(double x) {
        double r2357037 = x;
        double r2357038 = tanh(r2357037);
        return r2357038;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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