1 - \log \left(1 - \frac{x - y}{1 - y}\right)\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \le 0.99999880692138432:\\
\;\;\;\;\log \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{e^{1}}{\mathsf{fma}\left(1, \frac{x}{{y}^{2}} - \frac{1}{y}, \frac{x}{y}\right)}\right)\\
\end{array}double f(double x, double y) {
double r397577 = 1.0;
double r397578 = x;
double r397579 = y;
double r397580 = r397578 - r397579;
double r397581 = r397577 - r397579;
double r397582 = r397580 / r397581;
double r397583 = r397577 - r397582;
double r397584 = log(r397583);
double r397585 = r397577 - r397584;
return r397585;
}
double f(double x, double y) {
double r397586 = x;
double r397587 = y;
double r397588 = r397586 - r397587;
double r397589 = 1.0;
double r397590 = r397589 - r397587;
double r397591 = r397588 / r397590;
double r397592 = 0.9999988069213843;
bool r397593 = r397591 <= r397592;
double r397594 = exp(r397589);
double r397595 = r397589 - r397591;
double r397596 = r397594 / r397595;
double r397597 = log1p(r397596);
double r397598 = expm1(r397597);
double r397599 = log(r397598);
double r397600 = 2.0;
double r397601 = pow(r397587, r397600);
double r397602 = r397586 / r397601;
double r397603 = 1.0;
double r397604 = r397603 / r397587;
double r397605 = r397602 - r397604;
double r397606 = r397586 / r397587;
double r397607 = fma(r397589, r397605, r397606);
double r397608 = r397594 / r397607;
double r397609 = log(r397608);
double r397610 = r397593 ? r397599 : r397609;
return r397610;
}




Bits error versus x




Bits error versus y
| Original | 18.3 |
|---|---|
| Target | 0.1 |
| Herbie | 0.2 |
if (/ (- x y) (- 1.0 y)) < 0.9999988069213843Initial program 0.1
rmApplied add-log-exp0.1
Applied diff-log0.1
rmApplied expm1-log1p-u0.1
if 0.9999988069213843 < (/ (- x y) (- 1.0 y)) Initial program 62.5
rmApplied add-log-exp62.5
Applied diff-log62.5
Taylor expanded around inf 0.3
Simplified0.3
Final simplification0.2
herbie shell --seed 2020024 +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.61947241) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1) (- 1 (/ (- x y) (- 1 y))))) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y)))))))
(- 1 (log (- 1 (/ (- x y) (- 1 y))))))