(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.0008571594805803388) (- 1.0 (log1p (/ (- x y) (+ y -1.0)))) (- 1.0 (+ (log (/ (+ x -1.0) y)) (- (/ 1.0 y) (/ x (* y (- 1.0 x))))))))
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.0008571594805803388) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (log(((x + -1.0) / y)) + ((1.0 / y) - (x / (y * (1.0 - x)))));
}
return tmp;
}
public static double code(double x, double y) {
return 1.0 - Math.log((1.0 - ((x - y) / (1.0 - y))));
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.0008571594805803388) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (Math.log(((x + -1.0) / y)) + ((1.0 / y) - (x / (y * (1.0 - x)))));
}
return tmp;
}
def code(x, y): return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.0008571594805803388: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 - (math.log(((x + -1.0) / y)) + ((1.0 / y) - (x / (y * (1.0 - x))))) return tmp
function code(x, y) return Float64(1.0 - log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))))) end
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.0008571594805803388) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 - Float64(log(Float64(Float64(x + -1.0) / y)) + Float64(Float64(1.0 / y) - Float64(x / Float64(y * Float64(1.0 - x)))))); end return tmp end
code[x_, y_] := N[(1.0 - N[Log[N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.0008571594805803388], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision] + N[(N[(1.0 / y), $MachinePrecision] - N[(x / N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.0008571594805803388:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(\frac{x + -1}{y}\right) + \left(\frac{1}{y} - \frac{x}{y \cdot \left(1 - x\right)}\right)\right)\\
\end{array}




Bits error versus x




Bits error versus y
Results
| Original | 18.1 |
|---|---|
| Target | 0.1 |
| Herbie | 0.3 |
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 8.57159480580338786e-4Initial program 0.0
Simplified0.0
if 8.57159480580338786e-4 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 60.2
Simplified60.2
Taylor expanded in y around -inf 11.0
Simplified11.0
Applied log1p-udef_binary6411.0
Applied sum-log_binary641.1
Simplified1.1
Taylor expanded in x around 0 1.2
Final simplification0.3
herbie shell --seed 2022130
(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))))))