Average Error: 58.0 → 0.0
Time: 19.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 r1979637 = x;
        double r1979638 = exp(r1979637);
        double r1979639 = -r1979637;
        double r1979640 = exp(r1979639);
        double r1979641 = r1979638 - r1979640;
        double r1979642 = r1979638 + r1979640;
        double r1979643 = r1979641 / r1979642;
        return r1979643;
}

double f(double x) {
        double r1979644 = x;
        double r1979645 = tanh(r1979644);
        return r1979645;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.0

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