Average Error: 58.1 → 0.0
Time: 36.4s
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 r2463237 = x;
        double r2463238 = exp(r2463237);
        double r2463239 = -r2463237;
        double r2463240 = exp(r2463239);
        double r2463241 = r2463238 - r2463240;
        double r2463242 = r2463238 + r2463240;
        double r2463243 = r2463241 / r2463242;
        return r2463243;
}

double f(double x) {
        double r2463244 = x;
        double r2463245 = tanh(r2463244);
        return r2463245;
}

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