1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.00013641523025847621:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{e^{\frac{\frac{1}{1 - x} - \frac{x}{1 - x}}{y}} \cdot \left(x + -1\right)}{y}\right)\\
\end{array}
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
(FPCore (x y)
:precision binary64
(if (<= (/ (- x y) (- 1.0 y)) 0.00013641523025847621)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(-
1.0
(log
(/ (* (exp (/ (- (/ 1.0 (- 1.0 x)) (/ x (- 1.0 x))) y)) (+ x -1.0)) y)))))double code(double x, double y) {
return 1.0 - log(1.0 - ((x - y) / (1.0 - y)));
}
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.00013641523025847621) {
tmp = 1.0 - log1p((x - y) / (y + -1.0));
} else {
tmp = 1.0 - log((exp(((1.0 / (1.0 - x)) - (x / (1.0 - x))) / y) * (x + -1.0)) / y);
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 18.4 |
|---|---|
| Target | 0.1 |
| Herbie | 0.4 |
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 1.3641523025847621e-4Initial program 0.0
Simplified0.0
if 1.3641523025847621e-4 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 60.3
Simplified60.3
Taylor expanded in y around -inf 11.9
Simplified11.9
Applied add-log-exp_binary6411.9
Applied add-log-exp_binary6411.9
Applied diff-log_binary6411.9
Applied log1p-udef_binary6411.9
Applied sum-log_binary641.3
Applied sum-log_binary641.3
Simplified1.3
Taylor expanded in y around 0 1.3
Simplified1.3
Final simplification0.4
herbie shell --seed 2021313
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(if (< y -81284752.61947241) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))
(- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))