Average Error: 58.1 → 0.0
Time: 22.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 r2384215 = x;
        double r2384216 = exp(r2384215);
        double r2384217 = -r2384215;
        double r2384218 = exp(r2384217);
        double r2384219 = r2384216 - r2384218;
        double r2384220 = r2384216 + r2384218;
        double r2384221 = r2384219 / r2384220;
        return r2384221;
}

double f(double x) {
        double r2384222 = x;
        double r2384223 = tanh(r2384222);
        return r2384223;
}

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