Average Error: 58.0 → 0.0
Time: 4.1s
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 r52100 = x;
        double r52101 = exp(r52100);
        double r52102 = -r52100;
        double r52103 = exp(r52102);
        double r52104 = r52101 - r52103;
        double r52105 = r52101 + r52103;
        double r52106 = r52104 / r52105;
        return r52106;
}

double f(double x) {
        double r52107 = x;
        double r52108 = tanh(r52107);
        return r52108;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

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