Average Error: 58.1 → 0.7
Time: 5.6s
Precision: 64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\frac{\mathsf{expm1}\left(x + x\right)}{{\left(e^{2 \cdot x}\right)}^{3} + 1} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 - e^{2 \cdot x} \cdot 1\right)\right)\]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\frac{\mathsf{expm1}\left(x + x\right)}{{\left(e^{2 \cdot x}\right)}^{3} + 1} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 - e^{2 \cdot x} \cdot 1\right)\right)
double f(double x) {
        double r40281 = x;
        double r40282 = exp(r40281);
        double r40283 = -r40281;
        double r40284 = exp(r40283);
        double r40285 = r40282 - r40284;
        double r40286 = r40282 + r40284;
        double r40287 = r40285 / r40286;
        return r40287;
}

double f(double x) {
        double r40288 = x;
        double r40289 = r40288 + r40288;
        double r40290 = expm1(r40289);
        double r40291 = 2.0;
        double r40292 = r40291 * r40288;
        double r40293 = exp(r40292);
        double r40294 = 3.0;
        double r40295 = pow(r40293, r40294);
        double r40296 = 1.0;
        double r40297 = r40295 + r40296;
        double r40298 = r40290 / r40297;
        double r40299 = r40293 * r40293;
        double r40300 = r40293 * r40296;
        double r40301 = r40296 - r40300;
        double r40302 = r40299 + r40301;
        double r40303 = r40298 * r40302;
        return r40303;
}

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 div-inv0.7

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

    \[\leadsto 1 \cdot \left(\mathsf{expm1}\left(x + x\right) \cdot \color{blue}{\frac{1}{e^{2 \cdot x} + 1}}\right)\]
  6. Using strategy rm
  7. Applied flip3-+0.7

    \[\leadsto 1 \cdot \left(\mathsf{expm1}\left(x + x\right) \cdot \frac{1}{\color{blue}{\frac{{\left(e^{2 \cdot x}\right)}^{3} + {1}^{3}}{e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 \cdot 1 - e^{2 \cdot x} \cdot 1\right)}}}\right)\]
  8. Applied associate-/r/0.7

    \[\leadsto 1 \cdot \left(\mathsf{expm1}\left(x + x\right) \cdot \color{blue}{\left(\frac{1}{{\left(e^{2 \cdot x}\right)}^{3} + {1}^{3}} \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 \cdot 1 - e^{2 \cdot x} \cdot 1\right)\right)\right)}\right)\]
  9. Applied associate-*r*0.7

    \[\leadsto 1 \cdot \color{blue}{\left(\left(\mathsf{expm1}\left(x + x\right) \cdot \frac{1}{{\left(e^{2 \cdot x}\right)}^{3} + {1}^{3}}\right) \cdot \left(e^{2 \cdot x} \cdot e^{2 \cdot x} + \left(1 \cdot 1 - e^{2 \cdot x} \cdot 1\right)\right)\right)}\]
  10. Simplified0.7

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

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

Reproduce

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