1 - \log \left(1 - \frac{x - y}{1 - y}\right)\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.9999895614048552:\\
\;\;\;\;1 - \log \left(1 - \frac{x - y}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y} \cdot \left(1 + \frac{1}{y}\right)\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.9999895614048552) (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (* (/ (+ x -1.0) y) (+ 1.0 (/ 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.9999895614048552) {
tmp = 1.0 - log(1.0 - ((x - y) / (1.0 - y)));
} else {
tmp = 1.0 - log(((x + -1.0) / y) * (1.0 + (1.0 / y)));
}
return tmp;
}












Bits error versus x












Bits error versus y
Results
| Original | 18.1 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 7809 |
| Alternative 2 | |
|---|---|
| Error | 0.8 |
| Cost | 7554 |
| Alternative 3 | |
|---|---|
| Error | 0.8 |
| Cost | 7176 |
| Alternative 4 | |
|---|---|
| Error | 1.2 |
| Cost | 7176 |
| Alternative 5 | |
|---|---|
| Error | 23.7 |
| Cost | 6720 |
| Alternative 6 | |
|---|---|
| Error | 24.0 |
| Cost | 6977 |
| Alternative 7 | |
|---|---|
| Error | 34.5 |
| Cost | 385 |
| Alternative 8 | |
|---|---|
| Error | 36.1 |
| Cost | 64 |

if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.999989561404855176Initial program 0.1
Simplified0.1
if 0.999989561404855176 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 62.1
Taylor expanded around inf 0.0
Simplified0.0
Taylor expanded around 0 0.0
Simplified0.0
Simplified0.0
Final simplification0.1
herbie shell --seed 2021044
(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))))))