(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
(FPCore (x y)
:precision binary64
(if (<= y -589143.7095034524)
(+
1.0
(-
(+ (/ (/ x (- 1.0 x)) y) (/ -1.0 (* y (- 1.0 x))))
(+ (log1p (- x)) (log (/ -1.0 y)))))
(if (<= y 4.2096123486017616e+43)
(- 1.0 (log1p (* (- y x) (/ -1.0 (+ y -1.0)))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))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 (y <= -589143.7095034524) {
tmp = 1.0 + ((((x / (1.0 - x)) / y) + (-1.0 / (y * (1.0 - x)))) - (log1p(-x) + log((-1.0 / y))));
} else if (y <= 4.2096123486017616e+43) {
tmp = 1.0 - log1p(((y - x) * (-1.0 / (y + -1.0))));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
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 (y <= -589143.7095034524) {
tmp = 1.0 + ((((x / (1.0 - x)) / y) + (-1.0 / (y * (1.0 - x)))) - (Math.log1p(-x) + Math.log((-1.0 / y))));
} else if (y <= 4.2096123486017616e+43) {
tmp = 1.0 - Math.log1p(((y - x) * (-1.0 / (y + -1.0))));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
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 y <= -589143.7095034524: tmp = 1.0 + ((((x / (1.0 - x)) / y) + (-1.0 / (y * (1.0 - x)))) - (math.log1p(-x) + math.log((-1.0 / y)))) elif y <= 4.2096123486017616e+43: tmp = 1.0 - math.log1p(((y - x) * (-1.0 / (y + -1.0)))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) 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 (y <= -589143.7095034524) tmp = Float64(1.0 + Float64(Float64(Float64(Float64(x / Float64(1.0 - x)) / y) + Float64(-1.0 / Float64(y * Float64(1.0 - x)))) - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y))))); elseif (y <= 4.2096123486017616e+43) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) * Float64(-1.0 / Float64(y + -1.0))))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); 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[y, -589143.7095034524], N[(1.0 + N[(N[(N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + N[(-1.0 / N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.2096123486017616e+43], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] * N[(-1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\begin{array}{l}
\mathbf{if}\;y \leq -589143.7095034524:\\
\;\;\;\;1 + \left(\left(\frac{\frac{x}{1 - x}}{y} + \frac{-1}{y \cdot \left(1 - x\right)}\right) - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\right)\\
\mathbf{elif}\;y \leq 4.2096123486017616 \cdot 10^{+43}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\left(y - x\right) \cdot \frac{-1}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}




Bits error versus x




Bits error versus y
Results
| Original | 18.4 |
|---|---|
| Target | 0.1 |
| Herbie | 0.2 |
if y < -589143.70950345241Initial program 51.5
Simplified51.5
Taylor expanded in y around -inf 0.3
Simplified0.3
if -589143.70950345241 < y < 4.2096123486017616e43Initial program 0.1
Simplified0.1
Applied egg-rr0.1
if 4.2096123486017616e43 < y Initial program 37.1
Simplified37.1
Taylor expanded in y around inf 0.9
Simplified0.9
Final simplification0.2
herbie shell --seed 2022153
(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))))))