
(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 13 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 -380000.0)
(+ 1.0 (- (/ -1.0 y) (+ (log1p (- x)) (log (/ -1.0 y)))))
(if (<= y 1.2e+16)
(- 1.0 (log1p (* (/ 1.0 (+ y -1.0)) (- x y))))
(- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -380000.0) {
tmp = 1.0 + ((-1.0 / y) - (log1p(-x) + log((-1.0 / y))));
} else if (y <= 1.2e+16) {
tmp = 1.0 - log1p(((1.0 / (y + -1.0)) * (x - y)));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -380000.0) {
tmp = 1.0 + ((-1.0 / y) - (Math.log1p(-x) + Math.log((-1.0 / y))));
} else if (y <= 1.2e+16) {
tmp = 1.0 - Math.log1p(((1.0 / (y + -1.0)) * (x - y)));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -380000.0: tmp = 1.0 + ((-1.0 / y) - (math.log1p(-x) + math.log((-1.0 / y)))) elif y <= 1.2e+16: tmp = 1.0 - math.log1p(((1.0 / (y + -1.0)) * (x - y))) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -380000.0) tmp = Float64(1.0 + Float64(Float64(-1.0 / y) - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y))))); elseif (y <= 1.2e+16) tmp = Float64(1.0 - log1p(Float64(Float64(1.0 / Float64(y + -1.0)) * Float64(x - y)))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -380000.0], N[(1.0 + N[(N[(-1.0 / y), $MachinePrecision] - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e+16], N[(1.0 - N[Log[1 + N[(N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -380000:\\
\;\;\;\;1 + \left(\frac{-1}{y} - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\right)\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+16}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{1}{y + -1} \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -3.8e5Initial program 25.2%
sub-neg25.2%
log1p-define25.2%
distribute-neg-frac225.2%
neg-sub025.2%
associate--r-25.2%
metadata-eval25.2%
+-commutative25.2%
Simplified25.2%
Taylor expanded in y around -inf 99.3%
Simplified99.3%
if -3.8e5 < y < 1.2e16Initial program 99.9%
sub-neg99.9%
log1p-define99.9%
distribute-neg-frac299.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
if 1.2e16 < y Initial program 41.0%
sub-neg41.0%
log1p-define41.0%
distribute-neg-frac241.0%
neg-sub041.0%
associate--r-41.0%
metadata-eval41.0%
+-commutative41.0%
Simplified41.0%
Taylor expanded in y around inf 41.0%
Taylor expanded in x around 0 98.5%
log-rec98.5%
unsub-neg98.5%
Simplified98.5%
sub-neg98.5%
diff-log99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -1650000000.0)
(- 1.0 (+ (log1p (- x)) (log (/ -1.0 y))))
(if (<= y 5e+15)
(- 1.0 (log1p (* (/ 1.0 (+ y -1.0)) (- x y))))
(- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -1650000000.0) {
tmp = 1.0 - (log1p(-x) + log((-1.0 / y)));
} else if (y <= 5e+15) {
tmp = 1.0 - log1p(((1.0 / (y + -1.0)) * (x - y)));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1650000000.0) {
tmp = 1.0 - (Math.log1p(-x) + Math.log((-1.0 / y)));
} else if (y <= 5e+15) {
tmp = 1.0 - Math.log1p(((1.0 / (y + -1.0)) * (x - y)));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1650000000.0: tmp = 1.0 - (math.log1p(-x) + math.log((-1.0 / y))) elif y <= 5e+15: tmp = 1.0 - math.log1p(((1.0 / (y + -1.0)) * (x - y))) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1650000000.0) tmp = Float64(1.0 - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (y <= 5e+15) tmp = Float64(1.0 - log1p(Float64(Float64(1.0 / Float64(y + -1.0)) * Float64(x - y)))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -1650000000.0], N[(1.0 - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+15], N[(1.0 - N[Log[1 + N[(N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1650000000:\\
\;\;\;\;1 - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+15}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{1}{y + -1} \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -1.65e9Initial program 25.2%
sub-neg25.2%
log1p-define25.2%
distribute-neg-frac225.2%
neg-sub025.2%
associate--r-25.2%
metadata-eval25.2%
+-commutative25.2%
Simplified25.2%
Taylor expanded in y around -inf 99.1%
sub-neg99.1%
metadata-eval99.1%
distribute-lft-in99.1%
metadata-eval99.1%
+-commutative99.1%
log1p-define99.1%
mul-1-neg99.1%
Simplified99.1%
if -1.65e9 < y < 5e15Initial program 99.9%
sub-neg99.9%
log1p-define99.9%
distribute-neg-frac299.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
if 5e15 < y Initial program 41.0%
sub-neg41.0%
log1p-define41.0%
distribute-neg-frac241.0%
neg-sub041.0%
associate--r-41.0%
metadata-eval41.0%
+-commutative41.0%
Simplified41.0%
Taylor expanded in y around inf 41.0%
Taylor expanded in x around 0 98.5%
log-rec98.5%
unsub-neg98.5%
Simplified98.5%
sub-neg98.5%
diff-log99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
(FPCore (x y)
:precision binary64
(if (<= x -6.6e-6)
(- 1.0 (log1p (* x (- (/ 1.0 (+ y -1.0)) (/ (/ y x) (+ y -1.0))))))
(if (<= x 1.0)
(+ 1.0 (log1p (- (* y (- -1.0 x)) x)))
(- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -6.6e-6) {
tmp = 1.0 - log1p((x * ((1.0 / (y + -1.0)) - ((y / x) / (y + -1.0)))));
} else if (x <= 1.0) {
tmp = 1.0 + log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (x <= -6.6e-6) {
tmp = 1.0 - Math.log1p((x * ((1.0 / (y + -1.0)) - ((y / x) / (y + -1.0)))));
} else if (x <= 1.0) {
tmp = 1.0 + Math.log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.6e-6: tmp = 1.0 - math.log1p((x * ((1.0 / (y + -1.0)) - ((y / x) / (y + -1.0))))) elif x <= 1.0: tmp = 1.0 + math.log1p(((y * (-1.0 - x)) - x)) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -6.6e-6) tmp = Float64(1.0 - log1p(Float64(x * Float64(Float64(1.0 / Float64(y + -1.0)) - Float64(Float64(y / x) / Float64(y + -1.0)))))); elseif (x <= 1.0) tmp = Float64(1.0 + log1p(Float64(Float64(y * Float64(-1.0 - x)) - x))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[x, -6.6e-6], N[(1.0 - N[Log[1 + N[(x * N[(N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(y / x), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[Log[1 + N[(N[(y * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.6 \cdot 10^{-6}:\\
\;\;\;\;1 - \mathsf{log1p}\left(x \cdot \left(\frac{1}{y + -1} - \frac{\frac{y}{x}}{y + -1}\right)\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + \mathsf{log1p}\left(y \cdot \left(-1 - x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -6.60000000000000034e-6Initial program 88.3%
sub-neg88.3%
log1p-define88.3%
distribute-neg-frac288.3%
neg-sub088.3%
associate--r-88.3%
metadata-eval88.3%
+-commutative88.3%
Simplified88.3%
Taylor expanded in x around -inf 86.8%
associate-*r*86.8%
mul-1-neg86.8%
sub-neg86.8%
metadata-eval86.8%
associate-/r*89.1%
sub-neg89.1%
metadata-eval89.1%
Simplified89.1%
if -6.60000000000000034e-6 < x < 1Initial program 70.3%
sub-neg70.3%
log1p-define70.4%
distribute-neg-frac270.4%
neg-sub070.4%
associate--r-70.4%
metadata-eval70.4%
+-commutative70.4%
Simplified70.4%
add-exp-log70.4%
sub-neg70.4%
log1p-define70.4%
Applied egg-rr70.4%
log1p-undefine70.4%
rem-exp-log70.4%
add-sqr-sqrt38.9%
sqrt-unprod70.2%
sqr-neg70.2%
sqrt-unprod31.4%
add-sqr-sqrt67.1%
sub-neg67.1%
add-sqr-sqrt37.3%
sqrt-unprod67.0%
sqr-neg67.0%
sqrt-unprod29.8%
add-sqr-sqrt71.6%
Applied egg-rr71.6%
Taylor expanded in y around 0 98.5%
+-commutative98.5%
mul-1-neg98.5%
unsub-neg98.5%
mul-1-neg98.5%
distribute-rgt-neg-in98.5%
distribute-neg-in98.5%
metadata-eval98.5%
unsub-neg98.5%
Simplified98.5%
if 1 < x Initial program 45.8%
sub-neg45.8%
log1p-define45.8%
distribute-neg-frac245.8%
neg-sub045.8%
associate--r-45.8%
metadata-eval45.8%
+-commutative45.8%
Simplified45.8%
Taylor expanded in y around inf 41.4%
Taylor expanded in x around 0 94.3%
log-rec94.3%
unsub-neg94.3%
Simplified94.3%
sub-neg94.3%
diff-log95.6%
Applied egg-rr95.6%
sub-neg95.6%
Simplified95.6%
Final simplification95.1%
(FPCore (x y)
:precision binary64
(if (<= x -2.25e-5)
(- 1.0 (log1p (* x (- (/ 1.0 (+ y -1.0)) (/ (/ y (+ y -1.0)) x)))))
(if (<= x 1.0)
(+ 1.0 (log1p (- (* y (- -1.0 x)) x)))
(- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -2.25e-5) {
tmp = 1.0 - log1p((x * ((1.0 / (y + -1.0)) - ((y / (y + -1.0)) / x))));
} else if (x <= 1.0) {
tmp = 1.0 + log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (x <= -2.25e-5) {
tmp = 1.0 - Math.log1p((x * ((1.0 / (y + -1.0)) - ((y / (y + -1.0)) / x))));
} else if (x <= 1.0) {
tmp = 1.0 + Math.log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.25e-5: tmp = 1.0 - math.log1p((x * ((1.0 / (y + -1.0)) - ((y / (y + -1.0)) / x)))) elif x <= 1.0: tmp = 1.0 + math.log1p(((y * (-1.0 - x)) - x)) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.25e-5) tmp = Float64(1.0 - log1p(Float64(x * Float64(Float64(1.0 / Float64(y + -1.0)) - Float64(Float64(y / Float64(y + -1.0)) / x))))); elseif (x <= 1.0) tmp = Float64(1.0 + log1p(Float64(Float64(y * Float64(-1.0 - x)) - x))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[x, -2.25e-5], N[(1.0 - N[Log[1 + N[(x * N[(N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(y / N[(y + -1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[Log[1 + N[(N[(y * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.25 \cdot 10^{-5}:\\
\;\;\;\;1 - \mathsf{log1p}\left(x \cdot \left(\frac{1}{y + -1} - \frac{\frac{y}{y + -1}}{x}\right)\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + \mathsf{log1p}\left(y \cdot \left(-1 - x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -2.25000000000000014e-5Initial program 88.3%
sub-neg88.3%
log1p-define88.3%
distribute-neg-frac288.3%
neg-sub088.3%
associate--r-88.3%
metadata-eval88.3%
+-commutative88.3%
Simplified88.3%
Taylor expanded in x around inf 86.8%
+-commutative86.8%
mul-1-neg86.8%
unsub-neg86.8%
sub-neg86.8%
metadata-eval86.8%
sub-neg86.8%
metadata-eval86.8%
*-commutative86.8%
associate-/r*88.5%
Simplified88.5%
if -2.25000000000000014e-5 < x < 1Initial program 70.3%
sub-neg70.3%
log1p-define70.4%
distribute-neg-frac270.4%
neg-sub070.4%
associate--r-70.4%
metadata-eval70.4%
+-commutative70.4%
Simplified70.4%
add-exp-log70.4%
sub-neg70.4%
log1p-define70.4%
Applied egg-rr70.4%
log1p-undefine70.4%
rem-exp-log70.4%
add-sqr-sqrt38.9%
sqrt-unprod70.2%
sqr-neg70.2%
sqrt-unprod31.4%
add-sqr-sqrt67.1%
sub-neg67.1%
add-sqr-sqrt37.3%
sqrt-unprod67.0%
sqr-neg67.0%
sqrt-unprod29.8%
add-sqr-sqrt71.6%
Applied egg-rr71.6%
Taylor expanded in y around 0 98.5%
+-commutative98.5%
mul-1-neg98.5%
unsub-neg98.5%
mul-1-neg98.5%
distribute-rgt-neg-in98.5%
distribute-neg-in98.5%
metadata-eval98.5%
unsub-neg98.5%
Simplified98.5%
if 1 < x Initial program 45.8%
sub-neg45.8%
log1p-define45.8%
distribute-neg-frac245.8%
neg-sub045.8%
associate--r-45.8%
metadata-eval45.8%
+-commutative45.8%
Simplified45.8%
Taylor expanded in y around inf 41.4%
Taylor expanded in x around 0 94.3%
log-rec94.3%
unsub-neg94.3%
Simplified94.3%
sub-neg94.3%
diff-log95.6%
Applied egg-rr95.6%
sub-neg95.6%
Simplified95.6%
(FPCore (x y)
:precision binary64
(if (<= x -2.9e-5)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(if (<= x 1.0)
(+ 1.0 (log1p (- (* y (- -1.0 x)) x)))
(- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -2.9e-5) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else if (x <= 1.0) {
tmp = 1.0 + log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (x <= -2.9e-5) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else if (x <= 1.0) {
tmp = 1.0 + Math.log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -2.9e-5: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) elif x <= 1.0: tmp = 1.0 + math.log1p(((y * (-1.0 - x)) - x)) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -2.9e-5) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); elseif (x <= 1.0) tmp = Float64(1.0 + log1p(Float64(Float64(y * Float64(-1.0 - x)) - x))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[x, -2.9e-5], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[Log[1 + N[(N[(y * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9 \cdot 10^{-5}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + \mathsf{log1p}\left(y \cdot \left(-1 - x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -2.9e-5Initial program 88.3%
sub-neg88.3%
log1p-define88.3%
distribute-neg-frac288.3%
neg-sub088.3%
associate--r-88.3%
metadata-eval88.3%
+-commutative88.3%
Simplified88.3%
if -2.9e-5 < x < 1Initial program 70.3%
sub-neg70.3%
log1p-define70.4%
distribute-neg-frac270.4%
neg-sub070.4%
associate--r-70.4%
metadata-eval70.4%
+-commutative70.4%
Simplified70.4%
add-exp-log70.4%
sub-neg70.4%
log1p-define70.4%
Applied egg-rr70.4%
log1p-undefine70.4%
rem-exp-log70.4%
add-sqr-sqrt38.9%
sqrt-unprod70.2%
sqr-neg70.2%
sqrt-unprod31.4%
add-sqr-sqrt67.1%
sub-neg67.1%
add-sqr-sqrt37.3%
sqrt-unprod67.0%
sqr-neg67.0%
sqrt-unprod29.8%
add-sqr-sqrt71.6%
Applied egg-rr71.6%
Taylor expanded in y around 0 98.5%
+-commutative98.5%
mul-1-neg98.5%
unsub-neg98.5%
mul-1-neg98.5%
distribute-rgt-neg-in98.5%
distribute-neg-in98.5%
metadata-eval98.5%
unsub-neg98.5%
Simplified98.5%
if 1 < x Initial program 45.8%
sub-neg45.8%
log1p-define45.8%
distribute-neg-frac245.8%
neg-sub045.8%
associate--r-45.8%
metadata-eval45.8%
+-commutative45.8%
Simplified45.8%
Taylor expanded in y around inf 41.4%
Taylor expanded in x around 0 94.3%
log-rec94.3%
unsub-neg94.3%
Simplified94.3%
sub-neg94.3%
diff-log95.6%
Applied egg-rr95.6%
sub-neg95.6%
Simplified95.6%
(FPCore (x y)
:precision binary64
(if (<= x -6.6e-6)
(- 1.0 (log1p (/ x (+ y -1.0))))
(if (<= x 1.0)
(+ 1.0 (log1p (- (* y (- -1.0 x)) x)))
(- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (x <= -6.6e-6) {
tmp = 1.0 - log1p((x / (y + -1.0)));
} else if (x <= 1.0) {
tmp = 1.0 + log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (x <= -6.6e-6) {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
} else if (x <= 1.0) {
tmp = 1.0 + Math.log1p(((y * (-1.0 - x)) - x));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -6.6e-6: tmp = 1.0 - math.log1p((x / (y + -1.0))) elif x <= 1.0: tmp = 1.0 + math.log1p(((y * (-1.0 - x)) - x)) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -6.6e-6) tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); elseif (x <= 1.0) tmp = Float64(1.0 + log1p(Float64(Float64(y * Float64(-1.0 - x)) - x))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[x, -6.6e-6], N[(1.0 - N[Log[1 + N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(1.0 + N[Log[1 + N[(N[(y * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.6 \cdot 10^{-6}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;1 + \mathsf{log1p}\left(y \cdot \left(-1 - x\right) - x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if x < -6.60000000000000034e-6Initial program 88.3%
sub-neg88.3%
log1p-define88.3%
distribute-neg-frac288.3%
neg-sub088.3%
associate--r-88.3%
metadata-eval88.3%
+-commutative88.3%
Simplified88.3%
Taylor expanded in x around inf 86.6%
if -6.60000000000000034e-6 < x < 1Initial program 70.3%
sub-neg70.3%
log1p-define70.4%
distribute-neg-frac270.4%
neg-sub070.4%
associate--r-70.4%
metadata-eval70.4%
+-commutative70.4%
Simplified70.4%
add-exp-log70.4%
sub-neg70.4%
log1p-define70.4%
Applied egg-rr70.4%
log1p-undefine70.4%
rem-exp-log70.4%
add-sqr-sqrt38.9%
sqrt-unprod70.2%
sqr-neg70.2%
sqrt-unprod31.4%
add-sqr-sqrt67.1%
sub-neg67.1%
add-sqr-sqrt37.3%
sqrt-unprod67.0%
sqr-neg67.0%
sqrt-unprod29.8%
add-sqr-sqrt71.6%
Applied egg-rr71.6%
Taylor expanded in y around 0 98.5%
+-commutative98.5%
mul-1-neg98.5%
unsub-neg98.5%
mul-1-neg98.5%
distribute-rgt-neg-in98.5%
distribute-neg-in98.5%
metadata-eval98.5%
unsub-neg98.5%
Simplified98.5%
if 1 < x Initial program 45.8%
sub-neg45.8%
log1p-define45.8%
distribute-neg-frac245.8%
neg-sub045.8%
associate--r-45.8%
metadata-eval45.8%
+-commutative45.8%
Simplified45.8%
Taylor expanded in y around inf 41.4%
Taylor expanded in x around 0 94.3%
log-rec94.3%
unsub-neg94.3%
Simplified94.3%
sub-neg94.3%
diff-log95.6%
Applied egg-rr95.6%
sub-neg95.6%
Simplified95.6%
Final simplification94.3%
(FPCore (x y) :precision binary64 (if (<= y -65.0) (+ 1.0 (log (- y))) (if (<= y 40000.0) (- 1.0 (log1p (/ x (+ y -1.0)))) (- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -65.0) {
tmp = 1.0 + log(-y);
} else if (y <= 40000.0) {
tmp = 1.0 - log1p((x / (y + -1.0)));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -65.0) {
tmp = 1.0 + Math.log(-y);
} else if (y <= 40000.0) {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -65.0: tmp = 1.0 + math.log(-y) elif y <= 40000.0: tmp = 1.0 - math.log1p((x / (y + -1.0))) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -65.0) tmp = Float64(1.0 + log(Float64(-y))); elseif (y <= 40000.0) tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -65.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 40000.0], N[(1.0 - N[Log[1 + N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -65:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{elif}\;y \leq 40000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -65Initial program 27.1%
sub-neg27.1%
log1p-define27.1%
distribute-neg-frac227.1%
neg-sub027.1%
associate--r-27.1%
metadata-eval27.1%
+-commutative27.1%
Simplified27.1%
Taylor expanded in x around 0 5.7%
sub-neg5.7%
metadata-eval5.7%
neg-mul-15.7%
distribute-neg-frac5.7%
Simplified5.7%
Taylor expanded in y around -inf 63.2%
sub-neg63.2%
neg-log63.2%
clear-num63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
*-commutative63.2%
neg-mul-163.2%
Simplified63.2%
if -65 < y < 4e4Initial 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%
Taylor expanded in x around inf 99.9%
if 4e4 < y Initial program 41.0%
sub-neg41.0%
log1p-define41.0%
distribute-neg-frac241.0%
neg-sub041.0%
associate--r-41.0%
metadata-eval41.0%
+-commutative41.0%
Simplified41.0%
Taylor expanded in y around inf 41.0%
Taylor expanded in x around 0 98.5%
log-rec98.5%
unsub-neg98.5%
Simplified98.5%
sub-neg98.5%
diff-log99.9%
Applied egg-rr99.9%
sub-neg99.9%
Simplified99.9%
Final simplification89.5%
(FPCore (x y) :precision binary64 (if (<= y -27.0) (+ 1.0 (log (- y))) (if (<= y 1.0) (- 1.0 (+ y (log1p (- x)))) (- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -27.0) {
tmp = 1.0 + log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - (y + log1p(-x));
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -27.0) {
tmp = 1.0 + Math.log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - (y + Math.log1p(-x));
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -27.0: tmp = 1.0 + math.log(-y) elif y <= 1.0: tmp = 1.0 - (y + math.log1p(-x)) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -27.0) tmp = Float64(1.0 + log(Float64(-y))); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -27.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -27:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -27Initial program 27.1%
sub-neg27.1%
log1p-define27.1%
distribute-neg-frac227.1%
neg-sub027.1%
associate--r-27.1%
metadata-eval27.1%
+-commutative27.1%
Simplified27.1%
Taylor expanded in x around 0 5.7%
sub-neg5.7%
metadata-eval5.7%
neg-mul-15.7%
distribute-neg-frac5.7%
Simplified5.7%
Taylor expanded in y around -inf 63.2%
sub-neg63.2%
neg-log63.2%
clear-num63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
*-commutative63.2%
neg-mul-163.2%
Simplified63.2%
if -27 < y < 1Initial 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%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
div-sub100.0%
mul-1-neg100.0%
sub-neg100.0%
*-inverses100.0%
*-rgt-identity100.0%
log1p-define100.0%
mul-1-neg100.0%
Simplified100.0%
if 1 < y Initial program 45.8%
sub-neg45.8%
log1p-define45.8%
distribute-neg-frac245.8%
neg-sub045.8%
associate--r-45.8%
metadata-eval45.8%
+-commutative45.8%
Simplified45.8%
Taylor expanded in y around inf 41.4%
Taylor expanded in x around 0 94.3%
log-rec94.3%
unsub-neg94.3%
Simplified94.3%
sub-neg94.3%
diff-log95.6%
Applied egg-rr95.6%
sub-neg95.6%
Simplified95.6%
(FPCore (x y) :precision binary64 (if (<= y -55.0) (+ 1.0 (log (- y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -55.0) {
tmp = 1.0 + log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -55.0) {
tmp = 1.0 + Math.log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -55.0: tmp = 1.0 + math.log(-y) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -55.0) tmp = Float64(1.0 + log(Float64(-y))); elseif (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -55.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -55:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -55Initial program 27.1%
sub-neg27.1%
log1p-define27.1%
distribute-neg-frac227.1%
neg-sub027.1%
associate--r-27.1%
metadata-eval27.1%
+-commutative27.1%
Simplified27.1%
Taylor expanded in x around 0 5.7%
sub-neg5.7%
metadata-eval5.7%
neg-mul-15.7%
distribute-neg-frac5.7%
Simplified5.7%
Taylor expanded in y around -inf 63.2%
sub-neg63.2%
neg-log63.2%
clear-num63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
*-commutative63.2%
neg-mul-163.2%
Simplified63.2%
if -55 < y < 1Initial 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%
Taylor expanded in y around 0 99.9%
log1p-define99.9%
mul-1-neg99.9%
Simplified99.9%
if 1 < y Initial program 45.8%
sub-neg45.8%
log1p-define45.8%
distribute-neg-frac245.8%
neg-sub045.8%
associate--r-45.8%
metadata-eval45.8%
+-commutative45.8%
Simplified45.8%
Taylor expanded in y around inf 41.4%
Taylor expanded in x around 0 94.3%
log-rec94.3%
unsub-neg94.3%
Simplified94.3%
sub-neg94.3%
diff-log95.6%
Applied egg-rr95.6%
sub-neg95.6%
Simplified95.6%
(FPCore (x y) :precision binary64 (if (<= y -31.5) (+ 1.0 (log (- y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -31.5) {
tmp = 1.0 + log(-y);
} else {
tmp = 1.0 - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -31.5) {
tmp = 1.0 + Math.log(-y);
} else {
tmp = 1.0 - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -31.5: tmp = 1.0 + math.log(-y) else: tmp = 1.0 - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if (y <= -31.5) tmp = Float64(1.0 + log(Float64(-y))); else tmp = Float64(1.0 - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -31.5], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -31.5:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -31.5Initial program 27.1%
sub-neg27.1%
log1p-define27.1%
distribute-neg-frac227.1%
neg-sub027.1%
associate--r-27.1%
metadata-eval27.1%
+-commutative27.1%
Simplified27.1%
Taylor expanded in x around 0 5.7%
sub-neg5.7%
metadata-eval5.7%
neg-mul-15.7%
distribute-neg-frac5.7%
Simplified5.7%
Taylor expanded in y around -inf 63.2%
sub-neg63.2%
neg-log63.2%
clear-num63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
*-commutative63.2%
neg-mul-163.2%
Simplified63.2%
if -31.5 < y Initial program 92.6%
sub-neg92.6%
log1p-define92.6%
distribute-neg-frac292.6%
neg-sub092.6%
associate--r-92.6%
metadata-eval92.6%
+-commutative92.6%
Simplified92.6%
Taylor expanded in y around 0 86.2%
log1p-define86.3%
mul-1-neg86.3%
Simplified86.3%
(FPCore (x y) :precision binary64 (if (<= y -1.85e-13) (+ 1.0 (log (- y))) (- 1.0 (/ x (+ y -1.0)))))
double code(double x, double y) {
double tmp;
if (y <= -1.85e-13) {
tmp = 1.0 + log(-y);
} else {
tmp = 1.0 - (x / (y + -1.0));
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.85d-13)) then
tmp = 1.0d0 + log(-y)
else
tmp = 1.0d0 - (x / (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.85e-13) {
tmp = 1.0 + Math.log(-y);
} else {
tmp = 1.0 - (x / (y + -1.0));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.85e-13: tmp = 1.0 + math.log(-y) else: tmp = 1.0 - (x / (y + -1.0)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.85e-13) tmp = Float64(1.0 + log(Float64(-y))); else tmp = Float64(1.0 - Float64(x / Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.85e-13) tmp = 1.0 + log(-y); else tmp = 1.0 - (x / (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.85e-13], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{-13}:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y + -1}\\
\end{array}
\end{array}
if y < -1.84999999999999994e-13Initial program 28.1%
sub-neg28.1%
log1p-define28.1%
distribute-neg-frac228.1%
neg-sub028.1%
associate--r-28.1%
metadata-eval28.1%
+-commutative28.1%
Simplified28.1%
Taylor expanded in x around 0 5.6%
sub-neg5.6%
metadata-eval5.6%
neg-mul-15.6%
distribute-neg-frac5.6%
Simplified5.6%
Taylor expanded in y around -inf 62.6%
sub-neg62.6%
neg-log62.6%
clear-num62.6%
div-inv62.6%
metadata-eval62.6%
Applied egg-rr62.6%
*-commutative62.6%
neg-mul-162.6%
Simplified62.6%
if -1.84999999999999994e-13 < y Initial program 92.5%
sub-neg92.5%
log1p-define92.5%
distribute-neg-frac292.5%
neg-sub092.5%
associate--r-92.5%
metadata-eval92.5%
+-commutative92.5%
Simplified92.5%
Taylor expanded in x around inf 93.3%
Taylor expanded in x around 0 57.2%
Final simplification58.8%
(FPCore (x y) :precision binary64 (- 1.0 (/ x (+ y -1.0))))
double code(double x, double y) {
return 1.0 - (x / (y + -1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - (x / (y + (-1.0d0)))
end function
public static double code(double x, double y) {
return 1.0 - (x / (y + -1.0));
}
def code(x, y): return 1.0 - (x / (y + -1.0))
function code(x, y) return Float64(1.0 - Float64(x / Float64(y + -1.0))) end
function tmp = code(x, y) tmp = 1.0 - (x / (y + -1.0)); end
code[x_, y_] := N[(1.0 - N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{y + -1}
\end{array}
Initial program 73.9%
sub-neg73.9%
log1p-define73.9%
distribute-neg-frac273.9%
neg-sub073.9%
associate--r-73.9%
metadata-eval73.9%
+-commutative73.9%
Simplified73.9%
Taylor expanded in x around inf 75.1%
Taylor expanded in x around 0 44.4%
Final simplification44.4%
(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.9%
sub-neg73.9%
log1p-define73.9%
distribute-neg-frac273.9%
neg-sub073.9%
associate--r-73.9%
metadata-eval73.9%
+-commutative73.9%
Simplified73.9%
Taylor expanded in x around inf 75.1%
Taylor expanded in x around 0 42.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 2024116
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:alt
(! :herbie-platform default (if (< y -8128475261947241/100000000) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))) (if (< y 30094271212461764000000000) (log (/ (exp 1) (- 1 (/ (- x y) (- 1 y))))) (- 1 (log (- (/ x (* y y)) (- (/ 1 y) (/ x y))))))))
(- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))