Average Error: 58.1 → 0.0
Time: 20.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 r2033933 = x;
        double r2033934 = exp(r2033933);
        double r2033935 = -r2033933;
        double r2033936 = exp(r2033935);
        double r2033937 = r2033934 - r2033936;
        double r2033938 = r2033934 + r2033936;
        double r2033939 = r2033937 / r2033938;
        return r2033939;
}

double f(double x) {
        double r2033940 = x;
        double r2033941 = tanh(r2033940);
        return r2033941;
}

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