1 - \log \left(1 - \frac{x - y}{1 - y}\right)\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \le 1.545842237750884217971380531209124598035 \cdot 10^{-7}:\\
\;\;\;\;1 - \log \left(1 - \left(x - y\right) \cdot \frac{1}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(\sqrt{\mathsf{fma}\left(\frac{x}{{y}^{2}}, 1, \frac{x}{y}\right) - \frac{1}{y}}\right) + \log \left(\sqrt{\mathsf{fma}\left(\frac{x}{{y}^{2}}, 1, \frac{x}{y}\right) - \frac{1}{y}}\right)\right)\\
\end{array}double f(double x, double y) {
double r219601 = 1.0;
double r219602 = x;
double r219603 = y;
double r219604 = r219602 - r219603;
double r219605 = r219601 - r219603;
double r219606 = r219604 / r219605;
double r219607 = r219601 - r219606;
double r219608 = log(r219607);
double r219609 = r219601 - r219608;
return r219609;
}
double f(double x, double y) {
double r219610 = x;
double r219611 = y;
double r219612 = r219610 - r219611;
double r219613 = 1.0;
double r219614 = r219613 - r219611;
double r219615 = r219612 / r219614;
double r219616 = 1.5458422377508842e-07;
bool r219617 = r219615 <= r219616;
double r219618 = 1.0;
double r219619 = r219618 / r219614;
double r219620 = r219612 * r219619;
double r219621 = r219613 - r219620;
double r219622 = log(r219621);
double r219623 = r219613 - r219622;
double r219624 = 2.0;
double r219625 = pow(r219611, r219624);
double r219626 = r219610 / r219625;
double r219627 = r219610 / r219611;
double r219628 = fma(r219626, r219613, r219627);
double r219629 = r219613 / r219611;
double r219630 = r219628 - r219629;
double r219631 = sqrt(r219630);
double r219632 = log(r219631);
double r219633 = r219632 + r219632;
double r219634 = r219613 - r219633;
double r219635 = r219617 ? r219623 : r219634;
return r219635;
}




Bits error versus x




Bits error versus y
| Original | 18.2 |
|---|---|
| Target | 0.1 |
| Herbie | 0.8 |
if (/ (- x y) (- 1.0 y)) < 1.5458422377508842e-07Initial program 0.0
rmApplied div-inv0.0
if 1.5458422377508842e-07 < (/ (- x y) (- 1.0 y)) Initial program 59.8
Taylor expanded around inf 2.4
Simplified2.4
rmApplied add-sqr-sqrt2.4
Applied log-prod2.4
Final simplification0.8
herbie shell --seed 2019305 +o rules:numerics
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(if (< y -81284752.619472414) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))) (if (< y 3.0094271212461764e25) (log (/ (exp 1) (- 1 (/ (- x y) (- 1 y))))) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y)))))))
(- 1 (log (- 1 (/ (- x y) (- 1 y))))))