
(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 (or (<= y -45000.0) (not (<= y 5e+14))) (- 1.0 (log (/ (+ x -1.0) y))) (- 1.0 (log1p (/ x (+ y -1.0))))))
double code(double x, double y) {
double tmp;
if ((y <= -45000.0) || !(y <= 5e+14)) {
tmp = 1.0 - log(((x + -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 <= -45000.0) || !(y <= 5e+14)) {
tmp = 1.0 - Math.log(((x + -1.0) / y));
} else {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -45000.0) or not (y <= 5e+14): tmp = 1.0 - math.log(((x + -1.0) / y)) else: tmp = 1.0 - math.log1p((x / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if ((y <= -45000.0) || !(y <= 5e+14)) tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); else tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -45000.0], N[Not[LessEqual[y, 5e+14]], $MachinePrecision]], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / 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 -45000 \lor \neg \left(y \leq 5 \cdot 10^{+14}\right):\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\end{array}
\end{array}
if y < -45000 or 5e14 < y Initial program 28.1%
sub-neg28.1%
log1p-def28.1%
neg-sub028.1%
div-sub28.2%
associate--r-28.2%
neg-sub028.2%
+-commutative28.2%
sub-neg28.2%
div-sub28.1%
Simplified28.1%
Taylor expanded in y around inf 27.6%
*-un-lft-identity27.6%
associate--r+27.6%
sub-div27.6%
Applied egg-rr27.6%
*-lft-identity27.6%
sub-neg27.6%
sub-neg27.6%
metadata-eval27.6%
metadata-eval27.6%
Simplified27.6%
Taylor expanded in y around 0 21.4%
mul-1-neg21.4%
unsub-neg21.4%
log-div98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
if -45000 < 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%
Taylor expanded in x around inf 98.6%
neg-mul-198.6%
distribute-neg-frac98.6%
Simplified98.6%
Taylor expanded in x around 0 98.6%
metadata-eval98.6%
times-frac98.6%
*-lft-identity98.6%
neg-mul-198.6%
neg-sub098.6%
associate--r-98.6%
metadata-eval98.6%
Simplified98.6%
Final simplification98.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 (/ (+ x -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(((x + -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(((x + -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(((x + -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(Float64(x + -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[(N[(x + -1.0), $MachinePrecision] / 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{x + -1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 1Initial program 76.7%
sub-neg76.7%
log1p-def76.7%
neg-sub076.7%
div-sub76.7%
associate--r-76.7%
neg-sub076.7%
+-commutative76.7%
sub-neg76.7%
div-sub76.7%
Simplified76.7%
if 1 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 76.7%
sub-neg76.7%
log1p-def76.7%
neg-sub076.7%
div-sub76.7%
associate--r-76.7%
neg-sub076.7%
+-commutative76.7%
sub-neg76.7%
div-sub76.7%
Simplified76.7%
Taylor expanded in y around inf 10.5%
*-un-lft-identity10.5%
associate--r+10.5%
sub-div10.5%
Applied egg-rr10.5%
*-lft-identity10.5%
sub-neg10.5%
sub-neg10.5%
metadata-eval10.5%
metadata-eval10.5%
Simplified10.5%
Taylor expanded in y around 0 6.9%
mul-1-neg6.9%
unsub-neg6.9%
log-div33.6%
sub-neg33.6%
metadata-eval33.6%
+-commutative33.6%
Simplified33.6%
Final simplification76.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.75) (not (<= y 1.0))) (- 1.0 (log (/ (+ x -1.0) y))) (- 1.0 (+ y (log1p (- x))))))
double code(double x, double y) {
double tmp;
if ((y <= -1.75) || !(y <= 1.0)) {
tmp = 1.0 - log(((x + -1.0) / y));
} else {
tmp = 1.0 - (y + log1p(-x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((y <= -1.75) || !(y <= 1.0)) {
tmp = 1.0 - Math.log(((x + -1.0) / y));
} else {
tmp = 1.0 - (y + Math.log1p(-x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.75) or not (y <= 1.0): tmp = 1.0 - math.log(((x + -1.0) / y)) else: tmp = 1.0 - (y + math.log1p(-x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.75) || !(y <= 1.0)) tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); else tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -1.75], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $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 -1.75 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\end{array}
\end{array}
if y < -1.75 or 1 < y Initial program 29.0%
sub-neg29.0%
log1p-def29.0%
neg-sub029.0%
div-sub29.0%
associate--r-29.0%
neg-sub029.0%
+-commutative29.0%
sub-neg29.0%
div-sub29.0%
Simplified29.0%
Taylor expanded in y around inf 27.9%
*-un-lft-identity27.9%
associate--r+27.9%
sub-div27.9%
Applied egg-rr27.9%
*-lft-identity27.9%
sub-neg27.9%
sub-neg27.9%
metadata-eval27.9%
metadata-eval27.9%
Simplified27.9%
Taylor expanded in y around 0 21.1%
mul-1-neg21.1%
unsub-neg21.1%
log-div98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
Simplified98.4%
if -1.75 < 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 98.8%
div-sub98.8%
mul-1-neg98.8%
sub-neg98.8%
*-inverses98.8%
*-rgt-identity98.8%
log1p-def98.8%
mul-1-neg98.8%
Simplified98.8%
Final simplification98.7%
(FPCore (x y) :precision binary64 (if (<= y -5.8) (- 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 <= -5.8) {
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 <= -5.8) {
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 <= -5.8: 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 <= -5.8) 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, -5.8], 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 -5.8:\\
\;\;\;\;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 < -5.79999999999999982Initial program 24.3%
sub-neg24.3%
log1p-def24.3%
neg-sub024.3%
div-sub24.3%
associate--r-24.3%
neg-sub024.3%
+-commutative24.3%
sub-neg24.3%
div-sub24.3%
Simplified24.3%
Taylor expanded in x around 0 5.0%
log1p-def5.0%
Simplified5.0%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div68.0%
Simplified68.0%
if -5.79999999999999982 < 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 98.8%
div-sub98.8%
mul-1-neg98.8%
sub-neg98.8%
*-inverses98.8%
*-rgt-identity98.8%
log1p-def98.8%
mul-1-neg98.8%
Simplified98.8%
if 1 < y Initial program 46.2%
sub-neg46.2%
log1p-def46.2%
neg-sub046.2%
div-sub46.2%
associate--r-46.2%
neg-sub046.2%
+-commutative46.2%
sub-neg46.2%
div-sub46.2%
Simplified46.2%
Taylor expanded in y around inf 46.2%
Taylor expanded in x around inf 52.1%
Final simplification87.6%
(FPCore (x y) :precision binary64 (if (<= y -42000.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 0.08) (- 1.0 (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -42000.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 0.08) {
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 <= -42000.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 0.08) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -42000.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 0.08: 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 <= -42000.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 0.08) 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, -42000.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.08], 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 -42000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 0.08:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -42000Initial program 23.1%
sub-neg23.1%
log1p-def23.1%
neg-sub023.1%
div-sub23.2%
associate--r-23.2%
neg-sub023.2%
+-commutative23.2%
sub-neg23.2%
div-sub23.1%
Simplified23.1%
Taylor expanded in x around 0 5.1%
log1p-def5.1%
Simplified5.1%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.1%
Simplified69.1%
if -42000 < y < 0.0800000000000000017Initial 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 98.7%
log1p-def98.7%
mul-1-neg98.7%
Simplified98.7%
if 0.0800000000000000017 < y Initial program 51.5%
sub-neg51.5%
log1p-def51.6%
neg-sub051.6%
div-sub51.6%
associate--r-51.6%
neg-sub051.6%
+-commutative51.6%
sub-neg51.6%
div-sub51.6%
Simplified51.6%
Taylor expanded in y around inf 41.6%
Taylor expanded in x around inf 49.1%
Final simplification87.3%
(FPCore (x y) :precision binary64 (if (<= y -42000.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -42000.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 <= -42000.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 <= -42000.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 <= -42000.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, -42000.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 -42000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -42000Initial program 23.1%
sub-neg23.1%
log1p-def23.1%
neg-sub023.1%
div-sub23.2%
associate--r-23.2%
neg-sub023.2%
+-commutative23.2%
sub-neg23.2%
div-sub23.1%
Simplified23.1%
Taylor expanded in x around 0 5.1%
log1p-def5.1%
Simplified5.1%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.1%
Simplified69.1%
if -42000 < y Initial program 94.9%
sub-neg94.9%
log1p-def94.9%
neg-sub094.9%
div-sub94.9%
associate--r-94.9%
neg-sub094.9%
+-commutative94.9%
sub-neg94.9%
div-sub94.9%
Simplified94.9%
Taylor expanded in y around 0 88.6%
log1p-def88.6%
mul-1-neg88.6%
Simplified88.6%
Final simplification83.7%
(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 76.7%
sub-neg76.7%
log1p-def76.7%
neg-sub076.7%
div-sub76.7%
associate--r-76.7%
neg-sub076.7%
+-commutative76.7%
sub-neg76.7%
div-sub76.7%
Simplified76.7%
Taylor expanded in y around 0 69.3%
log1p-def69.3%
mul-1-neg69.3%
Simplified69.3%
Final simplification69.3%
(FPCore (x y) :precision binary64 (+ 1.0 (/ x (- 1.0 y))))
double code(double x, double y) {
return 1.0 + (x / (1.0 - y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + (x / (1.0d0 - y))
end function
public static double code(double x, double y) {
return 1.0 + (x / (1.0 - y));
}
def code(x, y): return 1.0 + (x / (1.0 - y))
function code(x, y) return Float64(1.0 + Float64(x / Float64(1.0 - y))) end
function tmp = code(x, y) tmp = 1.0 + (x / (1.0 - y)); end
code[x_, y_] := N[(1.0 + N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{x}{1 - y}
\end{array}
Initial program 76.7%
sub-neg76.7%
log1p-def76.7%
neg-sub076.7%
div-sub76.7%
associate--r-76.7%
neg-sub076.7%
+-commutative76.7%
sub-neg76.7%
div-sub76.7%
Simplified76.7%
Taylor expanded in x around inf 76.9%
neg-mul-176.9%
distribute-neg-frac76.9%
Simplified76.9%
Taylor expanded in x around 0 49.1%
Final simplification49.1%
(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 76.7%
sub-neg76.7%
log1p-def76.7%
neg-sub076.7%
div-sub76.7%
associate--r-76.7%
neg-sub076.7%
+-commutative76.7%
sub-neg76.7%
div-sub76.7%
Simplified76.7%
Taylor expanded in x around inf 76.9%
neg-mul-176.9%
distribute-neg-frac76.9%
Simplified76.9%
Taylor expanded in x around 0 47.3%
Final simplification47.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 2023195
(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))))))