Average Error: 58.1 → 0.0
Time: 15.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 r1482227 = x;
        double r1482228 = exp(r1482227);
        double r1482229 = -r1482227;
        double r1482230 = exp(r1482229);
        double r1482231 = r1482228 - r1482230;
        double r1482232 = r1482228 + r1482230;
        double r1482233 = r1482231 / r1482232;
        return r1482233;
}

double f(double x) {
        double r1482234 = x;
        double r1482235 = tanh(r1482234);
        return r1482235;
}

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