Average Error: 58.1 → 0.0
Time: 17.7s
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 r2054826 = x;
        double r2054827 = exp(r2054826);
        double r2054828 = -r2054826;
        double r2054829 = exp(r2054828);
        double r2054830 = r2054827 - r2054829;
        double r2054831 = r2054827 + r2054829;
        double r2054832 = r2054830 / r2054831;
        return r2054832;
}

double f(double x) {
        double r2054833 = x;
        double r2054834 = tanh(r2054833);
        return r2054834;
}

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