Average Error: 39.8 → 0.5
Time: 15.8s
Precision: 64
\[\frac{e^{x}}{e^{x} - 1}\]
\[\sqrt{e^{x}} \cdot \mathsf{fma}\left(e^{x}, \frac{\sqrt{e^{x}}}{\mathsf{expm1}\left(x + x\right)}, \frac{\sqrt{e^{x}}}{\mathsf{expm1}\left(x + x\right)}\right)\]
\frac{e^{x}}{e^{x} - 1}
\sqrt{e^{x}} \cdot \mathsf{fma}\left(e^{x}, \frac{\sqrt{e^{x}}}{\mathsf{expm1}\left(x + x\right)}, \frac{\sqrt{e^{x}}}{\mathsf{expm1}\left(x + x\right)}\right)
double f(double x) {
        double r3453428 = x;
        double r3453429 = exp(r3453428);
        double r3453430 = 1.0;
        double r3453431 = r3453429 - r3453430;
        double r3453432 = r3453429 / r3453431;
        return r3453432;
}

double f(double x) {
        double r3453433 = x;
        double r3453434 = exp(r3453433);
        double r3453435 = sqrt(r3453434);
        double r3453436 = r3453433 + r3453433;
        double r3453437 = expm1(r3453436);
        double r3453438 = r3453435 / r3453437;
        double r3453439 = fma(r3453434, r3453438, r3453438);
        double r3453440 = r3453435 * r3453439;
        return r3453440;
}

Error

Bits error versus x

Target

Original39.8
Target39.4
Herbie0.5
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Initial program 39.8

    \[\frac{e^{x}}{e^{x} - 1}\]
  2. Using strategy rm
  3. Applied flip--39.8

    \[\leadsto \frac{e^{x}}{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}\]
  4. Applied associate-/r/39.8

    \[\leadsto \color{blue}{\frac{e^{x}}{e^{x} \cdot e^{x} - 1 \cdot 1} \cdot \left(e^{x} + 1\right)}\]
  5. Simplified0.5

    \[\leadsto \color{blue}{\frac{e^{x}}{\mathsf{expm1}\left(x + x\right)}} \cdot \left(e^{x} + 1\right)\]
  6. Using strategy rm
  7. Applied *-un-lft-identity0.5

    \[\leadsto \frac{e^{x}}{\color{blue}{1 \cdot \mathsf{expm1}\left(x + x\right)}} \cdot \left(e^{x} + 1\right)\]
  8. Applied add-sqr-sqrt0.5

    \[\leadsto \frac{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}}}{1 \cdot \mathsf{expm1}\left(x + x\right)} \cdot \left(e^{x} + 1\right)\]
  9. Applied times-frac0.5

    \[\leadsto \color{blue}{\left(\frac{\sqrt{e^{x}}}{1} \cdot \frac{\sqrt{e^{x}}}{\mathsf{expm1}\left(x + x\right)}\right)} \cdot \left(e^{x} + 1\right)\]
  10. Applied associate-*l*0.5

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

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

    \[\leadsto \sqrt{e^{x}} \cdot \mathsf{fma}\left(e^{x}, \frac{\sqrt{e^{x}}}{\mathsf{expm1}\left(x + x\right)}, \frac{\sqrt{e^{x}}}{\mathsf{expm1}\left(x + x\right)}\right)\]

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x)
  :name "expq2 (section 3.11)"

  :herbie-target
  (/ 1 (- 1 (exp (- x))))

  (/ (exp x) (- (exp x) 1)))