Average Error: 58.1 → 0.7
Time: 5.5s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{{\left(e^{2 \cdot x} + 1\right)}^{3}}}\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{{\left(e^{2 \cdot x} + 1\right)}^{3}}}
double f(double x) {
        double r38275 = x;
        double r38276 = exp(r38275);
        double r38277 = -r38275;
        double r38278 = exp(r38277);
        double r38279 = r38276 - r38278;
        double r38280 = r38276 + r38278;
        double r38281 = r38279 / r38280;
        return r38281;
}

double f(double x) {
        double r38282 = x;
        double r38283 = r38282 + r38282;
        double r38284 = expm1(r38283);
        double r38285 = 2.0;
        double r38286 = r38285 * r38282;
        double r38287 = exp(r38286);
        double r38288 = 1.0;
        double r38289 = r38287 + r38288;
        double r38290 = 3.0;
        double r38291 = pow(r38289, r38290);
        double r38292 = cbrt(r38291);
        double r38293 = r38284 / r38292;
        return r38293;
}

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. Simplified0.7

    \[\leadsto \color{blue}{1 \cdot \frac{\mathsf{expm1}\left(x + x\right)}{\mathsf{fma}\left(1, 1, e^{x + x}\right)}}\]
  3. Using strategy rm
  4. Applied add-cbrt-cube0.7

    \[\leadsto 1 \cdot \frac{\mathsf{expm1}\left(x + x\right)}{\color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(1, 1, e^{x + x}\right) \cdot \mathsf{fma}\left(1, 1, e^{x + x}\right)\right) \cdot \mathsf{fma}\left(1, 1, e^{x + x}\right)}}}\]
  5. Simplified0.7

    \[\leadsto 1 \cdot \frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{\color{blue}{{\left(e^{2 \cdot x} + 1\right)}^{3}}}}\]
  6. Final simplification0.7

    \[\leadsto \frac{\mathsf{expm1}\left(x + x\right)}{\sqrt[3]{{\left(e^{2 \cdot x} + 1\right)}^{3}}}\]

Reproduce

herbie shell --seed 2020025 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))