Average Error: 58.2 → 0.0
Time: 4.5s
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 r54266 = x;
        double r54267 = exp(r54266);
        double r54268 = -r54266;
        double r54269 = exp(r54268);
        double r54270 = r54267 - r54269;
        double r54271 = r54267 + r54269;
        double r54272 = r54270 / r54271;
        return r54272;
}

double f(double x) {
        double r54273 = x;
        double r54274 = tanh(r54273);
        return r54274;
}

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