Average Error: 58.2 → 0.0
Time: 24.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 r2897218 = x;
        double r2897219 = exp(r2897218);
        double r2897220 = -r2897218;
        double r2897221 = exp(r2897220);
        double r2897222 = r2897219 - r2897221;
        double r2897223 = r2897219 + r2897221;
        double r2897224 = r2897222 / r2897223;
        return r2897224;
}

double f(double x) {
        double r2897225 = x;
        double r2897226 = tanh(r2897225);
        return r2897226;
}

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. Using strategy rm
  5. Applied add-sqr-sqrt32.2

    \[\leadsto \color{blue}{\sqrt{\tanh x} \cdot \sqrt{\tanh x}}\]
  6. Using strategy rm
  7. Applied rem-square-sqrt0.0

    \[\leadsto \color{blue}{\tanh x}\]
  8. Final simplification0.0

    \[\leadsto \tanh x\]

Reproduce

herbie shell --seed 2019169 
(FPCore (x)
  :name "Hyperbolic tangent"
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))