Average Error: 58.0 → 0.0
Time: 5.2s
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 r36950 = x;
        double r36951 = exp(r36950);
        double r36952 = -r36950;
        double r36953 = exp(r36952);
        double r36954 = r36951 - r36953;
        double r36955 = r36951 + r36953;
        double r36956 = r36954 / r36955;
        return r36956;
}

double f(double x) {
        double r36957 = x;
        double r36958 = tanh(r36957);
        return r36958;
}

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