Average Error: 39.8 → 0.5
Time: 16.5s
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 r2575908 = x;
        double r2575909 = exp(r2575908);
        double r2575910 = 1.0;
        double r2575911 = r2575909 - r2575910;
        double r2575912 = r2575909 / r2575911;
        return r2575912;
}

double f(double x) {
        double r2575913 = x;
        double r2575914 = exp(r2575913);
        double r2575915 = sqrt(r2575914);
        double r2575916 = r2575913 + r2575913;
        double r2575917 = expm1(r2575916);
        double r2575918 = r2575915 / r2575917;
        double r2575919 = fma(r2575914, r2575918, r2575918);
        double r2575920 = r2575915 * r2575919;
        return r2575920;
}

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)))