Average Error: 58.2 → 0.0
Time: 12.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 r66772 = x;
        double r66773 = exp(r66772);
        double r66774 = -r66772;
        double r66775 = exp(r66774);
        double r66776 = r66773 - r66775;
        double r66777 = r66773 + r66775;
        double r66778 = r66776 / r66777;
        return r66778;
}

double f(double x) {
        double r66779 = x;
        double r66780 = tanh(r66779);
        return r66780;
}

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