
(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 12 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 -9.5e+19)
(- 1.0 (+ (log1p (- x)) (log (/ -1.0 y))))
(if (<= y 30000000000000.0)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - (log1p(-x) + log((-1.0 / y)));
} else if (y <= 30000000000000.0) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - (Math.log1p(-x) + Math.log((-1.0 / y)));
} else if (y <= 30000000000000.0) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.5e+19: tmp = 1.0 - (math.log1p(-x) + math.log((-1.0 / y))) elif y <= 30000000000000.0: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.5e+19) tmp = Float64(1.0 - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (y <= 30000000000000.0) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -9.5e+19], N[(1.0 - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 30000000000000.0], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $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 -9.5 \cdot 10^{+19}:\\
\;\;\;\;1 - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 30000000000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if y < -9.5e19Initial program 11.7%
sub-neg11.7%
log1p-def11.7%
neg-sub011.7%
div-sub11.7%
associate--r-11.7%
neg-sub011.7%
+-commutative11.7%
sub-neg11.7%
div-sub11.7%
Simplified11.7%
Taylor expanded in y around -inf 99.5%
sub-neg99.5%
metadata-eval99.5%
distribute-lft-in99.5%
metadata-eval99.5%
+-commutative99.5%
log1p-def99.5%
mul-1-neg99.5%
Simplified99.5%
if -9.5e19 < y < 3e13Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
neg-sub0100.0%
div-sub100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
if 3e13 < y Initial program 62.9%
sub-neg62.9%
log1p-def62.9%
neg-sub062.9%
div-sub62.9%
associate--r-62.9%
neg-sub062.9%
+-commutative62.9%
sub-neg62.9%
div-sub62.9%
Simplified62.9%
Taylor expanded in y around inf 98.0%
+-commutative98.0%
log-rec98.0%
unsub-neg98.0%
sub-neg98.0%
metadata-eval98.0%
+-commutative98.0%
Simplified98.0%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 1.0) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (- 1.0 (log (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 1.0) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - log((-1.0 / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 1.0) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - Math.log((-1.0 / y));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 1.0: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - math.log((-1.0 / y)) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 1.0) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - log(Float64(-1.0 / y))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 1.0], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 1Initial program 73.3%
sub-neg73.3%
log1p-def73.4%
neg-sub073.4%
div-sub73.4%
associate--r-73.4%
neg-sub073.4%
+-commutative73.4%
sub-neg73.4%
div-sub73.4%
Simplified73.4%
if 1 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 73.3%
sub-neg73.3%
log1p-def73.4%
neg-sub073.4%
div-sub73.4%
associate--r-73.4%
neg-sub073.4%
+-commutative73.4%
sub-neg73.4%
div-sub73.4%
Simplified73.4%
Taylor expanded in x around 0 45.0%
log1p-def45.0%
Simplified45.0%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div21.7%
Simplified21.7%
Final simplification73.4%
(FPCore (x y)
:precision binary64
(if (<= y -9.5e+19)
(- 1.0 (log (/ -1.0 y)))
(if (or (<= y -1.38e-5) (not (<= y 1e-5)))
(- 1.0 (log (/ x (+ y -1.0))))
(- 1.0 (+ y (log1p (- x)))))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - log((-1.0 / y));
} else if ((y <= -1.38e-5) || !(y <= 1e-5)) {
tmp = 1.0 - log((x / (y + -1.0)));
} else {
tmp = 1.0 - (y + log1p(-x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if ((y <= -1.38e-5) || !(y <= 1e-5)) {
tmp = 1.0 - Math.log((x / (y + -1.0)));
} else {
tmp = 1.0 - (y + Math.log1p(-x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.5e+19: tmp = 1.0 - math.log((-1.0 / y)) elif (y <= -1.38e-5) or not (y <= 1e-5): tmp = 1.0 - math.log((x / (y + -1.0))) else: tmp = 1.0 - (y + math.log1p(-x)) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.5e+19) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif ((y <= -1.38e-5) || !(y <= 1e-5)) tmp = Float64(1.0 - log(Float64(x / Float64(y + -1.0)))); else tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -9.5e+19], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -1.38e-5], N[Not[LessEqual[y, 1e-5]], $MachinePrecision]], N[(1.0 - N[Log[N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+19}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq -1.38 \cdot 10^{-5} \lor \neg \left(y \leq 10^{-5}\right):\\
\;\;\;\;1 - \log \left(\frac{x}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\end{array}
\end{array}
if y < -9.5e19Initial program 11.7%
sub-neg11.7%
log1p-def11.7%
neg-sub011.7%
div-sub11.7%
associate--r-11.7%
neg-sub011.7%
+-commutative11.7%
sub-neg11.7%
div-sub11.7%
Simplified11.7%
Taylor expanded in x around 0 2.9%
log1p-def2.9%
Simplified2.9%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div74.2%
Simplified74.2%
if -9.5e19 < y < -1.38e-5 or 1.00000000000000008e-5 < y Initial program 71.8%
sub-neg71.8%
log1p-def71.8%
neg-sub071.8%
div-sub71.8%
associate--r-71.8%
neg-sub071.8%
+-commutative71.8%
sub-neg71.8%
div-sub71.8%
Simplified71.8%
Taylor expanded in x around inf 69.7%
neg-mul-169.7%
distribute-neg-frac69.7%
Simplified69.7%
frac-2neg69.7%
div-inv69.7%
remove-double-neg69.7%
Applied egg-rr69.7%
associate-*r/69.7%
*-rgt-identity69.7%
neg-sub069.7%
associate--r-69.7%
metadata-eval69.7%
Simplified69.7%
Taylor expanded in x around inf 78.0%
log-rec78.0%
unsub-neg78.0%
mul-1-neg78.0%
log-rec78.0%
remove-double-neg78.0%
sub-neg78.0%
metadata-eval78.0%
+-commutative78.0%
log-div96.9%
rem-exp-log78.3%
rem-exp-log78.0%
+-commutative78.0%
metadata-eval78.0%
sub-neg78.0%
rem-exp-log78.7%
sub-neg78.7%
metadata-eval78.7%
+-commutative78.7%
rem-exp-log96.9%
+-commutative96.9%
Simplified96.9%
if -1.38e-5 < y < 1.00000000000000008e-5Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
neg-sub0100.0%
div-sub100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
flip--100.0%
associate-/r/100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 99.8%
log1p-def99.8%
mul-1-neg99.8%
Simplified99.8%
Final simplification92.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (+ y -1.0))))
(if (<= y -1.02e+20)
(- 1.0 (log (/ -1.0 y)))
(if (<= y 1.0) (- 1.0 (log1p t_0)) (- 1.0 (log t_0))))))
double code(double x, double y) {
double t_0 = x / (y + -1.0);
double tmp;
if (y <= -1.02e+20) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - log1p(t_0);
} else {
tmp = 1.0 - log(t_0);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = x / (y + -1.0);
double tmp;
if (y <= -1.02e+20) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(t_0);
} else {
tmp = 1.0 - Math.log(t_0);
}
return tmp;
}
def code(x, y): t_0 = x / (y + -1.0) tmp = 0 if y <= -1.02e+20: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - math.log1p(t_0) else: tmp = 1.0 - math.log(t_0) return tmp
function code(x, y) t_0 = Float64(x / Float64(y + -1.0)) tmp = 0.0 if (y <= -1.02e+20) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(1.0 - log1p(t_0)); else tmp = Float64(1.0 - log(t_0)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.02e+20], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + t$95$0], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y + -1}\\
\mathbf{if}\;y \leq -1.02 \cdot 10^{+20}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log t_0\\
\end{array}
\end{array}
if y < -1.02e20Initial program 11.7%
sub-neg11.7%
log1p-def11.7%
neg-sub011.7%
div-sub11.7%
associate--r-11.7%
neg-sub011.7%
+-commutative11.7%
sub-neg11.7%
div-sub11.7%
Simplified11.7%
Taylor expanded in x around 0 2.9%
log1p-def2.9%
Simplified2.9%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div74.2%
Simplified74.2%
if -1.02e20 < y < 1Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
neg-sub0100.0%
div-sub100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in x around inf 99.4%
neg-mul-199.4%
distribute-neg-frac99.4%
Simplified99.4%
frac-2neg99.4%
div-inv99.4%
remove-double-neg99.4%
Applied egg-rr99.4%
associate-*r/99.4%
*-rgt-identity99.4%
neg-sub099.4%
associate--r-99.4%
metadata-eval99.4%
Simplified99.4%
if 1 < y Initial program 66.0%
sub-neg66.0%
log1p-def66.0%
neg-sub066.0%
div-sub66.0%
associate--r-66.0%
neg-sub066.0%
+-commutative66.0%
sub-neg66.0%
div-sub66.0%
Simplified66.0%
Taylor expanded in x around inf 63.4%
neg-mul-163.4%
distribute-neg-frac63.4%
Simplified63.4%
frac-2neg63.4%
div-inv63.4%
remove-double-neg63.4%
Applied egg-rr63.4%
associate-*r/63.4%
*-rgt-identity63.4%
neg-sub063.4%
associate--r-63.4%
metadata-eval63.4%
Simplified63.4%
Taylor expanded in x around inf 94.3%
log-rec94.3%
unsub-neg94.3%
mul-1-neg94.3%
log-rec94.3%
remove-double-neg94.3%
sub-neg94.3%
metadata-eval94.3%
+-commutative94.3%
log-div96.2%
rem-exp-log94.6%
rem-exp-log94.3%
+-commutative94.3%
metadata-eval94.3%
sub-neg94.3%
rem-exp-log95.1%
sub-neg95.1%
metadata-eval95.1%
+-commutative95.1%
rem-exp-log96.2%
+-commutative96.2%
Simplified96.2%
Final simplification92.4%
(FPCore (x y) :precision binary64 (if (<= y -8.2) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- 1.0 (+ y (log1p (- x)))) (- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -8.2) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - (y + log1p(-x));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -8.2) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - (y + Math.log1p(-x));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8.2: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - (y + math.log1p(-x)) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -8.2) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -8.2], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -8.1999999999999993Initial program 16.6%
sub-neg16.6%
log1p-def16.6%
neg-sub016.6%
div-sub16.6%
associate--r-16.6%
neg-sub016.6%
+-commutative16.6%
sub-neg16.6%
div-sub16.6%
Simplified16.6%
Taylor expanded in x around 0 2.8%
log1p-def2.8%
Simplified2.8%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div70.2%
Simplified70.2%
if -8.1999999999999993 < y < 1Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
neg-sub0100.0%
div-sub100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
flip--100.0%
associate-/r/100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 99.7%
log1p-def99.7%
mul-1-neg99.7%
Simplified99.7%
if 1 < y Initial program 66.0%
sub-neg66.0%
log1p-def66.0%
neg-sub066.0%
div-sub66.0%
associate--r-66.0%
neg-sub066.0%
+-commutative66.0%
sub-neg66.0%
div-sub66.0%
Simplified66.0%
Taylor expanded in x around inf 63.4%
neg-mul-163.4%
distribute-neg-frac63.4%
Simplified63.4%
frac-2neg63.4%
div-inv63.4%
remove-double-neg63.4%
Applied egg-rr63.4%
associate-*r/63.4%
*-rgt-identity63.4%
neg-sub063.4%
associate--r-63.4%
metadata-eval63.4%
Simplified63.4%
Taylor expanded in x around inf 94.3%
log-rec94.3%
unsub-neg94.3%
mul-1-neg94.3%
log-rec94.3%
remove-double-neg94.3%
sub-neg94.3%
metadata-eval94.3%
+-commutative94.3%
log-div96.2%
rem-exp-log94.6%
rem-exp-log94.3%
+-commutative94.3%
metadata-eval94.3%
sub-neg94.3%
rem-exp-log95.1%
sub-neg95.1%
metadata-eval95.1%
+-commutative95.1%
rem-exp-log96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in y around inf 94.8%
Final simplification90.9%
(FPCore (x y) :precision binary64 (if (<= y -9.5e+19) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.5e+19: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.5e+19) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -9.5e+19], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+19}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -9.5e19Initial program 11.7%
sub-neg11.7%
log1p-def11.7%
neg-sub011.7%
div-sub11.7%
associate--r-11.7%
neg-sub011.7%
+-commutative11.7%
sub-neg11.7%
div-sub11.7%
Simplified11.7%
Taylor expanded in x around 0 2.9%
log1p-def2.9%
Simplified2.9%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div74.2%
Simplified74.2%
if -9.5e19 < y < 1Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
neg-sub0100.0%
div-sub100.0%
associate--r-100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
Taylor expanded in y around 0 97.0%
log1p-def97.0%
mul-1-neg97.0%
Simplified97.0%
if 1 < y Initial program 66.0%
sub-neg66.0%
log1p-def66.0%
neg-sub066.0%
div-sub66.0%
associate--r-66.0%
neg-sub066.0%
+-commutative66.0%
sub-neg66.0%
div-sub66.0%
Simplified66.0%
Taylor expanded in x around inf 63.4%
neg-mul-163.4%
distribute-neg-frac63.4%
Simplified63.4%
frac-2neg63.4%
div-inv63.4%
remove-double-neg63.4%
Applied egg-rr63.4%
associate-*r/63.4%
*-rgt-identity63.4%
neg-sub063.4%
associate--r-63.4%
metadata-eval63.4%
Simplified63.4%
Taylor expanded in x around inf 94.3%
log-rec94.3%
unsub-neg94.3%
mul-1-neg94.3%
log-rec94.3%
remove-double-neg94.3%
sub-neg94.3%
metadata-eval94.3%
+-commutative94.3%
log-div96.2%
rem-exp-log94.6%
rem-exp-log94.3%
+-commutative94.3%
metadata-eval94.3%
sub-neg94.3%
rem-exp-log95.1%
sub-neg95.1%
metadata-eval95.1%
+-commutative95.1%
rem-exp-log96.2%
+-commutative96.2%
Simplified96.2%
Taylor expanded in y around inf 94.8%
Final simplification90.8%
(FPCore (x y) :precision binary64 (if (<= y -9.5e+19) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -9.5e+19) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.5e+19: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if (y <= -9.5e+19) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -9.5e+19], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+19}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -9.5e19Initial program 11.7%
sub-neg11.7%
log1p-def11.7%
neg-sub011.7%
div-sub11.7%
associate--r-11.7%
neg-sub011.7%
+-commutative11.7%
sub-neg11.7%
div-sub11.7%
Simplified11.7%
Taylor expanded in x around 0 2.9%
log1p-def2.9%
Simplified2.9%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div74.2%
Simplified74.2%
if -9.5e19 < y Initial program 95.6%
sub-neg95.6%
log1p-def95.7%
neg-sub095.7%
div-sub95.7%
associate--r-95.7%
neg-sub095.7%
+-commutative95.7%
sub-neg95.7%
div-sub95.7%
Simplified95.7%
Taylor expanded in y around 0 84.6%
log1p-def84.6%
mul-1-neg84.6%
Simplified84.6%
Final simplification81.9%
(FPCore (x y) :precision binary64 (if (<= x -0.88) (- 1.0 (log (- x))) (- 1.0 (/ x (+ y -1.0)))))
double code(double x, double y) {
double tmp;
if (x <= -0.88) {
tmp = 1.0 - log(-x);
} 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 (x <= (-0.88d0)) then
tmp = 1.0d0 - log(-x)
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 (x <= -0.88) {
tmp = 1.0 - Math.log(-x);
} else {
tmp = 1.0 - (x / (y + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.88: tmp = 1.0 - math.log(-x) else: tmp = 1.0 - (x / (y + -1.0)) return tmp
function code(x, y) tmp = 0.0 if (x <= -0.88) tmp = Float64(1.0 - log(Float64(-x))); 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 (x <= -0.88) tmp = 1.0 - log(-x); else tmp = 1.0 - (x / (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.88], N[(1.0 - N[Log[(-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.88:\\
\;\;\;\;1 - \log \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y + -1}\\
\end{array}
\end{array}
if x < -0.880000000000000004Initial program 80.3%
sub-neg80.3%
log1p-def80.3%
neg-sub080.3%
div-sub80.3%
associate--r-80.3%
neg-sub080.3%
+-commutative80.3%
sub-neg80.3%
div-sub80.3%
Simplified80.3%
Taylor expanded in x around inf 82.6%
neg-mul-182.6%
distribute-neg-frac82.6%
Simplified82.6%
frac-2neg82.6%
div-inv82.6%
remove-double-neg82.6%
Applied egg-rr82.6%
associate-*r/82.6%
*-rgt-identity82.6%
neg-sub082.6%
associate--r-82.6%
metadata-eval82.6%
Simplified82.6%
Taylor expanded in x around inf 0.0%
log-rec0.0%
unsub-neg0.0%
mul-1-neg0.0%
log-rec0.0%
remove-double-neg0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
log-div99.0%
rem-exp-log0.0%
rem-exp-log0.0%
+-commutative0.0%
metadata-eval0.0%
sub-neg0.0%
rem-exp-log0.0%
sub-neg0.0%
metadata-eval0.0%
+-commutative0.0%
rem-exp-log99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in y around 0 66.3%
neg-mul-166.3%
Simplified66.3%
if -0.880000000000000004 < x Initial program 70.7%
sub-neg70.7%
log1p-def70.8%
neg-sub070.8%
div-sub70.8%
associate--r-70.8%
neg-sub070.8%
+-commutative70.8%
sub-neg70.8%
div-sub70.8%
Simplified70.8%
Taylor expanded in x around inf 72.7%
neg-mul-172.7%
distribute-neg-frac72.7%
Simplified72.7%
frac-2neg72.7%
div-inv72.7%
remove-double-neg72.7%
Applied egg-rr72.7%
associate-*r/72.7%
*-rgt-identity72.7%
neg-sub072.7%
associate--r-72.7%
metadata-eval72.7%
Simplified72.7%
Taylor expanded in x around 0 65.1%
Final simplification65.4%
(FPCore (x y) :precision binary64 (- 1.0 (log1p (- x))))
double code(double x, double y) {
return 1.0 - log1p(-x);
}
public static double code(double x, double y) {
return 1.0 - Math.log1p(-x);
}
def code(x, y): return 1.0 - math.log1p(-x)
function code(x, y) return Float64(1.0 - log1p(Float64(-x))) end
code[x_, y_] := N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \mathsf{log1p}\left(-x\right)
\end{array}
Initial program 73.3%
sub-neg73.3%
log1p-def73.4%
neg-sub073.4%
div-sub73.4%
associate--r-73.4%
neg-sub073.4%
+-commutative73.4%
sub-neg73.4%
div-sub73.4%
Simplified73.4%
Taylor expanded in y around 0 65.3%
log1p-def65.3%
mul-1-neg65.3%
Simplified65.3%
Final simplification65.3%
(FPCore (x y) :precision binary64 (if (<= y -1.38e-5) (- 1.0 (/ x y)) (- 1.0 y)))
double code(double x, double y) {
double tmp;
if (y <= -1.38e-5) {
tmp = 1.0 - (x / y);
} else {
tmp = 1.0 - y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.38d-5)) then
tmp = 1.0d0 - (x / y)
else
tmp = 1.0d0 - y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.38e-5) {
tmp = 1.0 - (x / y);
} else {
tmp = 1.0 - y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.38e-5: tmp = 1.0 - (x / y) else: tmp = 1.0 - y return tmp
function code(x, y) tmp = 0.0 if (y <= -1.38e-5) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(1.0 - y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.38e-5) tmp = 1.0 - (x / y); else tmp = 1.0 - y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.38e-5], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(1.0 - y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.38 \cdot 10^{-5}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 - y\\
\end{array}
\end{array}
if y < -1.38e-5Initial program 17.7%
sub-neg17.7%
log1p-def17.7%
neg-sub017.7%
div-sub17.7%
associate--r-17.7%
neg-sub017.7%
+-commutative17.7%
sub-neg17.7%
div-sub17.7%
Simplified17.7%
Taylor expanded in x around inf 27.0%
neg-mul-127.0%
distribute-neg-frac27.0%
Simplified27.0%
frac-2neg27.0%
div-inv27.0%
remove-double-neg27.0%
Applied egg-rr27.0%
associate-*r/27.0%
*-rgt-identity27.0%
neg-sub027.0%
associate--r-27.0%
metadata-eval27.0%
Simplified27.0%
Taylor expanded in y around inf 12.9%
if -1.38e-5 < y Initial program 95.5%
sub-neg95.5%
log1p-def95.5%
neg-sub095.5%
div-sub95.5%
associate--r-95.5%
neg-sub095.5%
+-commutative95.5%
sub-neg95.5%
div-sub95.5%
Simplified95.5%
Taylor expanded in x around 0 61.8%
log1p-def61.8%
Simplified61.8%
Taylor expanded in y around 0 62.1%
Final simplification48.1%
(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 73.3%
sub-neg73.3%
log1p-def73.4%
neg-sub073.4%
div-sub73.4%
associate--r-73.4%
neg-sub073.4%
+-commutative73.4%
sub-neg73.4%
div-sub73.4%
Simplified73.4%
Taylor expanded in x around inf 75.4%
neg-mul-175.4%
distribute-neg-frac75.4%
Simplified75.4%
frac-2neg75.4%
div-inv75.4%
remove-double-neg75.4%
Applied egg-rr75.4%
associate-*r/75.4%
*-rgt-identity75.4%
neg-sub075.4%
associate--r-75.4%
metadata-eval75.4%
Simplified75.4%
Taylor expanded in x around 0 49.4%
Final simplification49.4%
(FPCore (x y) :precision binary64 (- 1.0 y))
double code(double x, double y) {
return 1.0 - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - y
end function
public static double code(double x, double y) {
return 1.0 - y;
}
def code(x, y): return 1.0 - y
function code(x, y) return Float64(1.0 - y) end
function tmp = code(x, y) tmp = 1.0 - y; end
code[x_, y_] := N[(1.0 - y), $MachinePrecision]
\begin{array}{l}
\\
1 - y
\end{array}
Initial program 73.3%
sub-neg73.3%
log1p-def73.4%
neg-sub073.4%
div-sub73.4%
associate--r-73.4%
neg-sub073.4%
+-commutative73.4%
sub-neg73.4%
div-sub73.4%
Simplified73.4%
Taylor expanded in x around 0 45.0%
log1p-def45.0%
Simplified45.0%
Taylor expanded in y around 0 45.7%
Final simplification45.7%
(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 2023224
(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))))))