Average Error: 58.1 → 0.0
Time: 4.4s
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 r30551 = x;
        double r30552 = exp(r30551);
        double r30553 = -r30551;
        double r30554 = exp(r30553);
        double r30555 = r30552 - r30554;
        double r30556 = r30552 + r30554;
        double r30557 = r30555 / r30556;
        return r30557;
}

double f(double x) {
        double r30558 = x;
        double r30559 = tanh(r30558);
        return r30559;
}

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