Average Error: 58.1 → 0.0
Time: 31.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 r2069337 = x;
        double r2069338 = exp(r2069337);
        double r2069339 = -r2069337;
        double r2069340 = exp(r2069339);
        double r2069341 = r2069338 - r2069340;
        double r2069342 = r2069338 + r2069340;
        double r2069343 = r2069341 / r2069342;
        return r2069343;
}

double f(double x) {
        double r2069344 = x;
        double r2069345 = tanh(r2069344);
        return r2069345;
}

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