
(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 -2900000000.0)
(- (- 1.0 (log1p (- x))) (log (/ -1.0 y)))
(if (<= y 9.8e+70)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -2900000000.0) {
tmp = (1.0 - log1p(-x)) - log((-1.0 / y));
} else if (y <= 9.8e+70) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -2900000000.0) {
tmp = (1.0 - Math.log1p(-x)) - Math.log((-1.0 / y));
} else if (y <= 9.8e+70) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2900000000.0: tmp = (1.0 - math.log1p(-x)) - math.log((-1.0 / y)) elif y <= 9.8e+70: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -2900000000.0) tmp = Float64(Float64(1.0 - log1p(Float64(-x))) - log(Float64(-1.0 / y))); elseif (y <= 9.8e+70) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -2900000000.0], N[(N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.8e+70], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2900000000:\\
\;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{+70}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if y < -2.9e9Initial program 18.6%
sub-neg18.6%
log1p-define18.6%
distribute-neg-frac218.6%
neg-sub018.6%
associate--r-18.6%
metadata-eval18.6%
+-commutative18.6%
Simplified18.6%
Taylor expanded in y around -inf 99.5%
associate--r+99.5%
sub-neg99.5%
metadata-eval99.5%
distribute-lft-in99.5%
metadata-eval99.5%
+-commutative99.5%
log1p-define99.5%
mul-1-neg99.5%
Simplified99.5%
if -2.9e9 < y < 9.80000000000000056e70Initial program 100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if 9.80000000000000056e70 < y Initial program 35.6%
sub-neg35.6%
log1p-define35.6%
distribute-neg-frac235.6%
neg-sub035.6%
associate--r-35.6%
metadata-eval35.6%
+-commutative35.6%
Simplified35.6%
Taylor expanded in y around inf 98.3%
log-rec98.3%
unsub-neg98.3%
sub-neg98.3%
metadata-eval98.3%
Simplified98.3%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ E (- 1.0 x))))
(if (<= (/ (- x y) (- 1.0 y)) 5e-5)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(log1p
(+ t_0 (fma (* y t_0) (+ (/ x (- 1.0 x)) (/ 1.0 (+ x -1.0))) -1.0))))))
double code(double x, double y) {
double t_0 = ((double) M_E) / (1.0 - x);
double tmp;
if (((x - y) / (1.0 - y)) <= 5e-5) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = log1p((t_0 + fma((y * t_0), ((x / (1.0 - x)) + (1.0 / (x + -1.0))), -1.0)));
}
return tmp;
}
function code(x, y) t_0 = Float64(exp(1) / Float64(1.0 - x)) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 5e-5) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = log1p(Float64(t_0 + fma(Float64(y * t_0), Float64(Float64(x / Float64(1.0 - x)) + Float64(1.0 / Float64(x + -1.0))), -1.0))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(E / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 5e-5], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(t$95$0 + N[(N[(y * t$95$0), $MachinePrecision] * N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{e}{1 - x}\\
\mathbf{if}\;\frac{x - y}{1 - y} \leq 5 \cdot 10^{-5}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(t\_0 + \mathsf{fma}\left(y \cdot t\_0, \frac{x}{1 - x} + \frac{1}{x + -1}, -1\right)\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 5.00000000000000024e-5Initial program 100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if 5.00000000000000024e-5 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 6.0%
sub-neg6.0%
log1p-define6.0%
distribute-neg-frac26.0%
neg-sub06.0%
associate--r-6.0%
metadata-eval6.0%
+-commutative6.0%
Simplified6.0%
log1p-expm1-u6.0%
Applied egg-rr6.0%
Taylor expanded in y around 0 78.3%
associate--l+78.3%
exp-diff78.3%
exp-1-e78.3%
rem-exp-log78.3%
mul-1-neg78.3%
sub-neg78.3%
associate-*r*78.3%
fma-neg78.3%
Simplified98.8%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 1.0) (- 1.0 (log1p (* x (/ (- 1.0 (/ y x)) (+ y -1.0))))) (- 1.0 (log (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 1.0) {
tmp = 1.0 - log1p((x * ((1.0 - (y / x)) / (y + -1.0))));
} 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)) <= 1.0) {
tmp = 1.0 - Math.log1p((x * ((1.0 - (y / x)) / (y + -1.0))));
} else {
tmp = 1.0 - Math.log((-1.0 / y));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 1.0: tmp = 1.0 - math.log1p((x * ((1.0 - (y / x)) / (y + -1.0)))) 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)) <= 1.0) tmp = Float64(1.0 - log1p(Float64(x * Float64(Float64(1.0 - Float64(y / x)) / Float64(y + -1.0))))); 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], 1.0], N[(1.0 - N[Log[1 + N[(x * N[(N[(1.0 - N[(y / x), $MachinePrecision]), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $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 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(x \cdot \frac{1 - \frac{y}{x}}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 1Initial program 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
clear-num71.0%
associate-/r/71.4%
Applied egg-rr71.4%
Taylor expanded in x around inf 72.1%
+-commutative72.1%
sub-neg72.1%
metadata-eval72.1%
+-commutative72.1%
mul-1-neg72.1%
unsub-neg72.1%
associate-/r*71.2%
sub-neg71.2%
metadata-eval71.2%
+-commutative71.2%
Simplified71.2%
Taylor expanded in x around inf 72.1%
+-commutative72.1%
sub-neg72.1%
metadata-eval72.1%
+-commutative72.1%
mul-1-neg72.1%
*-commutative72.1%
sub-neg72.1%
metadata-eval72.1%
+-commutative72.1%
sub-neg72.1%
+-commutative72.1%
metadata-eval72.1%
sub-neg72.1%
*-commutative72.1%
associate-/r*71.2%
sub-neg71.2%
metadata-eval71.2%
+-commutative71.2%
div-sub71.2%
Simplified71.2%
if 1 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
Taylor expanded in x around 0 41.3%
sub-neg41.3%
metadata-eval41.3%
neg-mul-141.3%
distribute-neg-frac41.3%
Simplified41.3%
Taylor expanded in y around -inf 21.9%
Final simplification71.2%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 1.0) (- 1.0 (log1p (* (- x y) (/ 1.0 (+ y -1.0))))) (- 1.0 (log (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 1.0) {
tmp = 1.0 - log1p(((x - y) * (1.0 / (y + -1.0))));
} 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)) <= 1.0) {
tmp = 1.0 - Math.log1p(((x - y) * (1.0 / (y + -1.0))));
} else {
tmp = 1.0 - Math.log((-1.0 / y));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 1.0: tmp = 1.0 - math.log1p(((x - y) * (1.0 / (y + -1.0)))) 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)) <= 1.0) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) * Float64(1.0 / Float64(y + -1.0))))); 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], 1.0], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] * N[(1.0 / N[(y + -1.0), $MachinePrecision]), $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 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(\left(x - y\right) \cdot \frac{1}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 1Initial program 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
clear-num71.0%
associate-/r/71.4%
Applied egg-rr71.4%
if 1 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
Taylor expanded in x around 0 41.3%
sub-neg41.3%
metadata-eval41.3%
neg-mul-141.3%
distribute-neg-frac41.3%
Simplified41.3%
Taylor expanded in y around -inf 21.9%
Final simplification71.4%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 1.0) (- 1.0 (log1p (/ (- x y) (+ y -1.0)))) (- 1.0 (log (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 1.0) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} 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)) <= 1.0) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - Math.log((-1.0 / y));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 1.0: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) 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)) <= 1.0) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); 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], 1.0], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $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 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 1Initial program 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
if 1 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
Taylor expanded in x around 0 41.3%
sub-neg41.3%
metadata-eval41.3%
neg-mul-141.3%
distribute-neg-frac41.3%
Simplified41.3%
Taylor expanded in y around -inf 21.9%
Final simplification71.0%
(FPCore (x y) :precision binary64 (if (<= y -1.25e+30) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ x (+ y -1.0))))))
double code(double x, double y) {
double tmp;
if (y <= -1.25e+30) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p((x / (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1.25e+30) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.25e+30: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p((x / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.25e+30) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.25e+30], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+30}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\end{array}
\end{array}
if y < -1.25e30Initial program 16.6%
sub-neg16.6%
log1p-define16.6%
distribute-neg-frac216.6%
neg-sub016.6%
associate--r-16.6%
metadata-eval16.6%
+-commutative16.6%
Simplified16.6%
Taylor expanded in x around 0 2.8%
sub-neg2.8%
metadata-eval2.8%
neg-mul-12.8%
distribute-neg-frac2.8%
Simplified2.8%
Taylor expanded in y around -inf 69.6%
if -1.25e30 < y Initial program 91.0%
sub-neg91.0%
log1p-define91.0%
distribute-neg-frac291.0%
neg-sub091.0%
associate--r-91.0%
metadata-eval91.0%
+-commutative91.0%
Simplified91.0%
Taylor expanded in x around inf 89.1%
Final simplification83.8%
(FPCore (x y) :precision binary64 (if (<= y -5.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (+ y (log1p (- x))))))
double code(double x, double y) {
double tmp;
if (y <= -5.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 <= -5.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 <= -5.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 <= -5.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -5.0], N[(1.0 - N[Log[N[(-1.0 / 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 -5:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\end{array}
\end{array}
if y < -5Initial program 18.6%
sub-neg18.6%
log1p-define18.6%
distribute-neg-frac218.6%
neg-sub018.6%
associate--r-18.6%
metadata-eval18.6%
+-commutative18.6%
Simplified18.6%
Taylor expanded in x around 0 2.8%
sub-neg2.8%
metadata-eval2.8%
neg-mul-12.8%
distribute-neg-frac2.8%
Simplified2.8%
Taylor expanded in y around -inf 68.5%
if -5 < y Initial program 91.9%
sub-neg91.9%
log1p-define91.9%
distribute-neg-frac291.9%
neg-sub091.9%
associate--r-91.9%
metadata-eval91.9%
+-commutative91.9%
Simplified91.9%
Taylor expanded in y around 0 82.0%
+-commutative82.0%
div-sub82.0%
*-commutative82.0%
mul-1-neg82.0%
sub-neg82.0%
*-inverses82.0%
metadata-eval82.0%
distribute-lft-neg-in82.0%
neg-mul-182.0%
remove-double-neg82.0%
log1p-define82.0%
mul-1-neg82.0%
Simplified82.0%
Final simplification78.2%
(FPCore (x y) :precision binary64 (if (<= y -155.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -155.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 <= -155.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 <= -155.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 <= -155.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, -155.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 -155:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -155Initial program 18.6%
sub-neg18.6%
log1p-define18.6%
distribute-neg-frac218.6%
neg-sub018.6%
associate--r-18.6%
metadata-eval18.6%
+-commutative18.6%
Simplified18.6%
Taylor expanded in x around 0 2.8%
sub-neg2.8%
metadata-eval2.8%
neg-mul-12.8%
distribute-neg-frac2.8%
Simplified2.8%
Taylor expanded in y around -inf 68.5%
if -155 < y Initial program 91.9%
sub-neg91.9%
log1p-define91.9%
distribute-neg-frac291.9%
neg-sub091.9%
associate--r-91.9%
metadata-eval91.9%
+-commutative91.9%
Simplified91.9%
Taylor expanded in y around 0 80.8%
log1p-define80.8%
mul-1-neg80.8%
Simplified80.8%
Final simplification77.3%
(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 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
Taylor expanded in y around 0 61.3%
log1p-define61.3%
mul-1-neg61.3%
Simplified61.3%
Final simplification61.3%
(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 71.0%
sub-neg71.0%
log1p-define71.0%
distribute-neg-frac271.0%
neg-sub071.0%
associate--r-71.0%
metadata-eval71.0%
+-commutative71.0%
Simplified71.0%
Taylor expanded in x around 0 41.3%
sub-neg41.3%
metadata-eval41.3%
neg-mul-141.3%
distribute-neg-frac41.3%
Simplified41.3%
Taylor expanded in y around 0 40.8%
Final simplification40.8%
(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 2024055
(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))))))