Average Error: 58.2 → 0.0
Time: 21.7s
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 r3653516 = x;
        double r3653517 = exp(r3653516);
        double r3653518 = -r3653516;
        double r3653519 = exp(r3653518);
        double r3653520 = r3653517 - r3653519;
        double r3653521 = r3653517 + r3653519;
        double r3653522 = r3653520 / r3653521;
        return r3653522;
}

double f(double x) {
        double r3653523 = x;
        double r3653524 = tanh(r3653523);
        return r3653524;
}

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