
(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 9 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 -1100000.0)
(- (+ 1.0 (- (/ -1.0 y) (log1p (- x)))) (log (/ -1.0 y)))
(if (<= y 10500000000000.0)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(+ 1.0 (- (log y) (log (+ -1.0 x)))))))
double code(double x, double y) {
double tmp;
if (y <= -1100000.0) {
tmp = (1.0 + ((-1.0 / y) - log1p(-x))) - log((-1.0 / y));
} else if (y <= 10500000000000.0) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 + (log(y) - log((-1.0 + x)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1100000.0) {
tmp = (1.0 + ((-1.0 / y) - Math.log1p(-x))) - Math.log((-1.0 / y));
} else if (y <= 10500000000000.0) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((-1.0 + x)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1100000.0: tmp = (1.0 + ((-1.0 / y) - math.log1p(-x))) - math.log((-1.0 / y)) elif y <= 10500000000000.0: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 + (math.log(y) - math.log((-1.0 + x))) return tmp
function code(x, y) tmp = 0.0 if (y <= -1100000.0) tmp = Float64(Float64(1.0 + Float64(Float64(-1.0 / y) - log1p(Float64(-x)))) - log(Float64(-1.0 / y))); elseif (y <= 10500000000000.0) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(-1.0 + x)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -1100000.0], N[(N[(1.0 + N[(N[(-1.0 / y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 10500000000000.0], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(-1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1100000:\\
\;\;\;\;\left(1 + \left(\frac{-1}{y} - \mathsf{log1p}\left(-x\right)\right)\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 10500000000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(-1 + x\right)\right)\\
\end{array}
\end{array}
if y < -1.1e6Initial program 23.0%
sub-neg23.0%
log1p-define23.0%
distribute-neg-frac223.0%
neg-sub023.0%
associate--r-23.0%
metadata-eval23.0%
+-commutative23.0%
Simplified23.0%
Taylor expanded in y around -inf 99.6%
Simplified99.6%
if -1.1e6 < y < 1.05e13Initial program 100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if 1.05e13 < y Initial program 55.6%
sub-neg55.6%
log1p-define55.6%
distribute-neg-frac255.6%
neg-sub055.6%
associate--r-55.6%
metadata-eval55.6%
+-commutative55.6%
Simplified55.6%
Taylor expanded in y around inf 98.0%
log-rec98.0%
unsub-neg98.0%
sub-neg98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -4500000000.0)
(- 1.0 (+ (log1p (- x)) (log (/ -1.0 y))))
(if (<= y 2.25e+21)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(+ 1.0 (- (log y) (log (+ -1.0 x)))))))
double code(double x, double y) {
double tmp;
if (y <= -4500000000.0) {
tmp = 1.0 - (log1p(-x) + log((-1.0 / y)));
} else if (y <= 2.25e+21) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 + (log(y) - log((-1.0 + x)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -4500000000.0) {
tmp = 1.0 - (Math.log1p(-x) + Math.log((-1.0 / y)));
} else if (y <= 2.25e+21) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((-1.0 + x)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4500000000.0: tmp = 1.0 - (math.log1p(-x) + math.log((-1.0 / y))) elif y <= 2.25e+21: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 + (math.log(y) - math.log((-1.0 + x))) return tmp
function code(x, y) tmp = 0.0 if (y <= -4500000000.0) tmp = Float64(1.0 - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (y <= 2.25e+21) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(-1.0 + x)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -4500000000.0], N[(1.0 - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.25e+21], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(-1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4500000000:\\
\;\;\;\;1 - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+21}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(-1 + x\right)\right)\\
\end{array}
\end{array}
if y < -4.5e9Initial program 23.0%
sub-neg23.0%
log1p-define23.0%
distribute-neg-frac223.0%
neg-sub023.0%
associate--r-23.0%
metadata-eval23.0%
+-commutative23.0%
Simplified23.0%
Taylor expanded in y around -inf 99.2%
sub-neg99.2%
metadata-eval99.2%
distribute-lft-in99.2%
metadata-eval99.2%
+-commutative99.2%
log1p-define99.2%
mul-1-neg99.2%
Simplified99.2%
if -4.5e9 < y < 2.25e21Initial program 100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if 2.25e21 < y Initial program 55.6%
sub-neg55.6%
log1p-define55.6%
distribute-neg-frac255.6%
neg-sub055.6%
associate--r-55.6%
metadata-eval55.6%
+-commutative55.6%
Simplified55.6%
Taylor expanded in y around inf 98.0%
log-rec98.0%
unsub-neg98.0%
sub-neg98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.2) (- 1.0 (log1p (/ (- x y) (+ y -1.0)))) (+ 1.0 (- (/ -1.0 y) (log (/ -1.0 y))))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.2) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} 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.2) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} 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.2: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) 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.2) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); 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.2], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $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.2:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\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 #s(literal 1 binary64) y)) < 0.20000000000000001Initial program 100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if 0.20000000000000001 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) Initial program 4.5%
sub-neg4.5%
log1p-define4.5%
distribute-neg-frac24.5%
neg-sub04.5%
associate--r-4.5%
metadata-eval4.5%
+-commutative4.5%
Simplified4.5%
Taylor expanded in x around 0 4.5%
sub-neg4.5%
mul-1-neg4.5%
sub-neg4.5%
metadata-eval4.5%
neg-mul-14.5%
log1p-define4.5%
distribute-neg-frac24.5%
+-commutative4.5%
distribute-neg-in4.5%
metadata-eval4.5%
unsub-neg4.5%
Simplified4.5%
Taylor expanded in y around -inf 76.1%
+-commutative76.1%
Simplified76.1%
Final simplification93.4%
(FPCore (x y) :precision binary64 (if (<= y -2.45e+20) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ (- x y) (+ y -1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -2.45e+20) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -2.45e+20) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.45e+20: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.45e+20) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -2.45e+20], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \cdot 10^{+20}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\end{array}
\end{array}
if y < -2.45e20Initial program 20.0%
sub-neg20.0%
log1p-define20.0%
distribute-neg-frac220.0%
neg-sub020.0%
associate--r-20.0%
metadata-eval20.0%
+-commutative20.0%
Simplified20.0%
Taylor expanded in x around 0 2.7%
sub-neg2.7%
mul-1-neg2.7%
sub-neg2.7%
metadata-eval2.7%
neg-mul-12.7%
log1p-define2.7%
distribute-neg-frac22.7%
+-commutative2.7%
distribute-neg-in2.7%
metadata-eval2.7%
unsub-neg2.7%
Simplified2.7%
Taylor expanded in y around -inf 74.6%
if -2.45e20 < y Initial program 93.7%
sub-neg93.7%
log1p-define93.8%
distribute-neg-frac293.8%
neg-sub093.8%
associate--r-93.8%
metadata-eval93.8%
+-commutative93.8%
Simplified93.8%
Final simplification88.6%
(FPCore (x y) :precision binary64 (if (<= y -2.65e+22) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ x (+ y -1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -2.65e+22) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p((x / (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -2.65e+22) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.65e+22: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p((x / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.65e+22) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -2.65e+22], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $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 -2.65 \cdot 10^{+22}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\end{array}
\end{array}
if y < -2.6499999999999999e22Initial program 20.0%
sub-neg20.0%
log1p-define20.0%
distribute-neg-frac220.0%
neg-sub020.0%
associate--r-20.0%
metadata-eval20.0%
+-commutative20.0%
Simplified20.0%
Taylor expanded in x around 0 2.7%
sub-neg2.7%
mul-1-neg2.7%
sub-neg2.7%
metadata-eval2.7%
neg-mul-12.7%
log1p-define2.7%
distribute-neg-frac22.7%
+-commutative2.7%
distribute-neg-in2.7%
metadata-eval2.7%
unsub-neg2.7%
Simplified2.7%
Taylor expanded in y around -inf 74.6%
if -2.6499999999999999e22 < y Initial program 93.7%
sub-neg93.7%
log1p-define93.8%
distribute-neg-frac293.8%
neg-sub093.8%
associate--r-93.8%
metadata-eval93.8%
+-commutative93.8%
Simplified93.8%
Taylor expanded in x around inf 92.5%
Final simplification87.6%
(FPCore (x y) :precision binary64 (if (<= y -30.0) (- 1.0 (log (/ -1.0 y))) (- (- 1.0 y) (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -30.0) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = (1.0 - y) - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -30.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = (1.0 - y) - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -30.0: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = (1.0 - y) - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if (y <= -30.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -30.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -30:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -30Initial program 25.0%
sub-neg25.0%
log1p-define25.0%
distribute-neg-frac225.0%
neg-sub025.0%
associate--r-25.0%
metadata-eval25.0%
+-commutative25.0%
Simplified25.0%
Taylor expanded in x around 0 3.9%
sub-neg3.9%
mul-1-neg3.9%
sub-neg3.9%
metadata-eval3.9%
neg-mul-13.9%
log1p-define3.9%
distribute-neg-frac23.9%
+-commutative3.9%
distribute-neg-in3.9%
metadata-eval3.9%
unsub-neg3.9%
Simplified3.9%
Taylor expanded in y around -inf 71.0%
if -30 < y Initial program 94.1%
sub-neg94.1%
log1p-define94.1%
distribute-neg-frac294.1%
neg-sub094.1%
associate--r-94.1%
metadata-eval94.1%
+-commutative94.1%
Simplified94.1%
Taylor expanded in y around 0 85.1%
Simplified85.1%
Final simplification81.0%
(FPCore (x y) :precision binary64 (if (<= y -1100000.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -1100000.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 <= -1100000.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 <= -1100000.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 <= -1100000.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, -1100000.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 -1100000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -1.1e6Initial program 23.0%
sub-neg23.0%
log1p-define23.0%
distribute-neg-frac223.0%
neg-sub023.0%
associate--r-23.0%
metadata-eval23.0%
+-commutative23.0%
Simplified23.0%
Taylor expanded in x around 0 3.9%
sub-neg3.9%
mul-1-neg3.9%
sub-neg3.9%
metadata-eval3.9%
neg-mul-13.9%
log1p-define3.9%
distribute-neg-frac23.9%
+-commutative3.9%
distribute-neg-in3.9%
metadata-eval3.9%
unsub-neg3.9%
Simplified3.9%
Taylor expanded in y around -inf 72.9%
if -1.1e6 < y Initial program 94.1%
sub-neg94.1%
log1p-define94.2%
distribute-neg-frac294.2%
neg-sub094.2%
associate--r-94.2%
metadata-eval94.2%
+-commutative94.2%
Simplified94.2%
Taylor expanded in y around 0 83.6%
log1p-define83.7%
mul-1-neg83.7%
Simplified83.7%
Final simplification80.6%
(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.9%
sub-neg73.9%
log1p-define73.9%
distribute-neg-frac273.9%
neg-sub073.9%
associate--r-73.9%
metadata-eval73.9%
+-commutative73.9%
Simplified73.9%
Taylor expanded in y around 0 63.7%
log1p-define63.7%
mul-1-neg63.7%
Simplified63.7%
Final simplification63.7%
(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.9%
sub-neg73.9%
log1p-define73.9%
distribute-neg-frac273.9%
neg-sub073.9%
associate--r-73.9%
metadata-eval73.9%
+-commutative73.9%
Simplified73.9%
Taylor expanded in x around 0 44.0%
sub-neg44.0%
mul-1-neg44.0%
sub-neg44.0%
metadata-eval44.0%
neg-mul-144.0%
log1p-define44.0%
distribute-neg-frac244.0%
+-commutative44.0%
distribute-neg-in44.0%
metadata-eval44.0%
unsub-neg44.0%
Simplified44.0%
Taylor expanded in y around 0 44.0%
Final simplification44.0%
(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 2024071
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:alt
(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))))))