Average Error: 58.1 → 0.0
Time: 16.6s
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 r906680 = x;
        double r906681 = exp(r906680);
        double r906682 = -r906680;
        double r906683 = exp(r906682);
        double r906684 = r906681 - r906683;
        double r906685 = r906681 + r906683;
        double r906686 = r906684 / r906685;
        return r906686;
}

double f(double x) {
        double r906687 = x;
        double r906688 = tanh(r906687);
        return r906688;
}

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