Average Error: 58.2 → 0.0
Time: 10.3s
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 r44815 = x;
        double r44816 = exp(r44815);
        double r44817 = -r44815;
        double r44818 = exp(r44817);
        double r44819 = r44816 - r44818;
        double r44820 = r44816 + r44818;
        double r44821 = r44819 / r44820;
        return r44821;
}

double f(double x) {
        double r44822 = x;
        double r44823 = tanh(r44822);
        return r44823;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 58.2

    \[\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 2020047 
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))