1 - \log \left(1 - \frac{x - y}{1 - y}\right)\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \le 0.99781943200392309:\\
\;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\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 r351640 = 1.0;
double r351641 = x;
double r351642 = y;
double r351643 = r351641 - r351642;
double r351644 = r351640 - r351642;
double r351645 = r351643 / r351644;
double r351646 = r351640 - r351645;
double r351647 = log(r351646);
double r351648 = r351640 - r351647;
return r351648;
}
double f(double x, double y) {
double r351649 = x;
double r351650 = y;
double r351651 = r351649 - r351650;
double r351652 = 1.0;
double r351653 = r351652 - r351650;
double r351654 = r351651 / r351653;
double r351655 = 0.9978194320039231;
bool r351656 = r351654 <= r351655;
double r351657 = exp(r351652);
double r351658 = r351652 - r351654;
double r351659 = r351657 / r351658;
double r351660 = log(r351659);
double r351661 = 2.0;
double r351662 = pow(r351650, r351661);
double r351663 = r351649 / r351662;
double r351664 = 1.0;
double r351665 = r351664 / r351650;
double r351666 = r351663 - r351665;
double r351667 = r351649 / r351650;
double r351668 = fma(r351652, r351666, r351667);
double r351669 = r351657 / r351668;
double r351670 = log(r351669);
double r351671 = r351656 ? r351660 : r351670;
return r351671;
}




Bits error versus x




Bits error versus y
| Original | 18.3 |
|---|---|
| Target | 0.1 |
| Herbie | 0.2 |
if (/ (- x y) (- 1.0 y)) < 0.9978194320039231Initial program 0.0
rmApplied add-log-exp0.0
Applied diff-log0.0
if 0.9978194320039231 < (/ (- x y) (- 1.0 y)) Initial program 61.5
rmApplied add-log-exp61.5
Applied diff-log61.5
Taylor expanded around inf 0.7
Simplified0.7
Final simplification0.2
herbie shell --seed 2020039 +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))))))