
(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 (<= (/ (- x y) (- 1.0 y)) 5e-11) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (* 2.0 (log (sqrt (/ (* y E) (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 5e-11) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 2.0 * log(sqrt(((y * ((double) M_E)) / (x + -1.0))));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 5e-11) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 2.0 * Math.log(Math.sqrt(((y * Math.E) / (x + -1.0))));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 5e-11: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 2.0 * math.log(math.sqrt(((y * math.e) / (x + -1.0)))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 5e-11) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(2.0 * log(sqrt(Float64(Float64(y * exp(1)) / Float64(x + -1.0))))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 5e-11], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Log[N[Sqrt[N[(N[(y * E), $MachinePrecision] / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \log \left(\sqrt{\frac{y \cdot e}{x + -1}}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 5.00000000000000018e-11Initial program 99.9%
sub-neg99.9%
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 5.00000000000000018e-11 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 6.8%
sub-neg6.8%
log1p-def6.8%
neg-sub06.8%
div-sub6.8%
associate--r-6.8%
neg-sub06.8%
+-commutative6.8%
sub-neg6.8%
div-sub6.8%
Simplified6.8%
add-log-exp6.8%
add-sqr-sqrt6.8%
log-prod6.8%
exp-diff6.8%
exp-1-e6.8%
log1p-udef6.8%
add-exp-log6.8%
exp-diff6.8%
exp-1-e6.8%
log1p-udef6.8%
add-exp-log6.8%
Applied egg-rr6.8%
count-26.8%
remove-double-neg6.8%
unsub-neg6.8%
*-rgt-identity6.8%
associate-*r/8.4%
distribute-rgt-neg-in8.4%
distribute-neg-frac8.4%
metadata-eval8.4%
metadata-eval8.4%
associate-/r*8.4%
neg-mul-18.4%
associate-*r/6.8%
*-rgt-identity6.8%
neg-sub06.8%
associate--r-6.8%
metadata-eval6.8%
Simplified6.8%
Taylor expanded in y around inf 99.6%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -470000.0)
(-
(- 1.0 (/ (+ (/ x (+ x -1.0)) (/ -1.0 (+ x -1.0))) y))
(+ (log1p (- x)) (log (/ -1.0 y))))
(if (<= y 1.7e+16)
(- 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 <= -470000.0) {
tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -1.0))) / y)) - (log1p(-x) + log((-1.0 / y)));
} else if (y <= 1.7e+16) {
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 <= -470000.0) {
tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -1.0))) / y)) - (Math.log1p(-x) + Math.log((-1.0 / y)));
} else if (y <= 1.7e+16) {
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 <= -470000.0: tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -1.0))) / y)) - (math.log1p(-x) + math.log((-1.0 / y))) elif y <= 1.7e+16: 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 <= -470000.0) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(x / Float64(x + -1.0)) + Float64(-1.0 / Float64(x + -1.0))) / y)) - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (y <= 1.7e+16) 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, -470000.0], N[(N[(1.0 - N[(N[(N[(x / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.7e+16], 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 -470000:\\
\;\;\;\;\left(1 - \frac{\frac{x}{x + -1} + \frac{-1}{x + -1}}{y}\right) - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{+16}:\\
\;\;\;\;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 < -4.7e5Initial program 19.6%
sub-neg19.6%
log1p-def19.6%
neg-sub019.6%
div-sub19.6%
associate--r-19.6%
neg-sub019.6%
+-commutative19.6%
sub-neg19.6%
div-sub19.6%
Simplified19.6%
Taylor expanded in y around -inf 99.5%
mul-1-neg99.5%
unsub-neg99.5%
sub-neg99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
if -4.7e5 < y < 1.7e16Initial 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 1.7e16 < y Initial program 56.9%
sub-neg56.9%
log1p-def56.9%
neg-sub056.9%
div-sub56.9%
associate--r-56.9%
neg-sub056.9%
+-commutative56.9%
sub-neg56.9%
div-sub56.9%
Simplified56.9%
Taylor expanded in y around inf 98.1%
+-commutative98.1%
log-rec98.1%
unsub-neg98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
Simplified98.1%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -500000.0)
(+
1.0
(- (- (/ (- 1.0 x) (* y (+ x -1.0))) (log (/ -1.0 y))) (log1p (- x))))
(if (<= y 5e+14)
(- 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 <= -500000.0) {
tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - log((-1.0 / y))) - log1p(-x));
} else if (y <= 5e+14) {
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 <= -500000.0) {
tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - Math.log((-1.0 / y))) - Math.log1p(-x));
} else if (y <= 5e+14) {
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 <= -500000.0: tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - math.log((-1.0 / y))) - math.log1p(-x)) elif y <= 5e+14: 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 <= -500000.0) tmp = Float64(1.0 + Float64(Float64(Float64(Float64(1.0 - x) / Float64(y * Float64(x + -1.0))) - log(Float64(-1.0 / y))) - log1p(Float64(-x)))); elseif (y <= 5e+14) 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, -500000.0], N[(1.0 + N[(N[(N[(N[(1.0 - x), $MachinePrecision] / N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+14], 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 -500000:\\
\;\;\;\;1 + \left(\left(\frac{1 - x}{y \cdot \left(x + -1\right)} - \log \left(\frac{-1}{y}\right)\right) - \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+14}:\\
\;\;\;\;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 < -5e5Initial program 19.6%
sub-neg19.6%
log1p-def19.6%
neg-sub019.6%
div-sub19.6%
associate--r-19.6%
neg-sub019.6%
+-commutative19.6%
sub-neg19.6%
div-sub19.6%
Simplified19.6%
Taylor expanded in y around -inf 99.4%
sub-neg99.4%
metadata-eval99.4%
distribute-lft-in99.4%
metadata-eval99.4%
+-commutative99.4%
log1p-def99.4%
mul-1-neg99.4%
mul-1-neg99.4%
unsub-neg99.4%
div-sub99.4%
associate-/l/99.4%
sub-neg99.4%
metadata-eval99.4%
Simplified99.4%
if -5e5 < y < 5e14Initial 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 5e14 < y Initial program 56.9%
sub-neg56.9%
log1p-def56.9%
neg-sub056.9%
div-sub56.9%
associate--r-56.9%
neg-sub056.9%
+-commutative56.9%
sub-neg56.9%
div-sub56.9%
Simplified56.9%
Taylor expanded in y around inf 98.1%
+-commutative98.1%
log-rec98.1%
unsub-neg98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
Simplified98.1%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -5400000000.0)
(- 1.0 (+ (log1p (- x)) (log (/ -1.0 y))))
(if (<= y 7600000000000.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 <= -5400000000.0) {
tmp = 1.0 - (log1p(-x) + log((-1.0 / y)));
} else if (y <= 7600000000000.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 <= -5400000000.0) {
tmp = 1.0 - (Math.log1p(-x) + Math.log((-1.0 / y)));
} else if (y <= 7600000000000.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 <= -5400000000.0: tmp = 1.0 - (math.log1p(-x) + math.log((-1.0 / y))) elif y <= 7600000000000.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 <= -5400000000.0) tmp = Float64(1.0 - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (y <= 7600000000000.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, -5400000000.0], N[(1.0 - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7600000000000.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 -5400000000:\\
\;\;\;\;1 - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 7600000000000:\\
\;\;\;\;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 < -5.4e9Initial program 19.6%
sub-neg19.6%
log1p-def19.6%
neg-sub019.6%
div-sub19.6%
associate--r-19.6%
neg-sub019.6%
+-commutative19.6%
sub-neg19.6%
div-sub19.6%
Simplified19.6%
Taylor expanded in y around -inf 99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-lft-in99.1%
metadata-eval99.1%
+-commutative99.1%
log1p-def99.1%
mul-1-neg99.1%
Simplified99.1%
if -5.4e9 < y < 7.6e12Initial 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 7.6e12 < y Initial program 56.9%
sub-neg56.9%
log1p-def56.9%
neg-sub056.9%
div-sub56.9%
associate--r-56.9%
neg-sub056.9%
+-commutative56.9%
sub-neg56.9%
div-sub56.9%
Simplified56.9%
Taylor expanded in y around inf 98.1%
+-commutative98.1%
log-rec98.1%
unsub-neg98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
Simplified98.1%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.999999995) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (+ 1.0 (- (/ -1.0 y) (log (/ -1.0 y))))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.999999995) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + ((-1.0 / y) - log((-1.0 / y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.999999995) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + ((-1.0 / y) - Math.log((-1.0 / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.999999995: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 + ((-1.0 / y) - math.log((-1.0 / y))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.999999995) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 + Float64(Float64(-1.0 / y) - 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], 0.999999995], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(-1.0 / y), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.999999995:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\frac{-1}{y} - \log \left(\frac{-1}{y}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.99999999500000003Initial program 99.8%
sub-neg99.8%
log1p-def99.8%
neg-sub099.8%
div-sub99.8%
associate--r-99.8%
neg-sub099.8%
+-commutative99.8%
sub-neg99.8%
div-sub99.8%
Simplified99.8%
if 0.99999999500000003 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 6.0%
sub-neg6.0%
log1p-def6.0%
neg-sub06.0%
div-sub6.0%
associate--r-6.0%
neg-sub06.0%
+-commutative6.0%
sub-neg6.0%
div-sub6.0%
Simplified6.0%
Taylor expanded in y around -inf 86.8%
sub-neg86.8%
metadata-eval86.8%
distribute-lft-in86.8%
metadata-eval86.8%
+-commutative86.8%
log1p-def86.8%
mul-1-neg86.8%
mul-1-neg86.8%
unsub-neg86.8%
div-sub86.8%
associate-/l/86.8%
sub-neg86.8%
metadata-eval86.8%
Simplified86.8%
Taylor expanded in x around 0 70.6%
Final simplification91.8%
(FPCore (x y) :precision binary64 (if (<= y -270000000000.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ (- y x) (- 1.0 y))))))
double code(double x, double y) {
double tmp;
if (y <= -270000000000.0) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -270000000000.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -270000000000.0: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if (y <= -270000000000.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -270000000000.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -270000000000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -2.7e11Initial program 19.6%
sub-neg19.6%
log1p-def19.6%
neg-sub019.6%
div-sub19.6%
associate--r-19.6%
neg-sub019.6%
+-commutative19.6%
sub-neg19.6%
div-sub19.6%
Simplified19.6%
Taylor expanded in x around 0 5.6%
log1p-def5.6%
Simplified5.6%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.5%
Simplified69.5%
if -2.7e11 < y Initial program 95.1%
sub-neg95.1%
log1p-def95.1%
neg-sub095.1%
div-sub95.1%
associate--r-95.1%
neg-sub095.1%
+-commutative95.1%
sub-neg95.1%
div-sub95.1%
Simplified95.1%
Final simplification88.0%
(FPCore (x y) :precision binary64 (if (<= y -17.0) (- 1.0 (log (/ -1.0 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 <= -17.0) {
tmp = 1.0 - log((-1.0 / 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 <= -17.0) {
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.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -17.0: tmp = 1.0 - math.log((-1.0 / 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 <= -17.0) 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 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -17.0], 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[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -17:\\
\;\;\;\;1 - \log \left(\frac{-1}{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 < -17Initial program 20.7%
sub-neg20.7%
log1p-def20.7%
neg-sub020.7%
div-sub20.7%
associate--r-20.7%
neg-sub020.7%
+-commutative20.7%
sub-neg20.7%
div-sub20.7%
Simplified20.7%
Taylor expanded in x around 0 5.5%
log1p-def5.5%
Simplified5.5%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div68.5%
Simplified68.5%
if -17 < 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 100.0%
div-sub100.0%
mul-1-neg100.0%
sub-neg100.0%
*-inverses100.0%
*-rgt-identity100.0%
log1p-def100.0%
mul-1-neg100.0%
Simplified100.0%
if 1 < y Initial program 56.9%
sub-neg56.9%
log1p-def56.9%
neg-sub056.9%
div-sub56.9%
associate--r-56.9%
neg-sub056.9%
+-commutative56.9%
sub-neg56.9%
div-sub56.9%
Simplified56.9%
Taylor expanded in x around inf 52.6%
neg-mul-152.6%
distribute-neg-frac52.6%
Simplified52.6%
Taylor expanded in y around inf 52.6%
Final simplification87.3%
(FPCore (x y) :precision binary64 (if (<= y -780000000.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ (- x) (- 1.0 y))))))
double code(double x, double y) {
double tmp;
if (y <= -780000000.0) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p((-x / (1.0 - y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -780000000.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p((-x / (1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -780000000.0: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p((-x / (1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if (y <= -780000000.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(Float64(-x) / Float64(1.0 - y)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -780000000.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[((-x) / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -780000000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -7.8e8Initial program 19.6%
sub-neg19.6%
log1p-def19.6%
neg-sub019.6%
div-sub19.6%
associate--r-19.6%
neg-sub019.6%
+-commutative19.6%
sub-neg19.6%
div-sub19.6%
Simplified19.6%
Taylor expanded in x around 0 5.6%
log1p-def5.6%
Simplified5.6%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.5%
Simplified69.5%
if -7.8e8 < y Initial program 95.1%
sub-neg95.1%
log1p-def95.1%
neg-sub095.1%
div-sub95.1%
associate--r-95.1%
neg-sub095.1%
+-commutative95.1%
sub-neg95.1%
div-sub95.1%
Simplified95.1%
Taylor expanded in x around inf 94.4%
neg-mul-194.4%
distribute-neg-frac94.4%
Simplified94.4%
Final simplification87.5%
(FPCore (x y) :precision binary64 (if (<= y -25000.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -25000.0) {
tmp = 1.0 - log((-1.0 / 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 <= -25000.0) {
tmp = 1.0 - Math.log((-1.0 / 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 <= -25000.0: tmp = 1.0 - math.log((-1.0 / 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 <= -25000.0) 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 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -25000.0], 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[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -25000:\\
\;\;\;\;1 - \log \left(\frac{-1}{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 < -25000Initial program 19.6%
sub-neg19.6%
log1p-def19.6%
neg-sub019.6%
div-sub19.6%
associate--r-19.6%
neg-sub019.6%
+-commutative19.6%
sub-neg19.6%
div-sub19.6%
Simplified19.6%
Taylor expanded in x around 0 5.6%
log1p-def5.6%
Simplified5.6%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.5%
Simplified69.5%
if -25000 < 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 99.2%
log1p-def99.3%
mul-1-neg99.3%
Simplified99.3%
if 1 < y Initial program 56.9%
sub-neg56.9%
log1p-def56.9%
neg-sub056.9%
div-sub56.9%
associate--r-56.9%
neg-sub056.9%
+-commutative56.9%
sub-neg56.9%
div-sub56.9%
Simplified56.9%
Taylor expanded in x around inf 52.6%
neg-mul-152.6%
distribute-neg-frac52.6%
Simplified52.6%
Taylor expanded in y around inf 52.6%
Final simplification87.2%
(FPCore (x y) :precision binary64 (if (<= y -25000.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -25000.0) {
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 <= -25000.0) {
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 <= -25000.0: 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 <= -25000.0) 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, -25000.0], 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 -25000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -25000Initial program 19.6%
sub-neg19.6%
log1p-def19.6%
neg-sub019.6%
div-sub19.6%
associate--r-19.6%
neg-sub019.6%
+-commutative19.6%
sub-neg19.6%
div-sub19.6%
Simplified19.6%
Taylor expanded in x around 0 5.6%
log1p-def5.6%
Simplified5.6%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.5%
Simplified69.5%
if -25000 < y Initial program 95.1%
sub-neg95.1%
log1p-def95.1%
neg-sub095.1%
div-sub95.1%
associate--r-95.1%
neg-sub095.1%
+-commutative95.1%
sub-neg95.1%
div-sub95.1%
Simplified95.1%
Taylor expanded in y around 0 88.0%
log1p-def88.0%
mul-1-neg88.0%
Simplified88.0%
Final simplification82.8%
(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 74.1%
sub-neg74.1%
log1p-def74.1%
neg-sub074.1%
div-sub74.1%
associate--r-74.1%
neg-sub074.1%
+-commutative74.1%
sub-neg74.1%
div-sub74.1%
Simplified74.1%
Taylor expanded in y around 0 67.1%
log1p-def67.1%
mul-1-neg67.1%
Simplified67.1%
Final simplification67.1%
(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 74.1%
sub-neg74.1%
log1p-def74.1%
neg-sub074.1%
div-sub74.1%
associate--r-74.1%
neg-sub074.1%
+-commutative74.1%
sub-neg74.1%
div-sub74.1%
Simplified74.1%
Taylor expanded in x around 0 42.9%
log1p-def42.9%
Simplified42.9%
Taylor expanded in y 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 74.1%
sub-neg74.1%
log1p-def74.1%
neg-sub074.1%
div-sub74.1%
associate--r-74.1%
neg-sub074.1%
+-commutative74.1%
sub-neg74.1%
div-sub74.1%
Simplified74.1%
Taylor expanded in y around 0 67.1%
Taylor expanded in x around 0 44.5%
mul-1-neg44.5%
unsub-neg44.5%
unpow244.5%
Simplified44.5%
Taylor expanded in x around 0 45.5%
neg-mul-145.5%
Simplified45.5%
Final simplification45.5%
(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 2023200
(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))))))