
(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 15 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 (let* ((t_0 (/ E (- 1.0 x)))) (log (fma y (* (+ (/ x (- 1.0 x)) (/ -1.0 (- 1.0 x))) t_0) t_0))))
double code(double x, double y) {
double t_0 = ((double) M_E) / (1.0 - x);
return log(fma(y, (((x / (1.0 - x)) + (-1.0 / (1.0 - x))) * t_0), t_0));
}
function code(x, y) t_0 = Float64(exp(1) / Float64(1.0 - x)) return log(fma(y, Float64(Float64(Float64(x / Float64(1.0 - x)) + Float64(-1.0 / Float64(1.0 - x))) * t_0), t_0)) end
code[x_, y_] := Block[{t$95$0 = N[(E / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, N[Log[N[(y * N[(N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{e}{1 - x}\\
\log \left(\mathsf{fma}\left(y, \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right) \cdot t_0, t_0\right)\right)
\end{array}
\end{array}
Initial program 73.5%
sub-neg73.5%
log1p-def73.5%
distribute-neg-frac73.5%
sub-neg73.5%
distribute-neg-in73.5%
remove-double-neg73.5%
+-commutative73.5%
sub-neg73.5%
Simplified73.5%
add-log-exp73.5%
Applied egg-rr73.5%
Taylor expanded in y around 0 90.1%
+-commutative90.1%
fma-def90.1%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.99999999) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (log (/ (* E (* y (+ (/ x (- 1.0 x)) (/ -1.0 (- 1.0 x))))) (- 1.0 x)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99999999) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = log(((((double) M_E) * (y * ((x / (1.0 - x)) + (-1.0 / (1.0 - x))))) / (1.0 - x)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99999999) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = Math.log(((Math.E * (y * ((x / (1.0 - x)) + (-1.0 / (1.0 - x))))) / (1.0 - x)));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.99999999: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = math.log(((math.e * (y * ((x / (1.0 - x)) + (-1.0 / (1.0 - x))))) / (1.0 - x))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.99999999) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = log(Float64(Float64(exp(1) * Float64(y * Float64(Float64(x / Float64(1.0 - x)) + Float64(-1.0 / Float64(1.0 - x))))) / Float64(1.0 - x))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.99999999], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(E * N[(y * N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.99999999:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{e \cdot \left(y \cdot \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right)\right)}{1 - x}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.99999998999999995Initial program 99.5%
sub-neg99.5%
log1p-def99.5%
distribute-neg-frac99.5%
sub-neg99.5%
distribute-neg-in99.5%
remove-double-neg99.5%
+-commutative99.5%
sub-neg99.5%
Simplified99.5%
if 0.99999998999999995 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 5.9%
sub-neg5.9%
log1p-def5.9%
distribute-neg-frac5.9%
sub-neg5.9%
distribute-neg-in5.9%
remove-double-neg5.9%
+-commutative5.9%
sub-neg5.9%
Simplified5.9%
add-log-exp5.9%
Applied egg-rr5.9%
Taylor expanded in y around 0 78.8%
+-commutative78.8%
fma-def78.8%
Simplified100.0%
Taylor expanded in y around inf 99.2%
*-commutative99.2%
associate-*l*99.2%
*-commutative99.2%
sub-neg99.2%
distribute-neg-frac99.2%
metadata-eval99.2%
Simplified99.2%
Final simplification99.4%
(FPCore (x y) :precision binary64 (let* ((t_0 (/ (- y x) (- 1.0 y)))) (if (<= (+ 1.0 t_0) 0.0005) (log (* E (- 1.0 y))) (- 1.0 (log1p t_0)))))
double code(double x, double y) {
double t_0 = (y - x) / (1.0 - y);
double tmp;
if ((1.0 + t_0) <= 0.0005) {
tmp = log((((double) M_E) * (1.0 - y)));
} else {
tmp = 1.0 - log1p(t_0);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = (y - x) / (1.0 - y);
double tmp;
if ((1.0 + t_0) <= 0.0005) {
tmp = Math.log((Math.E * (1.0 - y)));
} else {
tmp = 1.0 - Math.log1p(t_0);
}
return tmp;
}
def code(x, y): t_0 = (y - x) / (1.0 - y) tmp = 0 if (1.0 + t_0) <= 0.0005: tmp = math.log((math.e * (1.0 - y))) else: tmp = 1.0 - math.log1p(t_0) return tmp
function code(x, y) t_0 = Float64(Float64(y - x) / Float64(1.0 - y)) tmp = 0.0 if (Float64(1.0 + t_0) <= 0.0005) tmp = log(Float64(exp(1) * Float64(1.0 - y))); else tmp = Float64(1.0 - log1p(t_0)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], 0.0005], N[Log[N[(E * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(1.0 - N[Log[1 + t$95$0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y - x}{1 - y}\\
\mathbf{if}\;1 + t_0 \leq 0.0005:\\
\;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\
\end{array}
\end{array}
if (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) < 5.0000000000000001e-4Initial program 9.9%
sub-neg9.9%
log1p-def9.9%
distribute-neg-frac9.9%
sub-neg9.9%
distribute-neg-in9.9%
remove-double-neg9.9%
+-commutative9.9%
sub-neg9.9%
Simplified9.9%
add-log-exp9.9%
Applied egg-rr9.9%
Taylor expanded in y around 0 79.9%
+-commutative79.9%
fma-def79.9%
Simplified100.0%
Taylor expanded in x around 0 69.1%
*-lft-identity69.1%
associate-*r*69.1%
distribute-rgt-out69.1%
neg-mul-169.1%
sub-neg69.1%
Simplified69.1%
if 5.0000000000000001e-4 < (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) Initial program 99.9%
sub-neg99.9%
log1p-def99.9%
distribute-neg-frac99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Final simplification90.9%
(FPCore (x y) :precision binary64 (if (<= x -1.0) (log (/ (* E (+ y -1.0)) x)) (if (<= x 1.0) (log (* E (- 1.0 y))) (- 1.0 (- (log (+ x -1.0)) (log y))))))
double code(double x, double y) {
double tmp;
if (x <= -1.0) {
tmp = log(((((double) M_E) * (y + -1.0)) / x));
} else if (x <= 1.0) {
tmp = log((((double) M_E) * (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 (x <= -1.0) {
tmp = Math.log(((Math.E * (y + -1.0)) / x));
} else if (x <= 1.0) {
tmp = Math.log((Math.E * (1.0 - y)));
} else {
tmp = 1.0 - (Math.log((x + -1.0)) - Math.log(y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.0: tmp = math.log(((math.e * (y + -1.0)) / x)) elif x <= 1.0: tmp = math.log((math.e * (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 (x <= -1.0) tmp = log(Float64(Float64(exp(1) * Float64(y + -1.0)) / x)); elseif (x <= 1.0) tmp = log(Float64(exp(1) * Float64(1.0 - y))); else tmp = Float64(1.0 - Float64(log(Float64(x + -1.0)) - log(y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.0) tmp = log(((2.71828182845904523536 * (y + -1.0)) / x)); elseif (x <= 1.0) tmp = log((2.71828182845904523536 * (1.0 - y))); else tmp = 1.0 - (log((x + -1.0)) - log(y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.0], N[Log[N[(N[(E * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.0], N[Log[N[(E * N[(1.0 - y), $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}\;x \leq -1:\\
\;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(\log \left(x + -1\right) - \log y\right)\\
\end{array}
\end{array}
if x < -1Initial program 88.0%
sub-neg88.0%
log1p-def88.0%
distribute-neg-frac88.0%
sub-neg88.0%
distribute-neg-in88.0%
remove-double-neg88.0%
+-commutative88.0%
sub-neg88.0%
Simplified88.0%
add-log-exp88.0%
Applied egg-rr88.0%
Taylor expanded in y around 0 99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.8%
Taylor expanded in x around inf 95.2%
distribute-rgt-out95.2%
Simplified95.2%
if -1 < x < 1Initial program 72.2%
sub-neg72.2%
log1p-def72.2%
distribute-neg-frac72.2%
sub-neg72.2%
distribute-neg-in72.2%
remove-double-neg72.2%
+-commutative72.2%
sub-neg72.2%
Simplified72.2%
add-log-exp72.2%
Applied egg-rr72.2%
Taylor expanded in y around 0 99.9%
+-commutative99.9%
fma-def99.9%
Simplified100.0%
Taylor expanded in x around 0 98.4%
*-lft-identity98.4%
associate-*r*98.4%
distribute-rgt-out98.4%
neg-mul-198.4%
sub-neg98.4%
Simplified98.4%
if 1 < x Initial program 41.9%
sub-neg41.9%
log1p-def41.9%
distribute-neg-frac41.9%
sub-neg41.9%
distribute-neg-in41.9%
remove-double-neg41.9%
+-commutative41.9%
sub-neg41.9%
Simplified41.9%
Taylor expanded in y around inf 98.8%
log-rec98.8%
unsub-neg98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
Simplified98.8%
Final simplification97.6%
(FPCore (x y)
:precision binary64
(if (<= y -180000000.0)
(- (- 1.0 (log1p (- x))) (log (/ -1.0 y)))
(if (<= y 1.3e+141)
(- 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 <= -180000000.0) {
tmp = (1.0 - log1p(-x)) - log((-1.0 / y));
} else if (y <= 1.3e+141) {
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 <= -180000000.0) {
tmp = (1.0 - Math.log1p(-x)) - Math.log((-1.0 / y));
} else if (y <= 1.3e+141) {
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 <= -180000000.0: tmp = (1.0 - math.log1p(-x)) - math.log((-1.0 / y)) elif y <= 1.3e+141: 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 <= -180000000.0) tmp = Float64(Float64(1.0 - log1p(Float64(-x))) - log(Float64(-1.0 / y))); elseif (y <= 1.3e+141) 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, -180000000.0], N[(N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e+141], 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 -180000000:\\
\;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+141}:\\
\;\;\;\;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.8e8Initial program 20.8%
sub-neg20.8%
log1p-def20.8%
distribute-neg-frac20.8%
sub-neg20.8%
distribute-neg-in20.8%
remove-double-neg20.8%
+-commutative20.8%
sub-neg20.8%
Simplified20.8%
Taylor expanded in y around -inf 98.8%
associate--r+98.8%
sub-neg98.8%
metadata-eval98.8%
distribute-lft-in98.8%
metadata-eval98.8%
+-commutative98.8%
log1p-def98.8%
mul-1-neg98.8%
Simplified98.8%
if -1.8e8 < y < 1.3e141Initial program 99.4%
sub-neg99.4%
log1p-def99.5%
distribute-neg-frac99.5%
sub-neg99.5%
distribute-neg-in99.5%
remove-double-neg99.5%
+-commutative99.5%
sub-neg99.5%
Simplified99.5%
if 1.3e141 < y Initial program 27.4%
sub-neg27.4%
log1p-def27.4%
distribute-neg-frac27.4%
sub-neg27.4%
distribute-neg-in27.4%
remove-double-neg27.4%
+-commutative27.4%
sub-neg27.4%
Simplified27.4%
Taylor expanded in y around inf 98.9%
log-rec98.9%
unsub-neg98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Final simplification99.2%
(FPCore (x y) :precision binary64 (if (or (<= x -1.0) (not (<= x 1.0))) (log (/ (* E (+ y -1.0)) x)) (log (* E (- 1.0 y)))))
double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = log(((((double) M_E) * (y + -1.0)) / x));
} else {
tmp = log((((double) M_E) * (1.0 - y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((x <= -1.0) || !(x <= 1.0)) {
tmp = Math.log(((Math.E * (y + -1.0)) / x));
} else {
tmp = Math.log((Math.E * (1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (x <= -1.0) or not (x <= 1.0): tmp = math.log(((math.e * (y + -1.0)) / x)) else: tmp = math.log((math.e * (1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if ((x <= -1.0) || !(x <= 1.0)) tmp = log(Float64(Float64(exp(1) * Float64(y + -1.0)) / x)); else tmp = log(Float64(exp(1) * Float64(1.0 - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((x <= -1.0) || ~((x <= 1.0))) tmp = log(((2.71828182845904523536 * (y + -1.0)) / x)); else tmp = log((2.71828182845904523536 * (1.0 - y))); end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 1.0]], $MachinePrecision]], N[Log[N[(N[(E * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision], N[Log[N[(E * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 1\right):\\
\;\;\;\;\log \left(\frac{e \cdot \left(y + -1\right)}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(e \cdot \left(1 - y\right)\right)\\
\end{array}
\end{array}
if x < -1 or 1 < x Initial program 75.9%
sub-neg75.9%
log1p-def75.9%
distribute-neg-frac75.9%
sub-neg75.9%
distribute-neg-in75.9%
remove-double-neg75.9%
+-commutative75.9%
sub-neg75.9%
Simplified75.9%
add-log-exp75.9%
Applied egg-rr75.9%
Taylor expanded in y around 0 73.4%
+-commutative73.4%
fma-def73.4%
Simplified99.9%
Taylor expanded in x around inf 94.9%
distribute-rgt-out94.9%
Simplified94.9%
if -1 < x < 1Initial program 72.2%
sub-neg72.2%
log1p-def72.2%
distribute-neg-frac72.2%
sub-neg72.2%
distribute-neg-in72.2%
remove-double-neg72.2%
+-commutative72.2%
sub-neg72.2%
Simplified72.2%
add-log-exp72.2%
Applied egg-rr72.2%
Taylor expanded in y around 0 99.9%
+-commutative99.9%
fma-def99.9%
Simplified100.0%
Taylor expanded in x around 0 98.4%
*-lft-identity98.4%
associate-*r*98.4%
distribute-rgt-out98.4%
neg-mul-198.4%
sub-neg98.4%
Simplified98.4%
Final simplification97.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- y x) (- 1.0 y))))
(if (<= (+ 1.0 t_0) 5e-7)
(+ 1.0 (- (/ -1.0 y) (log (/ -1.0 y))))
(- 1.0 (log1p t_0)))))
double code(double x, double y) {
double t_0 = (y - x) / (1.0 - y);
double tmp;
if ((1.0 + t_0) <= 5e-7) {
tmp = 1.0 + ((-1.0 / y) - log((-1.0 / y)));
} else {
tmp = 1.0 - log1p(t_0);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = (y - x) / (1.0 - y);
double tmp;
if ((1.0 + t_0) <= 5e-7) {
tmp = 1.0 + ((-1.0 / y) - Math.log((-1.0 / y)));
} else {
tmp = 1.0 - Math.log1p(t_0);
}
return tmp;
}
def code(x, y): t_0 = (y - x) / (1.0 - y) tmp = 0 if (1.0 + t_0) <= 5e-7: tmp = 1.0 + ((-1.0 / y) - math.log((-1.0 / y))) else: tmp = 1.0 - math.log1p(t_0) return tmp
function code(x, y) t_0 = Float64(Float64(y - x) / Float64(1.0 - y)) tmp = 0.0 if (Float64(1.0 + t_0) <= 5e-7) tmp = Float64(1.0 + Float64(Float64(-1.0 / y) - log(Float64(-1.0 / y)))); else tmp = Float64(1.0 - log1p(t_0)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], 5e-7], N[(1.0 + N[(N[(-1.0 / y), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + t$95$0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y - x}{1 - y}\\
\mathbf{if}\;1 + t_0 \leq 5 \cdot 10^{-7}:\\
\;\;\;\;1 + \left(\frac{-1}{y} - \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\
\end{array}
\end{array}
if (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) < 4.99999999999999977e-7Initial program 7.8%
sub-neg7.8%
log1p-def7.8%
distribute-neg-frac7.8%
sub-neg7.8%
distribute-neg-in7.8%
remove-double-neg7.8%
+-commutative7.8%
sub-neg7.8%
Simplified7.8%
Taylor expanded in x around 0 7.0%
log1p-def7.0%
Simplified7.0%
Taylor expanded in y around inf 0.0%
associate-+r+0.0%
log-rec0.0%
sub-neg0.0%
log-div68.1%
+-commutative68.1%
Simplified68.1%
if 4.99999999999999977e-7 < (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) Initial program 99.8%
sub-neg99.8%
log1p-def99.8%
distribute-neg-frac99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
Final simplification90.8%
(FPCore (x y) :precision binary64 (if (<= y -2.75e+14) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ (- y x) (- 1.0 y))))))
double code(double x, double y) {
double tmp;
if (y <= -2.75e+14) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -2.75e+14) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.75e+14: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.75e+14) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -2.75e+14], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.75 \cdot 10^{+14}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -2.75e14Initial program 16.9%
sub-neg16.9%
log1p-def16.9%
distribute-neg-frac16.9%
sub-neg16.9%
distribute-neg-in16.9%
remove-double-neg16.9%
+-commutative16.9%
sub-neg16.9%
Simplified16.9%
Taylor expanded in x around 0 3.3%
log1p-def3.3%
Simplified3.3%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div75.1%
Simplified75.1%
if -2.75e14 < y Initial program 91.6%
sub-neg91.6%
log1p-def91.6%
distribute-neg-frac91.6%
sub-neg91.6%
distribute-neg-in91.6%
remove-double-neg91.6%
+-commutative91.6%
sub-neg91.6%
Simplified91.6%
Final simplification87.6%
(FPCore (x y) :precision binary64 (if (<= y -2.75e+14) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (/ (- x) (- 1.0 y))))))
double code(double x, double y) {
double tmp;
if (y <= -2.75e+14) {
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 <= -2.75e+14) {
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 <= -2.75e+14: 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 <= -2.75e+14) 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, -2.75e+14], 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 -2.75 \cdot 10^{+14}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -2.75e14Initial program 16.9%
sub-neg16.9%
log1p-def16.9%
distribute-neg-frac16.9%
sub-neg16.9%
distribute-neg-in16.9%
remove-double-neg16.9%
+-commutative16.9%
sub-neg16.9%
Simplified16.9%
Taylor expanded in x around 0 3.3%
log1p-def3.3%
Simplified3.3%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div75.1%
Simplified75.1%
if -2.75e14 < y Initial program 91.6%
sub-neg91.6%
log1p-def91.6%
distribute-neg-frac91.6%
sub-neg91.6%
distribute-neg-in91.6%
remove-double-neg91.6%
+-commutative91.6%
sub-neg91.6%
Simplified91.6%
Taylor expanded in x around inf 90.2%
neg-mul-190.2%
distribute-neg-frac90.2%
Simplified90.2%
Final simplification86.5%
(FPCore (x y) :precision binary64 (if (<= y -5.2) (- 1.0 (log (/ -1.0 y))) (- 1.0 (+ y (log1p (- x))))))
double code(double x, double y) {
double tmp;
if (y <= -5.2) {
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.2) {
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.2: 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.2) 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.2], 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.2:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\end{array}
\end{array}
if y < -5.20000000000000018Initial program 26.3%
sub-neg26.3%
log1p-def26.3%
distribute-neg-frac26.3%
sub-neg26.3%
distribute-neg-in26.3%
remove-double-neg26.3%
+-commutative26.3%
sub-neg26.3%
Simplified26.3%
Taylor expanded in x around 0 9.0%
log1p-def9.0%
Simplified9.0%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.2%
Simplified69.2%
if -5.20000000000000018 < y Initial program 92.0%
sub-neg92.0%
log1p-def92.0%
distribute-neg-frac92.0%
sub-neg92.0%
distribute-neg-in92.0%
remove-double-neg92.0%
+-commutative92.0%
sub-neg92.0%
Simplified92.0%
Taylor expanded in y around 0 86.0%
+-commutative86.0%
div-sub86.0%
mul-1-neg86.0%
sub-neg86.0%
*-inverses86.0%
*-rgt-identity86.0%
log1p-def86.0%
mul-1-neg86.0%
Simplified86.0%
Final simplification81.3%
(FPCore (x y) :precision binary64 (if (<= y -3050.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -3050.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 <= -3050.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 <= -3050.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 <= -3050.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, -3050.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 -3050:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -3050Initial program 25.3%
sub-neg25.3%
log1p-def25.3%
distribute-neg-frac25.3%
sub-neg25.3%
distribute-neg-in25.3%
remove-double-neg25.3%
+-commutative25.3%
sub-neg25.3%
Simplified25.3%
Taylor expanded in x around 0 9.1%
log1p-def9.1%
Simplified9.1%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div70.2%
Simplified70.2%
if -3050 < y Initial program 92.0%
sub-neg92.0%
log1p-def92.1%
distribute-neg-frac92.1%
sub-neg92.1%
distribute-neg-in92.1%
remove-double-neg92.1%
+-commutative92.1%
sub-neg92.1%
Simplified92.1%
Taylor expanded in y around 0 85.3%
log1p-def85.3%
mul-1-neg85.3%
Simplified85.3%
Final simplification81.1%
(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.5%
sub-neg73.5%
log1p-def73.5%
distribute-neg-frac73.5%
sub-neg73.5%
distribute-neg-in73.5%
remove-double-neg73.5%
+-commutative73.5%
sub-neg73.5%
Simplified73.5%
Taylor expanded in y around 0 65.3%
log1p-def65.4%
mul-1-neg65.4%
Simplified65.4%
Final simplification65.4%
(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 73.5%
sub-neg73.5%
log1p-def73.5%
distribute-neg-frac73.5%
sub-neg73.5%
distribute-neg-in73.5%
remove-double-neg73.5%
+-commutative73.5%
sub-neg73.5%
Simplified73.5%
Taylor expanded in x around inf 74.4%
neg-mul-174.4%
distribute-neg-frac74.4%
Simplified74.4%
Taylor expanded in x around 0 48.1%
Final simplification48.1%
(FPCore (x y) :precision binary64 (+ x 1.0))
double code(double x, double y) {
return x + 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + 1.0d0
end function
public static double code(double x, double y) {
return x + 1.0;
}
def code(x, y): return x + 1.0
function code(x, y) return Float64(x + 1.0) end
function tmp = code(x, y) tmp = x + 1.0; end
code[x_, y_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 73.5%
sub-neg73.5%
log1p-def73.5%
distribute-neg-frac73.5%
sub-neg73.5%
distribute-neg-in73.5%
remove-double-neg73.5%
+-commutative73.5%
sub-neg73.5%
Simplified73.5%
add-log-exp73.5%
Applied egg-rr73.5%
Taylor expanded in y around 0 65.3%
exp-diff65.4%
e-exp-165.4%
mul-1-neg65.4%
sub-neg65.4%
rem-exp-log65.4%
Simplified65.4%
Taylor expanded in x around 0 47.0%
log-E47.0%
Simplified47.0%
Final simplification47.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 73.5%
sub-neg73.5%
log1p-def73.5%
distribute-neg-frac73.5%
sub-neg73.5%
distribute-neg-in73.5%
remove-double-neg73.5%
+-commutative73.5%
sub-neg73.5%
Simplified73.5%
Taylor expanded in x around inf 74.4%
neg-mul-174.4%
distribute-neg-frac74.4%
Simplified74.4%
Taylor expanded in x around 0 46.6%
Final simplification46.6%
(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 2023320
(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))))))