Average Error: 58.2 → 0.0
Time: 16.9s
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 r1118517 = x;
        double r1118518 = exp(r1118517);
        double r1118519 = -r1118517;
        double r1118520 = exp(r1118519);
        double r1118521 = r1118518 - r1118520;
        double r1118522 = r1118518 + r1118520;
        double r1118523 = r1118521 / r1118522;
        return r1118523;
}

double f(double x) {
        double r1118524 = x;
        double r1118525 = tanh(r1118524);
        return r1118525;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.2

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