Average Error: 58.1 → 0.0
Time: 21.0s
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 r50307 = x;
        double r50308 = exp(r50307);
        double r50309 = -r50307;
        double r50310 = exp(r50309);
        double r50311 = r50308 - r50310;
        double r50312 = r50308 + r50310;
        double r50313 = r50311 / r50312;
        return r50313;
}

double f(double x) {
        double r50314 = x;
        double r50315 = tanh(r50314);
        return r50315;
}

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