
(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 10 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 -16500.0)
(+ 1.0 (- (- (/ (+ -1.0 (/ -0.5 y)) y) (log1p (- x))) (log (/ -1.0 y))))
(if (<= y 4.1e+20)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(- 1.0 (- (log (+ -1.0 x)) (log y))))))
double code(double x, double y) {
double tmp;
if (y <= -16500.0) {
tmp = 1.0 + ((((-1.0 + (-0.5 / y)) / y) - log1p(-x)) - log((-1.0 / y)));
} else if (y <= 4.1e+20) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (log((-1.0 + x)) - log(y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -16500.0) {
tmp = 1.0 + ((((-1.0 + (-0.5 / y)) / y) - Math.log1p(-x)) - Math.log((-1.0 / y)));
} else if (y <= 4.1e+20) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (Math.log((-1.0 + x)) - Math.log(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -16500.0: tmp = 1.0 + ((((-1.0 + (-0.5 / y)) / y) - math.log1p(-x)) - math.log((-1.0 / y))) elif y <= 4.1e+20: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 - (math.log((-1.0 + x)) - math.log(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -16500.0) tmp = Float64(1.0 + Float64(Float64(Float64(Float64(-1.0 + Float64(-0.5 / y)) / y) - log1p(Float64(-x))) - log(Float64(-1.0 / y)))); elseif (y <= 4.1e+20) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 - Float64(log(Float64(-1.0 + x)) - log(y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -16500.0], N[(1.0 + N[(N[(N[(N[(-1.0 + N[(-0.5 / y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.1e+20], 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[N[(-1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -16500:\\
\;\;\;\;1 + \left(\left(\frac{-1 + \frac{-0.5}{y}}{y} - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+20}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(-1 + x\right) - \log y\right)\\
\end{array}
\end{array}
if y < -16500Initial program 16.4%
sub-neg16.4%
log1p-define16.4%
distribute-neg-frac216.4%
neg-sub016.4%
associate--r-16.4%
metadata-eval16.4%
+-commutative16.4%
Simplified16.4%
Taylor expanded in y around -inf 87.0%
Simplified99.8%
if -16500 < y < 4.1e20Initial 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%
if 4.1e20 < 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.5%
log-rec98.5%
unsub-neg98.5%
sub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y -6600000000000.0)
(- 1.0 (+ (log (/ -1.0 y)) (log1p (- x))))
(if (<= y 3e+16)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(- 1.0 (- (log (+ -1.0 x)) (log y))))))
double code(double x, double y) {
double tmp;
if (y <= -6600000000000.0) {
tmp = 1.0 - (log((-1.0 / y)) + log1p(-x));
} else if (y <= 3e+16) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (log((-1.0 + x)) - log(y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -6600000000000.0) {
tmp = 1.0 - (Math.log((-1.0 / y)) + Math.log1p(-x));
} else if (y <= 3e+16) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (Math.log((-1.0 + x)) - Math.log(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6600000000000.0: tmp = 1.0 - (math.log((-1.0 / y)) + math.log1p(-x)) elif y <= 3e+16: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 - (math.log((-1.0 + x)) - math.log(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -6600000000000.0) tmp = Float64(1.0 - Float64(log(Float64(-1.0 / y)) + log1p(Float64(-x)))); elseif (y <= 3e+16) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 - Float64(log(Float64(-1.0 + x)) - log(y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -6600000000000.0], N[(1.0 - N[(N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision] + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e+16], 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[N[(-1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6600000000000:\\
\;\;\;\;1 - \left(\log \left(\frac{-1}{y}\right) + \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+16}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(-1 + x\right) - \log y\right)\\
\end{array}
\end{array}
if y < -6.6e12Initial program 13.3%
sub-neg13.3%
log1p-define13.3%
distribute-neg-frac213.3%
neg-sub013.3%
associate--r-13.3%
metadata-eval13.3%
+-commutative13.3%
Simplified13.3%
Taylor expanded in y around -inf 99.8%
sub-neg99.8%
metadata-eval99.8%
distribute-lft-in99.8%
metadata-eval99.8%
+-commutative99.8%
log1p-define99.8%
mul-1-neg99.8%
Simplified99.8%
if -6.6e12 < y < 3e16Initial program 99.7%
sub-neg99.7%
log1p-define99.7%
distribute-neg-frac299.7%
neg-sub099.7%
associate--r-99.7%
metadata-eval99.7%
+-commutative99.7%
Simplified99.7%
if 3e16 < 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.5%
log-rec98.5%
unsub-neg98.5%
sub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -680000.0)
(+ 1.0 (- (- (/ -1.0 y) (log (/ -1.0 y))) (log1p (- x))))
(if (<= y 4.15e+18)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(- 1.0 (- (log (+ -1.0 x)) (log y))))))
double code(double x, double y) {
double tmp;
if (y <= -680000.0) {
tmp = 1.0 + (((-1.0 / y) - log((-1.0 / y))) - log1p(-x));
} else if (y <= 4.15e+18) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (log((-1.0 + x)) - log(y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -680000.0) {
tmp = 1.0 + (((-1.0 / y) - Math.log((-1.0 / y))) - Math.log1p(-x));
} else if (y <= 4.15e+18) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - (Math.log((-1.0 + x)) - Math.log(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -680000.0: tmp = 1.0 + (((-1.0 / y) - math.log((-1.0 / y))) - math.log1p(-x)) elif y <= 4.15e+18: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 - (math.log((-1.0 + x)) - math.log(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -680000.0) tmp = Float64(1.0 + Float64(Float64(Float64(-1.0 / y) - log(Float64(-1.0 / y))) - log1p(Float64(-x)))); elseif (y <= 4.15e+18) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 - Float64(log(Float64(-1.0 + x)) - log(y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -680000.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, 4.15e+18], 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[N[(-1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -680000:\\
\;\;\;\;1 + \left(\left(\frac{-1}{y} - \log \left(\frac{-1}{y}\right)\right) - \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{elif}\;y \leq 4.15 \cdot 10^{+18}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(-1 + x\right) - \log y\right)\\
\end{array}
\end{array}
if y < -6.8e5Initial program 15.4%
sub-neg15.4%
log1p-define15.4%
distribute-neg-frac215.4%
neg-sub015.4%
associate--r-15.4%
metadata-eval15.4%
+-commutative15.4%
Simplified15.4%
Taylor expanded in y around -inf 99.7%
Simplified99.7%
if -6.8e5 < y < 4.15e18Initial 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 4.15e18 < 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.5%
log-rec98.5%
unsub-neg98.5%
sub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= (- 1.0 (/ (- x y) (- 1.0 y))) 0.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ (- x y) (+ y -1.0))))))
double code(double x, double y) {
double tmp;
if ((1.0 - ((x - y) / (1.0 - y))) <= 0.0) {
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 ((1.0 - ((x - y) / (1.0 - y))) <= 0.0) {
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 (1.0 - ((x - y) / (1.0 - y))) <= 0.0: 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 (Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))) <= 0.0) 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[N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], 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}\;1 - \frac{x - y}{1 - y} \leq 0:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))) < 0.0Initial program 3.1%
sub-neg3.1%
log1p-define3.1%
distribute-neg-frac23.1%
neg-sub03.1%
associate--r-3.1%
metadata-eval3.1%
+-commutative3.1%
Simplified3.1%
Taylor expanded in y around -inf 88.1%
sub-neg88.1%
metadata-eval88.1%
distribute-lft-in88.1%
metadata-eval88.1%
+-commutative88.1%
log1p-define88.1%
mul-1-neg88.1%
Simplified88.1%
Taylor expanded in x around 0 70.8%
if 0.0 < (-.f64 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))) Initial program 99.6%
sub-neg99.6%
log1p-define99.6%
distribute-neg-frac299.6%
neg-sub099.6%
associate--r-99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Final simplification92.0%
(FPCore (x y) :precision binary64 (if (<= y -12.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- (- 1.0 y) (log1p (- x))) (- 1.0 (log (/ (+ 1.0 x) y))))))
double code(double x, double y) {
double tmp;
if (y <= -12.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = 1.0 - log(((1.0 + x) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -12.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.log(((1.0 + x) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -12.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.log(((1.0 + x) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -12.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(Float64(1.0 + x) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -12.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1 + x}{y}\right)\\
\end{array}
\end{array}
if y < -12Initial program 17.5%
sub-neg17.5%
log1p-define17.5%
distribute-neg-frac217.5%
neg-sub017.5%
associate--r-17.5%
metadata-eval17.5%
+-commutative17.5%
Simplified17.5%
Taylor expanded in y around -inf 97.5%
sub-neg97.5%
metadata-eval97.5%
distribute-lft-in97.5%
metadata-eval97.5%
+-commutative97.5%
log1p-define97.5%
mul-1-neg97.5%
Simplified97.5%
Taylor expanded in x around 0 69.9%
if -12 < 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 98.9%
Simplified98.9%
if 1 < y Initial program 61.9%
sub-neg61.9%
log1p-define61.9%
distribute-neg-frac261.9%
neg-sub061.9%
associate--r-61.9%
metadata-eval61.9%
+-commutative61.9%
Simplified61.9%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-define0.0%
mul-1-neg0.0%
Simplified0.0%
+-commutative0.0%
log1p-undefine0.0%
sum-log94.4%
add-sqr-sqrt0.0%
sqrt-unprod1.1%
frac-times1.1%
metadata-eval1.1%
metadata-eval1.1%
frac-times1.1%
sqrt-unprod0.0%
add-sqr-sqrt0.0%
+-commutative0.0%
add-sqr-sqrt0.0%
sqrt-unprod44.9%
sqr-neg44.9%
sqrt-unprod92.3%
add-sqr-sqrt92.3%
Applied egg-rr92.3%
associate-*l/92.3%
distribute-lft-in92.3%
*-lft-identity92.3%
metadata-eval92.3%
+-commutative92.3%
Simplified92.3%
Final simplification90.3%
(FPCore (x y) :precision binary64 (if (<= y -11.0) (- 1.0 (log (/ -1.0 y))) (- (- 1.0 y) (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -11.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 <= -11.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 <= -11.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 <= -11.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, -11.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 -11:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -11Initial program 17.5%
sub-neg17.5%
log1p-define17.5%
distribute-neg-frac217.5%
neg-sub017.5%
associate--r-17.5%
metadata-eval17.5%
+-commutative17.5%
Simplified17.5%
Taylor expanded in y around -inf 97.5%
sub-neg97.5%
metadata-eval97.5%
distribute-lft-in97.5%
metadata-eval97.5%
+-commutative97.5%
log1p-define97.5%
mul-1-neg97.5%
Simplified97.5%
Taylor expanded in x around 0 69.9%
if -11 < y Initial program 95.6%
sub-neg95.6%
log1p-define95.7%
distribute-neg-frac295.7%
neg-sub095.7%
associate--r-95.7%
metadata-eval95.7%
+-commutative95.7%
Simplified95.7%
Taylor expanded in y around 0 87.6%
Simplified87.6%
Final simplification82.7%
(FPCore (x y) :precision binary64 (if (<= y -12.5) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -12.5) {
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 <= -12.5) {
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 <= -12.5: 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 <= -12.5) 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, -12.5], 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 -12.5:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -12.5Initial program 17.5%
sub-neg17.5%
log1p-define17.5%
distribute-neg-frac217.5%
neg-sub017.5%
associate--r-17.5%
metadata-eval17.5%
+-commutative17.5%
Simplified17.5%
Taylor expanded in y around -inf 97.5%
sub-neg97.5%
metadata-eval97.5%
distribute-lft-in97.5%
metadata-eval97.5%
+-commutative97.5%
log1p-define97.5%
mul-1-neg97.5%
Simplified97.5%
Taylor expanded in x around 0 69.9%
if -12.5 < y Initial program 95.6%
sub-neg95.6%
log1p-define95.7%
distribute-neg-frac295.7%
neg-sub095.7%
associate--r-95.7%
metadata-eval95.7%
+-commutative95.7%
Simplified95.7%
Taylor expanded in y around 0 86.5%
log1p-define86.5%
mul-1-neg86.5%
Simplified86.5%
Final simplification81.9%
(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.0%
sub-neg74.0%
log1p-define74.0%
distribute-neg-frac274.0%
neg-sub074.0%
associate--r-74.0%
metadata-eval74.0%
+-commutative74.0%
Simplified74.0%
Taylor expanded in y around 0 66.0%
log1p-define66.0%
mul-1-neg66.0%
Simplified66.0%
Final simplification66.0%
(FPCore (x y) :precision binary64 (+ 1.0 x))
double code(double x, double y) {
return 1.0 + x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + x
end function
public static double code(double x, double y) {
return 1.0 + x;
}
def code(x, y): return 1.0 + x
function code(x, y) return Float64(1.0 + x) end
function tmp = code(x, y) tmp = 1.0 + x; end
code[x_, y_] := N[(1.0 + x), $MachinePrecision]
\begin{array}{l}
\\
1 + x
\end{array}
Initial program 74.0%
sub-neg74.0%
log1p-define74.0%
distribute-neg-frac274.0%
neg-sub074.0%
associate--r-74.0%
metadata-eval74.0%
+-commutative74.0%
Simplified74.0%
Taylor expanded in y around 0 66.0%
log1p-define66.0%
mul-1-neg66.0%
Simplified66.0%
Taylor expanded in x around 0 43.6%
Final simplification43.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 74.0%
sub-neg74.0%
log1p-define74.0%
distribute-neg-frac274.0%
neg-sub074.0%
associate--r-74.0%
metadata-eval74.0%
+-commutative74.0%
Simplified74.0%
Taylor expanded in y around 0 66.0%
log1p-define66.0%
mul-1-neg66.0%
Simplified66.0%
Taylor expanded in x around 0 43.3%
Final simplification43.3%
(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 2024095
(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))))))