Average Error: 58.1 → 0.0
Time: 1.0m
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 r2359889 = x;
        double r2359890 = exp(r2359889);
        double r2359891 = -r2359889;
        double r2359892 = exp(r2359891);
        double r2359893 = r2359890 - r2359892;
        double r2359894 = r2359890 + r2359892;
        double r2359895 = r2359893 / r2359894;
        return r2359895;
}

double f(double x) {
        double r2359896 = x;
        double r2359897 = tanh(r2359896);
        return r2359897;
}

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