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




Bits error versus x




Bits error versus y
Results
| Original | 18.4 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
if y < -546459.023153362679Initial program 52.1
Simplified52.1
Taylor expanded in y around -inf 0.3
Simplified0.3
Applied egg-rr0.3
if -546459.023153362679 < y < 5977358701217.45215Initial program 0.1
Simplified0.0
if 5977358701217.45215 < y Initial program 31.0
Simplified31.0
Taylor expanded in y around inf 0.9
Simplified0.9
Applied egg-rr0.0
Final simplification0.1
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))))))