Average Error: 58.1 → 0.0
Time: 1.1m
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 r50928 = x;
        double r50929 = exp(r50928);
        double r50930 = -r50928;
        double r50931 = exp(r50930);
        double r50932 = r50929 - r50931;
        double r50933 = r50929 + r50931;
        double r50934 = r50932 / r50933;
        return r50934;
}

double f(double x) {
        double r50935 = x;
        double r50936 = tanh(r50935);
        return r50936;
}

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