Average Error: 58.2 → 1.9
Time: 31.9s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\left(x \cdot \frac{-1}{3}\right) \cdot \left(x \cdot x\right) + \left(x + \frac{2}{15} \cdot {x}^{5}\right)\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\left(x \cdot \frac{-1}{3}\right) \cdot \left(x \cdot x\right) + \left(x + \frac{2}{15} \cdot {x}^{5}\right)
double f(double x) {
        double r2417291 = x;
        double r2417292 = exp(r2417291);
        double r2417293 = -r2417291;
        double r2417294 = exp(r2417293);
        double r2417295 = r2417292 - r2417294;
        double r2417296 = r2417292 + r2417294;
        double r2417297 = r2417295 / r2417296;
        return r2417297;
}

double f(double x) {
        double r2417298 = x;
        double r2417299 = -0.3333333333333333;
        double r2417300 = r2417298 * r2417299;
        double r2417301 = r2417298 * r2417298;
        double r2417302 = r2417300 * r2417301;
        double r2417303 = 0.13333333333333333;
        double r2417304 = 5.0;
        double r2417305 = pow(r2417298, r2417304);
        double r2417306 = r2417303 * r2417305;
        double r2417307 = r2417298 + r2417306;
        double r2417308 = r2417302 + r2417307;
        return r2417308;
}

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. Taylor expanded around 0 1.9

    \[\leadsto \color{blue}{\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}}\]
  5. Simplified1.9

    \[\leadsto \color{blue}{\left(x \cdot \frac{-1}{3}\right) \cdot \left(x \cdot x\right) + \left({x}^{5} \cdot \frac{2}{15} + x\right)}\]
  6. Final simplification1.9

    \[\leadsto \left(x \cdot \frac{-1}{3}\right) \cdot \left(x \cdot x\right) + \left(x + \frac{2}{15} \cdot {x}^{5}\right)\]

Reproduce

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