Average Error: 58.0 → 0.0
Time: 36.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 r2933294 = x;
        double r2933295 = exp(r2933294);
        double r2933296 = -r2933294;
        double r2933297 = exp(r2933296);
        double r2933298 = r2933295 - r2933297;
        double r2933299 = r2933295 + r2933297;
        double r2933300 = r2933298 / r2933299;
        return r2933300;
}

double f(double x) {
        double r2933301 = x;
        double r2933302 = tanh(r2933301);
        return r2933302;
}

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