
(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 11 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 -700000.0)
(-
1.0
(+ (log1p (- x)) (+ (log (/ -1.0 y)) (/ (+ x -1.0) (* y (+ x -1.0))))))
(if (<= y 4.7e+15)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(- 1.0 (- (log (+ x -1.0)) (log y))))))
double code(double x, double y) {
double tmp;
if (y <= -700000.0) {
tmp = 1.0 - (log1p(-x) + (log((-1.0 / y)) + ((x + -1.0) / (y * (x + -1.0)))));
} else if (y <= 4.7e+15) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - (log((x + -1.0)) - log(y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -700000.0) {
tmp = 1.0 - (Math.log1p(-x) + (Math.log((-1.0 / y)) + ((x + -1.0) / (y * (x + -1.0)))));
} else if (y <= 4.7e+15) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - (Math.log((x + -1.0)) - Math.log(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -700000.0: tmp = 1.0 - (math.log1p(-x) + (math.log((-1.0 / y)) + ((x + -1.0) / (y * (x + -1.0))))) elif y <= 4.7e+15: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - (math.log((x + -1.0)) - math.log(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -700000.0) tmp = Float64(1.0 - Float64(log1p(Float64(-x)) + Float64(log(Float64(-1.0 / y)) + Float64(Float64(x + -1.0) / Float64(y * Float64(x + -1.0)))))); elseif (y <= 4.7e+15) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - Float64(log(Float64(x + -1.0)) - log(y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -700000.0], N[(1.0 - N[(N[Log[1 + (-x)], $MachinePrecision] + N[(N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision] + N[(N[(x + -1.0), $MachinePrecision] / N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.7e+15], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -700000:\\
\;\;\;\;1 - \left(\mathsf{log1p}\left(-x\right) + \left(\log \left(\frac{-1}{y}\right) + \frac{x + -1}{y \cdot \left(x + -1\right)}\right)\right)\\
\mathbf{elif}\;y \leq 4.7 \cdot 10^{+15}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\
\end{array}
\end{array}
if y < -7e5Initial program 16.2%
sub-neg16.2%
log1p-def16.2%
distribute-neg-frac16.2%
sub-neg16.2%
distribute-neg-in16.2%
remove-double-neg16.2%
+-commutative16.2%
sub-neg16.2%
Simplified16.2%
Taylor expanded in y around -inf 99.3%
sub-neg99.3%
metadata-eval99.3%
distribute-lft-in99.3%
metadata-eval99.3%
+-commutative99.3%
log1p-def99.3%
mul-1-neg99.3%
mul-1-neg99.3%
unsub-neg99.3%
div-sub99.3%
associate-/l/99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
if -7e5 < y < 4.7e15Initial program 99.9%
sub-neg99.9%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if 4.7e15 < y Initial program 57.0%
sub-neg57.0%
log1p-def57.0%
distribute-neg-frac57.0%
sub-neg57.0%
distribute-neg-in57.0%
remove-double-neg57.0%
+-commutative57.0%
sub-neg57.0%
Simplified57.0%
Taylor expanded in y around inf 98.6%
log-rec98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification99.6%
(FPCore (x y)
:precision binary64
(if (<= y -6e+25)
(- 1.0 (log (/ -1.0 y)))
(if (<= y 3.9e+18)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(- 1.0 (- (log (+ x -1.0)) (log y))))))
double code(double x, double y) {
double tmp;
if (y <= -6e+25) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 3.9e+18) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - (log((x + -1.0)) - log(y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -6e+25) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 3.9e+18) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - (Math.log((x + -1.0)) - Math.log(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6e+25: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 3.9e+18: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - (math.log((x + -1.0)) - math.log(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -6e+25) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 3.9e+18) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - Float64(log(Float64(x + -1.0)) - log(y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -6e+25], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.9e+18], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+25}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{+18}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\
\end{array}
\end{array}
if y < -6.00000000000000011e25Initial program 14.4%
sub-neg14.4%
log1p-def14.4%
distribute-neg-frac14.4%
sub-neg14.4%
distribute-neg-in14.4%
remove-double-neg14.4%
+-commutative14.4%
sub-neg14.4%
Simplified14.4%
Taylor expanded in x around 0 2.9%
log1p-def2.9%
Simplified2.9%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div67.4%
Simplified67.4%
if -6.00000000000000011e25 < y < 3.9e18Initial program 99.6%
sub-neg99.6%
log1p-def99.7%
distribute-neg-frac99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
Simplified99.7%
if 3.9e18 < y Initial program 57.0%
sub-neg57.0%
log1p-def57.0%
distribute-neg-frac57.0%
sub-neg57.0%
distribute-neg-in57.0%
remove-double-neg57.0%
+-commutative57.0%
sub-neg57.0%
Simplified57.0%
Taylor expanded in y around inf 98.6%
log-rec98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification91.5%
(FPCore (x y)
:precision binary64
(if (<= y -14500000000.0)
(- (- 1.0 (log1p (- x))) (log (/ -1.0 y)))
(if (<= y 19000000000000.0)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(- 1.0 (- (log (+ x -1.0)) (log y))))))
double code(double x, double y) {
double tmp;
if (y <= -14500000000.0) {
tmp = (1.0 - log1p(-x)) - log((-1.0 / y));
} else if (y <= 19000000000000.0) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - (log((x + -1.0)) - log(y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -14500000000.0) {
tmp = (1.0 - Math.log1p(-x)) - Math.log((-1.0 / y));
} else if (y <= 19000000000000.0) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - (Math.log((x + -1.0)) - Math.log(y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -14500000000.0: tmp = (1.0 - math.log1p(-x)) - math.log((-1.0 / y)) elif y <= 19000000000000.0: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - (math.log((x + -1.0)) - math.log(y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -14500000000.0) tmp = Float64(Float64(1.0 - log1p(Float64(-x))) - log(Float64(-1.0 / y))); elseif (y <= 19000000000000.0) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - Float64(log(Float64(x + -1.0)) - log(y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -14500000000.0], N[(N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 19000000000000.0], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -14500000000:\\
\;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 19000000000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\
\end{array}
\end{array}
if y < -1.45e10Initial program 16.2%
sub-neg16.2%
log1p-def16.2%
distribute-neg-frac16.2%
sub-neg16.2%
distribute-neg-in16.2%
remove-double-neg16.2%
+-commutative16.2%
sub-neg16.2%
Simplified16.2%
Taylor expanded in y around -inf 99.1%
associate--r+99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-lft-in99.1%
metadata-eval99.1%
+-commutative99.1%
log1p-def99.1%
mul-1-neg99.1%
Simplified99.1%
if -1.45e10 < y < 1.9e13Initial program 99.9%
sub-neg99.9%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if 1.9e13 < y Initial program 57.0%
sub-neg57.0%
log1p-def57.0%
distribute-neg-frac57.0%
sub-neg57.0%
distribute-neg-in57.0%
remove-double-neg57.0%
+-commutative57.0%
sub-neg57.0%
Simplified57.0%
Taylor expanded in y around inf 98.6%
log-rec98.6%
unsub-neg98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification99.6%
(FPCore (x y)
:precision binary64
(if (<= y -6.8e+25)
(- 1.0 (log (/ -1.0 y)))
(if (<= y 7.6e+17)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(+ 1.0 (- (log y) (log x))))))
double code(double x, double y) {
double tmp;
if (y <= -6.8e+25) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 7.6e+17) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (log(y) - log(x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -6.8e+25) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 7.6e+17) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log(x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.8e+25: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 7.6e+17: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 + (math.log(y) - math.log(x)) return tmp
function code(x, y) tmp = 0.0 if (y <= -6.8e+25) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 7.6e+17) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 + Float64(log(y) - log(x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -6.8e+25], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.6e+17], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+25}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{+17}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log x\right)\\
\end{array}
\end{array}
if y < -6.79999999999999967e25Initial program 14.4%
sub-neg14.4%
log1p-def14.4%
distribute-neg-frac14.4%
sub-neg14.4%
distribute-neg-in14.4%
remove-double-neg14.4%
+-commutative14.4%
sub-neg14.4%
Simplified14.4%
Taylor expanded in x around 0 2.9%
log1p-def2.9%
Simplified2.9%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div67.4%
Simplified67.4%
if -6.79999999999999967e25 < y < 7.6e17Initial program 99.6%
sub-neg99.6%
log1p-def99.7%
distribute-neg-frac99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
Simplified99.7%
if 7.6e17 < y Initial program 57.0%
sub-neg57.0%
log1p-def57.0%
distribute-neg-frac57.0%
sub-neg57.0%
distribute-neg-in57.0%
remove-double-neg57.0%
+-commutative57.0%
sub-neg57.0%
Simplified57.0%
Taylor expanded in y around inf 57.0%
Taylor expanded in x around inf 95.3%
log-rec95.3%
+-commutative95.3%
unsub-neg95.3%
mul-1-neg95.3%
log-rec95.3%
remove-double-neg95.3%
Simplified95.3%
Final simplification91.1%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.99999999998) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (- 1.0 (log (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99999999998) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - log((-1.0 / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99999999998) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - Math.log((-1.0 / y));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.99999999998: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - math.log((-1.0 / y)) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.99999999998) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - 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.99999999998], 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[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.99999999998:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.99999999998Initial program 99.2%
sub-neg99.2%
log1p-def99.3%
distribute-neg-frac99.3%
sub-neg99.3%
distribute-neg-in99.3%
remove-double-neg99.3%
+-commutative99.3%
sub-neg99.3%
Simplified99.3%
if 0.99999999998 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 3.8%
sub-neg3.8%
log1p-def3.8%
distribute-neg-frac3.8%
sub-neg3.8%
distribute-neg-in3.8%
remove-double-neg3.8%
+-commutative3.8%
sub-neg3.8%
Simplified3.8%
Taylor expanded in x around 0 3.8%
log1p-def3.8%
Simplified3.8%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div62.0%
Simplified62.0%
Final simplification89.1%
(FPCore (x y) :precision binary64 (if (<= y -5.3) (- 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.3) {
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.3) {
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.3: 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.3) 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.3], 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.3:\\
\;\;\;\;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.29999999999999982Initial program 16.2%
sub-neg16.2%
log1p-def16.2%
distribute-neg-frac16.2%
sub-neg16.2%
distribute-neg-in16.2%
remove-double-neg16.2%
+-commutative16.2%
sub-neg16.2%
Simplified16.2%
Taylor expanded in x around 0 3.6%
log1p-def3.6%
Simplified3.6%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div66.4%
Simplified66.4%
if -5.29999999999999982 < y < 1Initial program 99.9%
sub-neg99.9%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 98.9%
+-commutative98.9%
div-sub98.9%
mul-1-neg98.9%
sub-neg98.9%
*-inverses98.9%
*-rgt-identity98.9%
log1p-def98.9%
mul-1-neg98.9%
Simplified98.9%
if 1 < y Initial program 57.0%
sub-neg57.0%
log1p-def57.0%
distribute-neg-frac57.0%
sub-neg57.0%
distribute-neg-in57.0%
remove-double-neg57.0%
+-commutative57.0%
sub-neg57.0%
Simplified57.0%
Taylor expanded in y around inf 57.0%
Taylor expanded in x around inf 55.4%
Final simplification85.3%
(FPCore (x y) :precision binary64 (if (<= y -9.5e+27) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ (- x) (- 1.0 y))))))
double code(double x, double y) {
double tmp;
if (y <= -9.5e+27) {
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 <= -9.5e+27) {
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 <= -9.5e+27: 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 <= -9.5e+27) 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, -9.5e+27], 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 -9.5 \cdot 10^{+27}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -9.4999999999999997e27Initial program 14.4%
sub-neg14.4%
log1p-def14.4%
distribute-neg-frac14.4%
sub-neg14.4%
distribute-neg-in14.4%
remove-double-neg14.4%
+-commutative14.4%
sub-neg14.4%
Simplified14.4%
Taylor expanded in x around 0 2.9%
log1p-def2.9%
Simplified2.9%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div67.4%
Simplified67.4%
if -9.4999999999999997e27 < y Initial program 92.7%
sub-neg92.7%
log1p-def92.8%
distribute-neg-frac92.8%
sub-neg92.8%
distribute-neg-in92.8%
remove-double-neg92.8%
+-commutative92.8%
sub-neg92.8%
Simplified92.8%
Taylor expanded in x around inf 91.0%
neg-mul-191.0%
distribute-neg-frac91.0%
Simplified91.0%
Final simplification85.1%
(FPCore (x y) :precision binary64 (if (<= y -9.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 2.1e-8) (- 1.0 (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -9.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 2.1e-8) {
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 <= -9.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 2.1e-8) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -9.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 2.1e-8: 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 <= -9.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 2.1e-8) 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, -9.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.1e-8], 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 -9:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -9Initial program 16.2%
sub-neg16.2%
log1p-def16.2%
distribute-neg-frac16.2%
sub-neg16.2%
distribute-neg-in16.2%
remove-double-neg16.2%
+-commutative16.2%
sub-neg16.2%
Simplified16.2%
Taylor expanded in x around 0 3.6%
log1p-def3.6%
Simplified3.6%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div66.4%
Simplified66.4%
if -9 < y < 2.09999999999999994e-8Initial program 99.9%
sub-neg99.9%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 98.2%
log1p-def98.2%
mul-1-neg98.2%
Simplified98.2%
if 2.09999999999999994e-8 < y Initial program 59.5%
sub-neg59.5%
log1p-def59.6%
distribute-neg-frac59.6%
sub-neg59.6%
distribute-neg-in59.6%
remove-double-neg59.6%
+-commutative59.6%
sub-neg59.6%
Simplified59.6%
Taylor expanded in y around inf 53.5%
Taylor expanded in x around inf 54.9%
Final simplification84.4%
(FPCore (x y) :precision binary64 (if (<= y -30.5) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -30.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 <= -30.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 <= -30.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 <= -30.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, -30.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 -30.5:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -30.5Initial program 16.2%
sub-neg16.2%
log1p-def16.2%
distribute-neg-frac16.2%
sub-neg16.2%
distribute-neg-in16.2%
remove-double-neg16.2%
+-commutative16.2%
sub-neg16.2%
Simplified16.2%
Taylor expanded in x around 0 3.6%
log1p-def3.6%
Simplified3.6%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div66.4%
Simplified66.4%
if -30.5 < y Initial program 92.9%
sub-neg92.9%
log1p-def93.0%
distribute-neg-frac93.0%
sub-neg93.0%
distribute-neg-in93.0%
remove-double-neg93.0%
+-commutative93.0%
sub-neg93.0%
Simplified93.0%
Taylor expanded in y around 0 81.6%
log1p-def81.6%
mul-1-neg81.6%
Simplified81.6%
Final simplification77.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 73.1%
sub-neg73.1%
log1p-def73.2%
distribute-neg-frac73.2%
sub-neg73.2%
distribute-neg-in73.2%
remove-double-neg73.2%
+-commutative73.2%
sub-neg73.2%
Simplified73.2%
Taylor expanded in y around 0 63.5%
log1p-def63.5%
mul-1-neg63.5%
Simplified63.5%
Final simplification63.5%
(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.1%
sub-neg73.1%
log1p-def73.2%
distribute-neg-frac73.2%
sub-neg73.2%
distribute-neg-in73.2%
remove-double-neg73.2%
+-commutative73.2%
sub-neg73.2%
Simplified73.2%
Taylor expanded in x around 0 45.2%
log1p-def45.2%
Simplified45.2%
Taylor expanded in y around 0 45.2%
Final simplification45.2%
(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 2023333
(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))))))