Average Error: 58.1 → 0.0
Time: 6.0s
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 r34171 = x;
        double r34172 = exp(r34171);
        double r34173 = -r34171;
        double r34174 = exp(r34173);
        double r34175 = r34172 - r34174;
        double r34176 = r34172 + r34174;
        double r34177 = r34175 / r34176;
        return r34177;
}

double f(double x) {
        double r34178 = x;
        double r34179 = tanh(r34178);
        return r34179;
}

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