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 r2575940 = x;
        double r2575941 = exp(r2575940);
        double r2575942 = -r2575940;
        double r2575943 = exp(r2575942);
        double r2575944 = r2575941 - r2575943;
        double r2575945 = r2575941 + r2575943;
        double r2575946 = r2575944 / r2575945;
        return r2575946;
}

double f(double x) {
        double r2575947 = x;
        double r2575948 = tanh(r2575947);
        return r2575948;
}

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