Average Error: 58.1 → 0.0
Time: 22.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 r2254263 = x;
        double r2254264 = exp(r2254263);
        double r2254265 = -r2254263;
        double r2254266 = exp(r2254265);
        double r2254267 = r2254264 - r2254266;
        double r2254268 = r2254264 + r2254266;
        double r2254269 = r2254267 / r2254268;
        return r2254269;
}

double f(double x) {
        double r2254270 = x;
        double r2254271 = tanh(r2254270);
        return r2254271;
}

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