Average Error: 58.1 → 0.0
Time: 14.8s
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 r1914102 = x;
        double r1914103 = exp(r1914102);
        double r1914104 = -r1914102;
        double r1914105 = exp(r1914104);
        double r1914106 = r1914103 - r1914105;
        double r1914107 = r1914103 + r1914105;
        double r1914108 = r1914106 / r1914107;
        return r1914108;
}

double f(double x) {
        double r1914109 = x;
        double r1914110 = tanh(r1914109);
        return r1914110;
}

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