Average Error: 58.1 → 0.0
Time: 18.0s
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 r2239329 = x;
        double r2239330 = exp(r2239329);
        double r2239331 = -r2239329;
        double r2239332 = exp(r2239331);
        double r2239333 = r2239330 - r2239332;
        double r2239334 = r2239330 + r2239332;
        double r2239335 = r2239333 / r2239334;
        return r2239335;
}

double f(double x) {
        double r2239336 = x;
        double r2239337 = tanh(r2239336);
        return r2239337;
}

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