\frac{e^{x}}{e^{x} - 1}\begin{array}{l}
\mathbf{if}\;\frac{e^{x}}{e^{x} - 1} \leq 6.7951388768857965:\\
\;\;\;\;\frac{e^{x}}{\sqrt[3]{\left(e^{x} - 1\right) \cdot \left(\left(e^{x} - 1\right) \cdot \left(e^{x} - 1\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(0.5 + \frac{1}{x}\right) + x \cdot 0.08333333333333333\right) - {x}^{3} \cdot 0.001388888888888889\\
\end{array}(FPCore (x) :precision binary64 (/ (exp x) (- (exp x) 1.0)))
(FPCore (x)
:precision binary64
(if (<= (/ (exp x) (- (exp x) 1.0)) 6.7951388768857965)
(/ (exp x) (cbrt (* (- (exp x) 1.0) (* (- (exp x) 1.0) (- (exp x) 1.0)))))
(-
(+ (+ 0.5 (/ 1.0 x)) (* x 0.08333333333333333))
(* (pow x 3.0) 0.001388888888888889))))double code(double x) {
return exp(x) / (exp(x) - 1.0);
}
double code(double x) {
double tmp;
if ((exp(x) / (exp(x) - 1.0)) <= 6.7951388768857965) {
tmp = exp(x) / cbrt((exp(x) - 1.0) * ((exp(x) - 1.0) * (exp(x) - 1.0)));
} else {
tmp = ((0.5 + (1.0 / x)) + (x * 0.08333333333333333)) - (pow(x, 3.0) * 0.001388888888888889);
}
return tmp;
}




Bits error versus x
Results
| Original | 41.3 |
|---|---|
| Target | 40.8 |
| Herbie | 0.9 |
if (/.f64 (exp.f64 x) (-.f64 (exp.f64 x) 1)) < 6.79513887688579654Initial program 1.2
rmApplied add-cbrt-cube_binary64_14781.2
if 6.79513887688579654 < (/.f64 (exp.f64 x) (-.f64 (exp.f64 x) 1)) Initial program 63.0
Taylor expanded around 0 0.7
Simplified0.7
Final simplification0.9
herbie shell --seed 2021019
(FPCore (x)
:name "expq2 (section 3.11)"
:precision binary64
:herbie-target
(/ 1.0 (- 1.0 (exp (- x))))
(/ (exp x) (- (exp x) 1.0)))