
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
double code(double x, double y) {
return 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - log((1.0d0 - ((x - y) / (1.0d0 - y))))
end function
public static double code(double x, double y) {
return 1.0 - Math.log((1.0 - ((x - y) / (1.0 - y))));
}
def code(x, y): return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
function code(x, y) return Float64(1.0 - log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))))) end
function tmp = code(x, y) tmp = 1.0 - log((1.0 - ((x - y) / (1.0 - y)))); 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]
\begin{array}{l}
\\
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
double code(double x, double y) {
return 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - log((1.0d0 - ((x - y) / (1.0d0 - y))))
end function
public static double code(double x, double y) {
return 1.0 - Math.log((1.0 - ((x - y) / (1.0 - y))));
}
def code(x, y): return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
function code(x, y) return Float64(1.0 - log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))))) end
function tmp = code(x, y) tmp = 1.0 - log((1.0 - ((x - y) / (1.0 - y)))); 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]
\begin{array}{l}
\\
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\end{array}
(FPCore (x y)
:precision binary64
(if (<= y -7500000.0)
(+
(/ (+ (/ x (- 1.0 x)) (/ -1.0 (- 1.0 x))) y)
(- (- 1.0 (log1p (- x))) (log (/ -1.0 y))))
(if (<= y 24000000000000.0)
(- 1.0 (log1p (/ (* x (- 1.0 (/ y x))) (+ y -1.0))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = (((x / (1.0 - x)) + (-1.0 / (1.0 - x))) / y) + ((1.0 - log1p(-x)) - log((-1.0 / y)));
} else if (y <= 24000000000000.0) {
tmp = 1.0 - log1p(((x * (1.0 - (y / x))) / (y + -1.0)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = (((x / (1.0 - x)) + (-1.0 / (1.0 - x))) / y) + ((1.0 - Math.log1p(-x)) - Math.log((-1.0 / y)));
} else if (y <= 24000000000000.0) {
tmp = 1.0 - Math.log1p(((x * (1.0 - (y / x))) / (y + -1.0)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7500000.0: tmp = (((x / (1.0 - x)) + (-1.0 / (1.0 - x))) / y) + ((1.0 - math.log1p(-x)) - math.log((-1.0 / y))) elif y <= 24000000000000.0: tmp = 1.0 - math.log1p(((x * (1.0 - (y / x))) / (y + -1.0))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -7500000.0) tmp = Float64(Float64(Float64(Float64(x / Float64(1.0 - x)) + Float64(-1.0 / Float64(1.0 - x))) / y) + Float64(Float64(1.0 - log1p(Float64(-x))) - log(Float64(-1.0 / y)))); elseif (y <= 24000000000000.0) tmp = Float64(1.0 - log1p(Float64(Float64(x * Float64(1.0 - Float64(y / x))) / Float64(y + -1.0)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -7500000.0], N[(N[(N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + N[(N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 24000000000000.0], N[(1.0 - N[Log[1 + N[(N[(x * N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7500000:\\
\;\;\;\;\frac{\frac{x}{1 - x} + \frac{-1}{1 - x}}{y} + \left(\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 24000000000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x \cdot \left(1 - \frac{y}{x}\right)}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if y < -7.5e6Initial program 25.6%
sub-neg25.6%
log1p-define25.7%
distribute-neg-frac225.7%
neg-sub025.7%
associate--r-25.7%
metadata-eval25.7%
+-commutative25.7%
Simplified25.7%
Taylor expanded in y around -inf 99.5%
Simplified99.5%
if -7.5e6 < y < 2.4e13Initial program 99.9%
sub-neg99.9%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if 2.4e13 < y Initial program 40.0%
sub-neg40.0%
log1p-define40.0%
distribute-neg-frac240.0%
neg-sub040.0%
associate--r-40.0%
metadata-eval40.0%
+-commutative40.0%
Simplified40.0%
Taylor expanded in y around inf 98.6%
log-rec98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -7500000.0)
(+ 1.0 (- (- (/ -1.0 y) (log (/ -1.0 y))) (log1p (- x))))
(if (<= y 32000000000000.0)
(- 1.0 (log1p (/ (* x (- 1.0 (/ y x))) (+ y -1.0))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = 1.0 + (((-1.0 / y) - log((-1.0 / y))) - log1p(-x));
} else if (y <= 32000000000000.0) {
tmp = 1.0 - log1p(((x * (1.0 - (y / x))) / (y + -1.0)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = 1.0 + (((-1.0 / y) - Math.log((-1.0 / y))) - Math.log1p(-x));
} else if (y <= 32000000000000.0) {
tmp = 1.0 - Math.log1p(((x * (1.0 - (y / x))) / (y + -1.0)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7500000.0: tmp = 1.0 + (((-1.0 / y) - math.log((-1.0 / y))) - math.log1p(-x)) elif y <= 32000000000000.0: tmp = 1.0 - math.log1p(((x * (1.0 - (y / x))) / (y + -1.0))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -7500000.0) tmp = Float64(1.0 + Float64(Float64(Float64(-1.0 / y) - log(Float64(-1.0 / y))) - log1p(Float64(-x)))); elseif (y <= 32000000000000.0) tmp = Float64(1.0 - log1p(Float64(Float64(x * Float64(1.0 - Float64(y / x))) / Float64(y + -1.0)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -7500000.0], N[(1.0 + N[(N[(N[(-1.0 / y), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 32000000000000.0], N[(1.0 - N[Log[1 + N[(N[(x * N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7500000:\\
\;\;\;\;1 + \left(\left(\frac{-1}{y} - \log \left(\frac{-1}{y}\right)\right) - \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{elif}\;y \leq 32000000000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x \cdot \left(1 - \frac{y}{x}\right)}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if y < -7.5e6Initial program 25.6%
sub-neg25.6%
log1p-define25.7%
distribute-neg-frac225.7%
neg-sub025.7%
associate--r-25.7%
metadata-eval25.7%
+-commutative25.7%
Simplified25.7%
Taylor expanded in y around -inf 99.5%
Simplified99.5%
if -7.5e6 < y < 3.2e13Initial program 99.9%
sub-neg99.9%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if 3.2e13 < y Initial program 40.0%
sub-neg40.0%
log1p-define40.0%
distribute-neg-frac240.0%
neg-sub040.0%
associate--r-40.0%
metadata-eval40.0%
+-commutative40.0%
Simplified40.0%
Taylor expanded in y around inf 98.6%
log-rec98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -2050000000.0)
(- (- 1.0 (log1p (- x))) (log (/ -1.0 y)))
(if (<= y 38000000000000.0)
(- 1.0 (log1p (/ (* x (- 1.0 (/ y x))) (+ y -1.0))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -2050000000.0) {
tmp = (1.0 - log1p(-x)) - log((-1.0 / y));
} else if (y <= 38000000000000.0) {
tmp = 1.0 - log1p(((x * (1.0 - (y / x))) / (y + -1.0)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -2050000000.0) {
tmp = (1.0 - Math.log1p(-x)) - Math.log((-1.0 / y));
} else if (y <= 38000000000000.0) {
tmp = 1.0 - Math.log1p(((x * (1.0 - (y / x))) / (y + -1.0)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2050000000.0: tmp = (1.0 - math.log1p(-x)) - math.log((-1.0 / y)) elif y <= 38000000000000.0: tmp = 1.0 - math.log1p(((x * (1.0 - (y / x))) / (y + -1.0))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -2050000000.0) tmp = Float64(Float64(1.0 - log1p(Float64(-x))) - log(Float64(-1.0 / y))); elseif (y <= 38000000000000.0) tmp = Float64(1.0 - log1p(Float64(Float64(x * Float64(1.0 - Float64(y / x))) / Float64(y + -1.0)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -2050000000.0], N[(N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 38000000000000.0], N[(1.0 - N[Log[1 + N[(N[(x * N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2050000000:\\
\;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 38000000000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x \cdot \left(1 - \frac{y}{x}\right)}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if y < -2.05e9Initial program 25.6%
sub-neg25.6%
log1p-define25.7%
distribute-neg-frac225.7%
neg-sub025.7%
associate--r-25.7%
metadata-eval25.7%
+-commutative25.7%
Simplified25.7%
Taylor expanded in y around -inf 99.4%
associate--r+99.4%
sub-neg99.4%
metadata-eval99.4%
distribute-lft-in99.4%
metadata-eval99.4%
+-commutative99.4%
log1p-define99.4%
mul-1-neg99.4%
Simplified99.4%
if -2.05e9 < y < 3.8e13Initial program 99.9%
sub-neg99.9%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if 3.8e13 < y Initial program 40.0%
sub-neg40.0%
log1p-define40.0%
distribute-neg-frac240.0%
neg-sub040.0%
associate--r-40.0%
metadata-eval40.0%
+-commutative40.0%
Simplified40.0%
Taylor expanded in y around inf 98.6%
log-rec98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.9999995) (- 1.0 (log1p (/ (- x y) (+ y -1.0)))) (+ (+ 1.0 (/ -1.0 y)) (log (- y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.9999995) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = (1.0 + (-1.0 / y)) + log(-y);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.9999995) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = (1.0 + (-1.0 / y)) + Math.log(-y);
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.9999995: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = (1.0 + (-1.0 / y)) + math.log(-y) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.9999995) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(Float64(1.0 + Float64(-1.0 / y)) + log(Float64(-y))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.9999995], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] + N[Log[(-y)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.9999995:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{-1}{y}\right) + \log \left(-y\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < 0.999999500000000041Initial program 99.8%
sub-neg99.8%
log1p-define99.9%
distribute-neg-frac299.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
if 0.999999500000000041 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) Initial program 4.6%
sub-neg4.6%
log1p-define4.6%
distribute-neg-frac24.6%
neg-sub04.6%
associate--r-4.6%
metadata-eval4.6%
+-commutative4.6%
Simplified4.6%
Taylor expanded in x around 0 4.2%
mul-1-neg4.2%
sub-neg4.2%
metadata-eval4.2%
distribute-neg-frac4.2%
Simplified4.2%
Taylor expanded in y around -inf 70.9%
associate--r+71.0%
sub-neg71.0%
distribute-neg-frac71.0%
metadata-eval71.0%
Simplified71.0%
*-un-lft-identity71.0%
+-commutative71.0%
sub-neg71.0%
associate-+r+71.0%
neg-log71.0%
clear-num71.0%
div-inv71.0%
metadata-eval71.0%
Applied egg-rr71.0%
*-lft-identity71.0%
+-commutative71.0%
*-commutative71.0%
neg-mul-171.0%
Simplified71.0%
(FPCore (x y) :precision binary64 (if (<= y -21.0) (+ 1.0 (log (- y))) (if (<= y 1.0) (- 1.0 (+ y (log1p (- x)))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -21.0) {
tmp = 1.0 + log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - (y + log1p(-x));
} else {
tmp = 1.0 - log1p((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -21.0) {
tmp = 1.0 + Math.log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - (y + Math.log1p(-x));
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -21.0: tmp = 1.0 + math.log(-y) elif y <= 1.0: tmp = 1.0 - (y + math.log1p(-x)) else: tmp = 1.0 - math.log1p((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -21.0) tmp = Float64(1.0 + log(Float64(-y))); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); else tmp = Float64(1.0 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -21.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -21:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -21Initial program 28.4%
sub-neg28.4%
log1p-define28.4%
distribute-neg-frac228.4%
neg-sub028.4%
associate--r-28.4%
metadata-eval28.4%
+-commutative28.4%
Simplified28.4%
Taylor expanded in y around -inf 97.7%
associate--r+97.7%
sub-neg97.7%
metadata-eval97.7%
distribute-lft-in97.7%
metadata-eval97.7%
+-commutative97.7%
log1p-define97.7%
mul-1-neg97.7%
Simplified97.7%
Taylor expanded in x around 0 66.5%
sub-neg66.5%
neg-log66.5%
clear-num66.5%
div-inv66.5%
metadata-eval66.5%
Applied egg-rr66.5%
*-commutative66.5%
mul-1-neg66.5%
Simplified66.5%
if -21 < y < 1Initial program 99.9%
sub-neg99.9%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 99.7%
+-commutative99.7%
div-sub99.7%
mul-1-neg99.7%
sub-neg99.7%
*-inverses99.7%
*-rgt-identity99.7%
log1p-define99.7%
mul-1-neg99.7%
Simplified99.7%
if 1 < y Initial program 42.5%
sub-neg42.5%
log1p-define42.5%
distribute-neg-frac242.5%
neg-sub042.5%
associate--r-42.5%
metadata-eval42.5%
+-commutative42.5%
Simplified42.5%
Taylor expanded in x around inf 45.2%
Taylor expanded in y around inf 42.6%
(FPCore (x y) :precision binary64 (if (<= y -7500000.0) (+ 1.0 (log (- y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = 1.0 + log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log1p((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = 1.0 + Math.log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7500000.0: tmp = 1.0 + math.log(-y) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log1p((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -7500000.0) tmp = Float64(1.0 + log(Float64(-y))); elseif (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = Float64(1.0 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -7500000.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7500000:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -7.5e6Initial program 25.6%
sub-neg25.6%
log1p-define25.7%
distribute-neg-frac225.7%
neg-sub025.7%
associate--r-25.7%
metadata-eval25.7%
+-commutative25.7%
Simplified25.7%
Taylor expanded in y around -inf 99.4%
associate--r+99.4%
sub-neg99.4%
metadata-eval99.4%
distribute-lft-in99.4%
metadata-eval99.4%
+-commutative99.4%
log1p-define99.4%
mul-1-neg99.4%
Simplified99.4%
Taylor expanded in x around 0 68.6%
sub-neg68.6%
neg-log68.6%
clear-num68.6%
div-inv68.6%
metadata-eval68.6%
Applied egg-rr68.6%
*-commutative68.6%
mul-1-neg68.6%
Simplified68.6%
if -7.5e6 < y < 1Initial program 99.9%
sub-neg99.9%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 96.9%
log1p-define96.9%
mul-1-neg96.9%
Simplified96.9%
if 1 < y Initial program 42.5%
sub-neg42.5%
log1p-define42.5%
distribute-neg-frac242.5%
neg-sub042.5%
associate--r-42.5%
metadata-eval42.5%
+-commutative42.5%
Simplified42.5%
Taylor expanded in x around inf 45.2%
Taylor expanded in y around inf 42.6%
(FPCore (x y) :precision binary64 (if (<= y -12500000.0) (+ (+ 1.0 (/ -1.0 y)) (log (- y))) (- 1.0 (log1p (/ x (+ y -1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -12500000.0) {
tmp = (1.0 + (-1.0 / y)) + log(-y);
} else {
tmp = 1.0 - log1p((x / (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -12500000.0) {
tmp = (1.0 + (-1.0 / y)) + Math.log(-y);
} else {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -12500000.0: tmp = (1.0 + (-1.0 / y)) + math.log(-y) else: tmp = 1.0 - math.log1p((x / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -12500000.0) tmp = Float64(Float64(1.0 + Float64(-1.0 / y)) + log(Float64(-y))); else tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -12500000.0], N[(N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12500000:\\
\;\;\;\;\left(1 + \frac{-1}{y}\right) + \log \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\end{array}
\end{array}
if y < -1.25e7Initial program 25.6%
sub-neg25.6%
log1p-define25.7%
distribute-neg-frac225.7%
neg-sub025.7%
associate--r-25.7%
metadata-eval25.7%
+-commutative25.7%
Simplified25.7%
Taylor expanded in x around 0 3.6%
mul-1-neg3.6%
sub-neg3.6%
metadata-eval3.6%
distribute-neg-frac3.6%
Simplified3.6%
Taylor expanded in y around -inf 68.7%
associate--r+68.7%
sub-neg68.7%
distribute-neg-frac68.7%
metadata-eval68.7%
Simplified68.7%
*-un-lft-identity68.7%
+-commutative68.7%
sub-neg68.7%
associate-+r+68.7%
neg-log68.7%
clear-num68.7%
div-inv68.7%
metadata-eval68.7%
Applied egg-rr68.7%
*-lft-identity68.7%
+-commutative68.7%
*-commutative68.7%
neg-mul-168.7%
Simplified68.7%
if -1.25e7 < y Initial program 92.2%
sub-neg92.2%
log1p-define92.2%
distribute-neg-frac292.2%
neg-sub092.2%
associate--r-92.2%
metadata-eval92.2%
+-commutative92.2%
Simplified92.2%
Taylor expanded in x around inf 91.2%
Final simplification84.4%
(FPCore (x y) :precision binary64 (if (<= y -100000000000.0) (+ 1.0 (log (- y))) (- 1.0 (log1p (/ x (+ y -1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -100000000000.0) {
tmp = 1.0 + log(-y);
} else {
tmp = 1.0 - log1p((x / (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -100000000000.0) {
tmp = 1.0 + Math.log(-y);
} else {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -100000000000.0: tmp = 1.0 + math.log(-y) else: tmp = 1.0 - math.log1p((x / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -100000000000.0) tmp = Float64(1.0 + log(Float64(-y))); else tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -100000000000.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -100000000000:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\end{array}
\end{array}
if y < -1e11Initial program 25.6%
sub-neg25.6%
log1p-define25.7%
distribute-neg-frac225.7%
neg-sub025.7%
associate--r-25.7%
metadata-eval25.7%
+-commutative25.7%
Simplified25.7%
Taylor expanded in y around -inf 99.4%
associate--r+99.4%
sub-neg99.4%
metadata-eval99.4%
distribute-lft-in99.4%
metadata-eval99.4%
+-commutative99.4%
log1p-define99.4%
mul-1-neg99.4%
Simplified99.4%
Taylor expanded in x around 0 68.6%
sub-neg68.6%
neg-log68.6%
clear-num68.6%
div-inv68.6%
metadata-eval68.6%
Applied egg-rr68.6%
*-commutative68.6%
mul-1-neg68.6%
Simplified68.6%
if -1e11 < y Initial program 92.2%
sub-neg92.2%
log1p-define92.2%
distribute-neg-frac292.2%
neg-sub092.2%
associate--r-92.2%
metadata-eval92.2%
+-commutative92.2%
Simplified92.2%
Taylor expanded in x around inf 91.2%
Final simplification84.3%
(FPCore (x y) :precision binary64 (if (<= y -7500000.0) (+ 1.0 (log (- y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = 1.0 + log(-y);
} else {
tmp = 1.0 - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -7500000.0) {
tmp = 1.0 + Math.log(-y);
} else {
tmp = 1.0 - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7500000.0: tmp = 1.0 + math.log(-y) else: tmp = 1.0 - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if (y <= -7500000.0) tmp = Float64(1.0 + log(Float64(-y))); else tmp = Float64(1.0 - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -7500000.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7500000:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -7.5e6Initial program 25.6%
sub-neg25.6%
log1p-define25.7%
distribute-neg-frac225.7%
neg-sub025.7%
associate--r-25.7%
metadata-eval25.7%
+-commutative25.7%
Simplified25.7%
Taylor expanded in y around -inf 99.4%
associate--r+99.4%
sub-neg99.4%
metadata-eval99.4%
distribute-lft-in99.4%
metadata-eval99.4%
+-commutative99.4%
log1p-define99.4%
mul-1-neg99.4%
Simplified99.4%
Taylor expanded in x around 0 68.6%
sub-neg68.6%
neg-log68.6%
clear-num68.6%
div-inv68.6%
metadata-eval68.6%
Applied egg-rr68.6%
*-commutative68.6%
mul-1-neg68.6%
Simplified68.6%
if -7.5e6 < y Initial program 92.2%
sub-neg92.2%
log1p-define92.2%
distribute-neg-frac292.2%
neg-sub092.2%
associate--r-92.2%
metadata-eval92.2%
+-commutative92.2%
Simplified92.2%
Taylor expanded in y around 0 83.8%
log1p-define83.9%
mul-1-neg83.9%
Simplified83.9%
(FPCore (x y) :precision binary64 (if (<= y -1.42) (+ 1.0 (log (- y))) (- 1.0 (/ x (+ y -1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.42) {
tmp = 1.0 + log(-y);
} else {
tmp = 1.0 - (x / (y + -1.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.42d0)) then
tmp = 1.0d0 + log(-y)
else
tmp = 1.0d0 - (x / (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.42) {
tmp = 1.0 + Math.log(-y);
} else {
tmp = 1.0 - (x / (y + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.42: tmp = 1.0 + math.log(-y) else: tmp = 1.0 - (x / (y + -1.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.42) tmp = Float64(1.0 + log(Float64(-y))); else tmp = Float64(1.0 - Float64(x / Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.42) tmp = 1.0 + log(-y); else tmp = 1.0 - (x / (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.42], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.42:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y + -1}\\
\end{array}
\end{array}
if y < -1.4199999999999999Initial program 28.4%
sub-neg28.4%
log1p-define28.4%
distribute-neg-frac228.4%
neg-sub028.4%
associate--r-28.4%
metadata-eval28.4%
+-commutative28.4%
Simplified28.4%
Taylor expanded in y around -inf 97.7%
associate--r+97.7%
sub-neg97.7%
metadata-eval97.7%
distribute-lft-in97.7%
metadata-eval97.7%
+-commutative97.7%
log1p-define97.7%
mul-1-neg97.7%
Simplified97.7%
Taylor expanded in x around 0 66.5%
sub-neg66.5%
neg-log66.5%
clear-num66.5%
div-inv66.5%
metadata-eval66.5%
Applied egg-rr66.5%
*-commutative66.5%
mul-1-neg66.5%
Simplified66.5%
if -1.4199999999999999 < y Initial program 92.1%
sub-neg92.1%
log1p-define92.1%
distribute-neg-frac292.1%
neg-sub092.1%
associate--r-92.1%
metadata-eval92.1%
+-commutative92.1%
Simplified92.1%
Taylor expanded in x around inf 91.5%
Taylor expanded in x around 0 57.0%
Final simplification60.0%
(FPCore (x y) :precision binary64 (- 1.0 (/ x (+ y -1.0))))
double code(double x, double y) {
return 1.0 - (x / (y + -1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (x / (y + (-1.0d0)))
end function
public static double code(double x, double y) {
return 1.0 - (x / (y + -1.0));
}
def code(x, y): return 1.0 - (x / (y + -1.0))
function code(x, y) return Float64(1.0 - Float64(x / Float64(y + -1.0))) end
function tmp = code(x, y) tmp = 1.0 - (x / (y + -1.0)); end
code[x_, y_] := N[(1.0 - N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{y + -1}
\end{array}
Initial program 71.9%
sub-neg71.9%
log1p-define72.0%
distribute-neg-frac272.0%
neg-sub072.0%
associate--r-72.0%
metadata-eval72.0%
+-commutative72.0%
Simplified72.0%
Taylor expanded in x around inf 72.9%
Taylor expanded in x around 0 42.9%
Final simplification42.9%
(FPCore (x y) :precision binary64 (+ x 1.0))
double code(double x, double y) {
return x + 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + 1.0d0
end function
public static double code(double x, double y) {
return x + 1.0;
}
def code(x, y): return x + 1.0
function code(x, y) return Float64(x + 1.0) end
function tmp = code(x, y) tmp = x + 1.0; end
code[x_, y_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 71.9%
sub-neg71.9%
log1p-define72.0%
distribute-neg-frac272.0%
neg-sub072.0%
associate--r-72.0%
metadata-eval72.0%
+-commutative72.0%
Simplified72.0%
Taylor expanded in y around 0 62.4%
log1p-define62.4%
mul-1-neg62.4%
Simplified62.4%
Taylor expanded in x around 0 41.6%
Final simplification41.6%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 71.9%
sub-neg71.9%
log1p-define72.0%
distribute-neg-frac272.0%
neg-sub072.0%
associate--r-72.0%
metadata-eval72.0%
+-commutative72.0%
Simplified72.0%
Taylor expanded in x around inf 72.9%
Taylor expanded in x around 0 41.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))
(if (< y -81284752.61947241)
t_0
(if (< y 3.0094271212461764e+25)
(log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y)))))
t_0))))
double code(double x, double y) {
double t_0 = 1.0 - log(((x / (y * y)) - ((1.0 / y) - (x / y))));
double tmp;
if (y < -81284752.61947241) {
tmp = t_0;
} else if (y < 3.0094271212461764e+25) {
tmp = log((exp(1.0) / (1.0 - ((x - y) / (1.0 - y)))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - log(((x / (y * y)) - ((1.0d0 / y) - (x / y))))
if (y < (-81284752.61947241d0)) then
tmp = t_0
else if (y < 3.0094271212461764d+25) then
tmp = log((exp(1.0d0) / (1.0d0 - ((x - y) / (1.0d0 - y)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - Math.log(((x / (y * y)) - ((1.0 / y) - (x / y))));
double tmp;
if (y < -81284752.61947241) {
tmp = t_0;
} else if (y < 3.0094271212461764e+25) {
tmp = Math.log((Math.exp(1.0) / (1.0 - ((x - y) / (1.0 - y)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - math.log(((x / (y * y)) - ((1.0 / y) - (x / y)))) tmp = 0 if y < -81284752.61947241: tmp = t_0 elif y < 3.0094271212461764e+25: tmp = math.log((math.exp(1.0) / (1.0 - ((x - y) / (1.0 - y))))) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - log(Float64(Float64(x / Float64(y * y)) - Float64(Float64(1.0 / y) - Float64(x / y))))) tmp = 0.0 if (y < -81284752.61947241) tmp = t_0; elseif (y < 3.0094271212461764e+25) tmp = log(Float64(exp(1.0) / Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - log(((x / (y * y)) - ((1.0 / y) - (x / y)))); tmp = 0.0; if (y < -81284752.61947241) tmp = t_0; elseif (y < 3.0094271212461764e+25) tmp = log((exp(1.0) / (1.0 - ((x - y) / (1.0 - y))))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[Log[N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(N[(1.0 / y), $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Less[y, -81284752.61947241], t$95$0, If[Less[y, 3.0094271212461764e+25], N[Log[N[(N[Exp[1.0], $MachinePrecision] / N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \log \left(\frac{x}{y \cdot y} - \left(\frac{1}{y} - \frac{x}{y}\right)\right)\\
\mathbf{if}\;y < -81284752.61947241:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 3.0094271212461764 \cdot 10^{+25}:\\
\;\;\;\;\log \left(\frac{e^{1}}{1 - \frac{x - y}{1 - y}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024165
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:alt
(! :herbie-platform default (if (< y -8128475261947241/100000000) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))) (if (< y 30094271212461764000000000) (log (/ (exp 1) (- 1 (/ (- x y) (- 1 y))))) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))))))
(- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))