\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;e^{x} \le 0.013991682066964498:\\
\;\;\;\;\frac{e^{x}}{{\left(e^{x}\right)}^{3} - {1}^{3}} \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{12}, x, \frac{1}{x}\right) + \frac{1}{2}\\
\end{array}double f(double x) {
double r73808 = x;
double r73809 = exp(r73808);
double r73810 = 1.0;
double r73811 = r73809 - r73810;
double r73812 = r73809 / r73811;
return r73812;
}
double f(double x) {
double r73813 = x;
double r73814 = exp(r73813);
double r73815 = 0.013991682066964498;
bool r73816 = r73814 <= r73815;
double r73817 = 3.0;
double r73818 = pow(r73814, r73817);
double r73819 = 1.0;
double r73820 = pow(r73819, r73817);
double r73821 = r73818 - r73820;
double r73822 = r73814 / r73821;
double r73823 = r73814 * r73814;
double r73824 = r73819 * r73819;
double r73825 = r73814 * r73819;
double r73826 = r73824 + r73825;
double r73827 = r73823 + r73826;
double r73828 = r73822 * r73827;
double r73829 = 0.08333333333333333;
double r73830 = 1.0;
double r73831 = r73830 / r73813;
double r73832 = fma(r73829, r73813, r73831);
double r73833 = 0.5;
double r73834 = r73832 + r73833;
double r73835 = r73816 ? r73828 : r73834;
return r73835;
}




Bits error versus x
| Original | 41.2 |
|---|---|
| Target | 40.8 |
| Herbie | 0.6 |
if (exp x) < 0.013991682066964498Initial program 0.0
rmApplied flip3--0.0
Applied associate-/r/0.0
if 0.013991682066964498 < (exp x) Initial program 62.0
Taylor expanded around 0 1.0
Simplified1.0
Final simplification0.6
herbie shell --seed 2019199 +o rules:numerics
(FPCore (x)
:name "expq2 (section 3.11)"
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))