Average Error: 58.2 → 0.0
Time: 16.7s
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 r927809 = x;
        double r927810 = exp(r927809);
        double r927811 = -r927809;
        double r927812 = exp(r927811);
        double r927813 = r927810 - r927812;
        double r927814 = r927810 + r927812;
        double r927815 = r927813 / r927814;
        return r927815;
}

double f(double x) {
        double r927816 = x;
        double r927817 = tanh(r927816);
        return r927817;
}

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