Average Error: 58.1 → 0.0
Time: 19.5s
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 r1873021 = x;
        double r1873022 = exp(r1873021);
        double r1873023 = -r1873021;
        double r1873024 = exp(r1873023);
        double r1873025 = r1873022 - r1873024;
        double r1873026 = r1873022 + r1873024;
        double r1873027 = r1873025 / r1873026;
        return r1873027;
}

double f(double x) {
        double r1873028 = x;
        double r1873029 = tanh(r1873028);
        return r1873029;
}

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