
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
double code(double x, double y) {
return 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - log((1.0d0 - ((x - y) / (1.0d0 - y))))
end function
public static double code(double x, double y) {
return 1.0 - Math.log((1.0 - ((x - y) / (1.0 - y))));
}
def code(x, y): return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
function code(x, y) return Float64(1.0 - log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))))) end
function tmp = code(x, y) tmp = 1.0 - log((1.0 - ((x - y) / (1.0 - y)))); end
code[x_, y_] := N[(1.0 - N[Log[N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))
double code(double x, double y) {
return 1.0 - log((1.0 - ((x - y) / (1.0 - y))));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - log((1.0d0 - ((x - y) / (1.0d0 - y))))
end function
public static double code(double x, double y) {
return 1.0 - Math.log((1.0 - ((x - y) / (1.0 - y))));
}
def code(x, y): return 1.0 - math.log((1.0 - ((x - y) / (1.0 - y))))
function code(x, y) return Float64(1.0 - log(Float64(1.0 - Float64(Float64(x - y) / Float64(1.0 - y))))) end
function tmp = code(x, y) tmp = 1.0 - log((1.0 - ((x - y) / (1.0 - y)))); end
code[x_, y_] := N[(1.0 - N[Log[N[(1.0 - N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \log \left(1 - \frac{x - y}{1 - y}\right)
\end{array}
(FPCore (x y) :precision binary64 (log (- (/ E (- 1.0 x)) (/ E (/ (- 1.0 x) y)))))
double code(double x, double y) {
return log(((((double) M_E) / (1.0 - x)) - (((double) M_E) / ((1.0 - x) / y))));
}
public static double code(double x, double y) {
return Math.log(((Math.E / (1.0 - x)) - (Math.E / ((1.0 - x) / y))));
}
def code(x, y): return math.log(((math.e / (1.0 - x)) - (math.e / ((1.0 - x) / y))))
function code(x, y) return log(Float64(Float64(exp(1) / Float64(1.0 - x)) - Float64(exp(1) / Float64(Float64(1.0 - x) / y)))) end
function tmp = code(x, y) tmp = log(((2.71828182845904523536 / (1.0 - x)) - (2.71828182845904523536 / ((1.0 - x) / y)))); end
code[x_, y_] := N[Log[N[(N[(E / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] - N[(E / N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(\frac{e}{1 - x} - \frac{e}{\frac{1 - x}{y}}\right)
\end{array}
Initial program 71.0%
sub-neg71.0%
log1p-def71.1%
neg-sub071.1%
div-sub71.1%
associate--r-71.1%
neg-sub071.1%
+-commutative71.1%
sub-neg71.1%
div-sub71.1%
Simplified71.1%
add-log-exp71.1%
exp-diff71.0%
exp-1-e71.0%
log1p-udef71.0%
add-exp-log71.0%
Applied egg-rr71.0%
Taylor expanded in y around 0 83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
associate-/l*83.1%
sub-neg83.1%
neg-mul-183.1%
unpow283.1%
*-commutative83.1%
times-frac100.0%
*-inverses100.0%
neg-mul-1100.0%
sub-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.9) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (log (/ E (+ (/ (+ x -1.0) (* y y)) (/ (+ x -1.0) y))))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.9) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = log((((double) M_E) / (((x + -1.0) / (y * y)) + ((x + -1.0) / y))));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.9) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = Math.log((Math.E / (((x + -1.0) / (y * y)) + ((x + -1.0) / y))));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.9: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = math.log((math.e / (((x + -1.0) / (y * y)) + ((x + -1.0) / y)))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.9) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = log(Float64(exp(1) / Float64(Float64(Float64(x + -1.0) / Float64(y * y)) + 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], 0.9], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[N[(E / N[(N[(N[(x + -1.0), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.9:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{e}{\frac{x + -1}{y \cdot y} + \frac{x + -1}{y}}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.900000000000000022Initial 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 0.900000000000000022 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 8.6%
sub-neg8.6%
log1p-def8.6%
neg-sub08.6%
div-sub8.7%
associate--r-8.7%
neg-sub08.7%
+-commutative8.7%
sub-neg8.7%
div-sub8.6%
Simplified8.6%
add-log-exp8.6%
exp-diff8.6%
exp-1-e8.6%
log1p-udef8.6%
add-exp-log8.6%
Applied egg-rr8.6%
Taylor expanded in y around -inf 99.6%
+-commutative99.6%
associate--l+99.6%
associate-*r/99.6%
sub-neg99.6%
neg-mul-199.6%
mul-1-neg99.6%
neg-mul-199.6%
sub-neg99.6%
unpow299.6%
div-sub99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.99998) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (- 1.0 (log (* (- 1.0 x) (/ -1.0 y))))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99998) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - log(((1.0 - x) * (-1.0 / y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99998) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - Math.log(((1.0 - x) * (-1.0 / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.99998: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - math.log(((1.0 - x) * (-1.0 / y))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.99998) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - log(Float64(Float64(1.0 - x) * 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.99998], 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[(1.0 - x), $MachinePrecision] * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.99998:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\left(1 - x\right) \cdot \frac{-1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.99997999999999998Initial program 99.7%
sub-neg99.7%
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.99997999999999998 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 5.6%
sub-neg5.6%
log1p-def5.6%
neg-sub05.6%
div-sub5.6%
associate--r-5.6%
neg-sub05.6%
+-commutative5.6%
sub-neg5.6%
div-sub5.6%
Simplified5.6%
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%
Simplified86.8%
Taylor expanded in y around 0 0.0%
mul-1-neg0.0%
log-rec0.0%
associate-+r+0.0%
log-rec0.0%
unsub-neg0.0%
+-commutative0.0%
sub-neg0.0%
log1p-def0.0%
associate-+r-0.0%
log-div86.8%
rem-log-exp86.8%
exp-sum86.8%
neg-mul-186.8%
log1p-def86.8%
rem-exp-log86.8%
neg-mul-186.8%
sub-neg86.8%
rem-exp-log100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (or (<= y -1.6) (not (<= y 1.0))) (- 1.0 (log (* (- 1.0 x) (/ -1.0 y)))) (- 1.0 (+ y (log1p (- x))))))
double code(double x, double y) {
double tmp;
if ((y <= -1.6) || !(y <= 1.0)) {
tmp = 1.0 - log(((1.0 - 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.6) || !(y <= 1.0)) {
tmp = 1.0 - Math.log(((1.0 - x) * (-1.0 / y)));
} else {
tmp = 1.0 - (y + Math.log1p(-x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.6) or not (y <= 1.0): tmp = 1.0 - math.log(((1.0 - x) * (-1.0 / y))) else: tmp = 1.0 - (y + math.log1p(-x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.6) || !(y <= 1.0)) tmp = Float64(1.0 - log(Float64(Float64(1.0 - x) * Float64(-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.6], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(1.0 - N[Log[N[(N[(1.0 - x), $MachinePrecision] * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;1 - \log \left(\left(1 - x\right) \cdot \frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\end{array}
\end{array}
if y < -1.6000000000000001 or 1 < y Initial program 35.1%
sub-neg35.1%
log1p-def35.1%
neg-sub035.1%
div-sub35.1%
associate--r-35.1%
neg-sub035.1%
+-commutative35.1%
sub-neg35.1%
div-sub35.1%
Simplified35.1%
Taylor expanded in y around -inf 66.9%
sub-neg66.9%
metadata-eval66.9%
distribute-lft-in66.9%
metadata-eval66.9%
+-commutative66.9%
log1p-def66.9%
mul-1-neg66.9%
Simplified66.9%
Taylor expanded in y around 0 0.0%
mul-1-neg0.0%
log-rec0.0%
associate-+r+0.0%
log-rec0.0%
unsub-neg0.0%
+-commutative0.0%
sub-neg0.0%
log1p-def0.0%
associate-+r-0.0%
log-div66.9%
rem-log-exp66.9%
exp-sum66.9%
neg-mul-166.9%
log1p-def66.9%
rem-exp-log67.0%
neg-mul-167.0%
sub-neg67.0%
rem-exp-log98.0%
Simplified98.0%
if -1.6000000000000001 < y < 1Initial 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%
Taylor expanded in y around 0 98.7%
div-sub98.7%
mul-1-neg98.7%
sub-neg98.7%
*-inverses98.7%
*-rgt-identity98.7%
log1p-def98.7%
mul-1-neg98.7%
Simplified98.7%
Final simplification98.4%
(FPCore (x y) :precision binary64 (if (<= y -7.2) (- 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 <= -7.2) {
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 <= -7.2) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - (y + Math.log1p(-x));
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7.2: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - (y + math.log1p(-x)) else: tmp = 1.0 - math.log1p((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -7.2) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); else tmp = Float64(1.0 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -7.2], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -7.20000000000000018Initial program 17.5%
sub-neg17.5%
log1p-def17.5%
neg-sub017.5%
div-sub17.5%
associate--r-17.5%
neg-sub017.5%
+-commutative17.5%
sub-neg17.5%
div-sub17.5%
Simplified17.5%
Taylor expanded in y around -inf 97.8%
sub-neg97.8%
metadata-eval97.8%
distribute-lft-in97.8%
metadata-eval97.8%
+-commutative97.8%
log1p-def97.8%
mul-1-neg97.8%
Simplified97.8%
Taylor expanded in x around 0 69.3%
if -7.20000000000000018 < y < 1Initial 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%
Taylor expanded in y around 0 98.7%
div-sub98.7%
mul-1-neg98.7%
sub-neg98.7%
*-inverses98.7%
*-rgt-identity98.7%
log1p-def98.7%
mul-1-neg98.7%
Simplified98.7%
if 1 < y Initial program 73.2%
sub-neg73.2%
log1p-def73.2%
neg-sub073.2%
div-sub73.2%
associate--r-73.2%
neg-sub073.2%
+-commutative73.2%
sub-neg73.2%
div-sub73.2%
Simplified73.2%
Taylor expanded in x around inf 68.4%
neg-mul-168.4%
distribute-neg-frac68.4%
Simplified68.4%
Taylor expanded in y around inf 65.8%
Final simplification85.1%
(FPCore (x y) :precision binary64 (if (<= y -7.2) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- (/ x (- 1.0 y)))))))
double code(double x, double y) {
double tmp;
if (y <= -7.2) {
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 <= -7.2) {
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 <= -7.2: 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 <= -7.2) 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, -7.2], 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 -7.2:\\
\;\;\;\;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.20000000000000018Initial program 17.5%
sub-neg17.5%
log1p-def17.5%
neg-sub017.5%
div-sub17.5%
associate--r-17.5%
neg-sub017.5%
+-commutative17.5%
sub-neg17.5%
div-sub17.5%
Simplified17.5%
Taylor expanded in y around -inf 97.8%
sub-neg97.8%
metadata-eval97.8%
distribute-lft-in97.8%
metadata-eval97.8%
+-commutative97.8%
log1p-def97.8%
mul-1-neg97.8%
Simplified97.8%
Taylor expanded in x around 0 69.3%
if -7.20000000000000018 < y Initial program 94.5%
sub-neg94.5%
log1p-def94.6%
neg-sub094.6%
div-sub94.6%
associate--r-94.6%
neg-sub094.6%
+-commutative94.6%
sub-neg94.6%
div-sub94.6%
Simplified94.6%
Taylor expanded in x around inf 91.5%
neg-mul-191.5%
distribute-neg-frac91.5%
Simplified91.5%
Final simplification84.7%
(FPCore (x y) :precision binary64 (if (<= y -4.9) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.5e-7) (- 1.0 (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -4.9) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.5e-7) {
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 <= -4.9) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 1.5e-7) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.9: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.5e-7: 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 <= -4.9) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.5e-7) 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, -4.9], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e-7], 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 -4.9:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{-7}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -4.9000000000000004Initial program 17.5%
sub-neg17.5%
log1p-def17.5%
neg-sub017.5%
div-sub17.5%
associate--r-17.5%
neg-sub017.5%
+-commutative17.5%
sub-neg17.5%
div-sub17.5%
Simplified17.5%
Taylor expanded in y around -inf 97.8%
sub-neg97.8%
metadata-eval97.8%
distribute-lft-in97.8%
metadata-eval97.8%
+-commutative97.8%
log1p-def97.8%
mul-1-neg97.8%
Simplified97.8%
Taylor expanded in x around 0 69.3%
if -4.9000000000000004 < y < 1.4999999999999999e-7Initial 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%
Taylor expanded in y around 0 98.2%
log1p-def98.2%
mul-1-neg98.2%
Simplified98.2%
if 1.4999999999999999e-7 < y Initial program 74.6%
sub-neg74.6%
log1p-def74.7%
neg-sub074.7%
div-sub74.6%
associate--r-74.6%
neg-sub074.6%
+-commutative74.6%
sub-neg74.6%
div-sub74.7%
Simplified74.7%
Taylor expanded in x around inf 66.9%
neg-mul-166.9%
distribute-neg-frac66.9%
Simplified66.9%
Taylor expanded in y around inf 64.4%
Final simplification84.4%
(FPCore (x y) :precision binary64 (if (<= y -6.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log x)))))
double code(double x, double y) {
double tmp;
if (y <= -6.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log(x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -6.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.log(x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log(x) return tmp
function code(x, y) tmp = 0.0 if (y <= -6.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 - log(x)); end return tmp end
code[x_, y_] := If[LessEqual[y, -6.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[x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log x\\
\end{array}
\end{array}
if y < -6Initial program 17.5%
sub-neg17.5%
log1p-def17.5%
neg-sub017.5%
div-sub17.5%
associate--r-17.5%
neg-sub017.5%
+-commutative17.5%
sub-neg17.5%
div-sub17.5%
Simplified17.5%
Taylor expanded in y around -inf 97.8%
sub-neg97.8%
metadata-eval97.8%
distribute-lft-in97.8%
metadata-eval97.8%
+-commutative97.8%
log1p-def97.8%
mul-1-neg97.8%
Simplified97.8%
Taylor expanded in x around 0 69.3%
if -6 < y < 1Initial 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%
Taylor expanded in y around 0 97.4%
log1p-def97.4%
mul-1-neg97.4%
Simplified97.4%
if 1 < y Initial program 73.2%
sub-neg73.2%
log1p-def73.2%
neg-sub073.2%
div-sub73.2%
associate--r-73.2%
neg-sub073.2%
+-commutative73.2%
sub-neg73.2%
div-sub73.2%
Simplified73.2%
Taylor expanded in y around 0 0.0%
log1p-def0.0%
mul-1-neg0.0%
Simplified0.0%
Taylor expanded in x around inf 0.0%
+-commutative0.0%
mul-1-neg0.0%
log-rec0.0%
remove-double-neg0.0%
log-prod0.0%
neg-mul-10.0%
Simplified0.0%
sub-neg0.0%
add-sqr-sqrt0.0%
sqrt-unprod4.1%
sqr-neg4.1%
sqrt-unprod12.7%
add-sqr-sqrt12.7%
Applied egg-rr12.7%
sub-neg12.7%
Simplified12.7%
Final simplification76.9%
(FPCore (x y) :precision binary64 (if (<= x -0.82) (- 1.0 (log (- x))) (+ 1.0 x)))
double code(double x, double y) {
double tmp;
if (x <= -0.82) {
tmp = 1.0 - log(-x);
} else {
tmp = 1.0 + x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.82d0)) then
tmp = 1.0d0 - log(-x)
else
tmp = 1.0d0 + x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.82) {
tmp = 1.0 - Math.log(-x);
} else {
tmp = 1.0 + x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.82: tmp = 1.0 - math.log(-x) else: tmp = 1.0 + x return tmp
function code(x, y) tmp = 0.0 if (x <= -0.82) tmp = Float64(1.0 - log(Float64(-x))); else tmp = Float64(1.0 + x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.82) tmp = 1.0 - log(-x); else tmp = 1.0 + x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.82], N[(1.0 - N[Log[(-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.82:\\
\;\;\;\;1 - \log \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 + x\\
\end{array}
\end{array}
if x < -0.819999999999999951Initial program 80.0%
sub-neg80.0%
log1p-def80.0%
neg-sub080.0%
div-sub80.0%
associate--r-80.0%
neg-sub080.0%
+-commutative80.0%
sub-neg80.0%
div-sub80.0%
Simplified80.0%
Taylor expanded in y around 0 70.1%
log1p-def70.1%
mul-1-neg70.1%
Simplified70.1%
Taylor expanded in x around inf 0.0%
+-commutative0.0%
mul-1-neg0.0%
log-rec0.0%
remove-double-neg0.0%
log-prod69.0%
neg-mul-169.0%
Simplified69.0%
if -0.819999999999999951 < x Initial program 66.9%
sub-neg66.9%
log1p-def66.9%
neg-sub066.9%
div-sub66.9%
associate--r-66.9%
neg-sub066.9%
+-commutative66.9%
sub-neg66.9%
div-sub66.9%
Simplified66.9%
Taylor expanded in y around 0 51.8%
log1p-def51.8%
mul-1-neg51.8%
Simplified51.8%
Taylor expanded in x around 0 52.1%
Final simplification57.4%
(FPCore (x y) :precision binary64 (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log x))))
double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log(x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log(x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log(x) return tmp
function code(x, y) tmp = 0.0 if (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = Float64(1.0 - log(x)); end return tmp end
code[x_, y_] := If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log x\\
\end{array}
\end{array}
if y < 1Initial program 70.7%
sub-neg70.7%
log1p-def70.7%
neg-sub070.7%
div-sub70.7%
associate--r-70.7%
neg-sub070.7%
+-commutative70.7%
sub-neg70.7%
div-sub70.7%
Simplified70.7%
Taylor expanded in y around 0 67.0%
log1p-def67.0%
mul-1-neg67.0%
Simplified67.0%
if 1 < y Initial program 73.2%
sub-neg73.2%
log1p-def73.2%
neg-sub073.2%
div-sub73.2%
associate--r-73.2%
neg-sub073.2%
+-commutative73.2%
sub-neg73.2%
div-sub73.2%
Simplified73.2%
Taylor expanded in y around 0 0.0%
log1p-def0.0%
mul-1-neg0.0%
Simplified0.0%
Taylor expanded in x around inf 0.0%
+-commutative0.0%
mul-1-neg0.0%
log-rec0.0%
remove-double-neg0.0%
log-prod0.0%
neg-mul-10.0%
Simplified0.0%
sub-neg0.0%
add-sqr-sqrt0.0%
sqrt-unprod4.1%
sqr-neg4.1%
sqrt-unprod12.7%
add-sqr-sqrt12.7%
Applied egg-rr12.7%
sub-neg12.7%
Simplified12.7%
Final simplification59.4%
(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 71.0%
sub-neg71.0%
log1p-def71.1%
neg-sub071.1%
div-sub71.1%
associate--r-71.1%
neg-sub071.1%
+-commutative71.1%
sub-neg71.1%
div-sub71.1%
Simplified71.1%
Taylor expanded in y around 0 57.6%
log1p-def57.6%
mul-1-neg57.6%
Simplified57.6%
Taylor expanded in x around 0 37.0%
Final simplification37.0%
(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 71.0%
sub-neg71.0%
log1p-def71.1%
neg-sub071.1%
div-sub71.1%
associate--r-71.1%
neg-sub071.1%
+-commutative71.1%
sub-neg71.1%
div-sub71.1%
Simplified71.1%
Taylor expanded in y around 0 57.6%
log1p-def57.6%
mul-1-neg57.6%
Simplified57.6%
Taylor expanded in x around 0 36.9%
Final simplification36.9%
(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 2023192
(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))))))