
(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 (log (* y (+ (/ E (* y (- 1.0 x))) (/ E (+ x -1.0))))))
double code(double x, double y) {
return log((y * ((((double) M_E) / (y * (1.0 - x))) + (((double) M_E) / (x + -1.0)))));
}
public static double code(double x, double y) {
return Math.log((y * ((Math.E / (y * (1.0 - x))) + (Math.E / (x + -1.0)))));
}
def code(x, y): return math.log((y * ((math.e / (y * (1.0 - x))) + (math.e / (x + -1.0)))))
function code(x, y) return log(Float64(y * Float64(Float64(exp(1) / Float64(y * Float64(1.0 - x))) + Float64(exp(1) / Float64(x + -1.0))))) end
function tmp = code(x, y) tmp = log((y * ((2.71828182845904523536 / (y * (1.0 - x))) + (2.71828182845904523536 / (x + -1.0))))); end
code[x_, y_] := N[Log[N[(y * N[(N[(E / N[(y * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(E / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\log \left(y \cdot \left(\frac{e}{y \cdot \left(1 - x\right)} + \frac{e}{x + -1}\right)\right)
\end{array}
Initial program 70.5%
sub-neg70.5%
log1p-define70.6%
distribute-neg-frac270.6%
neg-sub070.6%
associate--r-70.6%
metadata-eval70.6%
+-commutative70.6%
Simplified70.6%
Taylor expanded in y around -inf 34.8%
Simplified34.8%
associate--r+34.8%
add-log-exp34.4%
exp-diff34.4%
+-commutative34.4%
exp-sum34.4%
add-exp-log34.8%
Applied egg-rr34.8%
exp-diff34.8%
exp-1-e34.8%
log1p-undefine34.8%
neg-mul-134.8%
rem-exp-log45.6%
neg-mul-145.6%
sub-neg45.6%
associate-*l/45.6%
mul-1-neg45.6%
Simplified45.6%
Taylor expanded in y around inf 99.9%
+-commutative99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.99998) (- 1.0 (log1p (/ (- x y) (+ y -1.0)))) (log (* E (/ y (+ x -1.0))))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99998) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = log((((double) M_E) * (y / (x + -1.0))));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.99998) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = Math.log((Math.E * (y / (x + -1.0))));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.99998: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = math.log((math.e * (y / (x + -1.0)))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.99998) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = log(Float64(exp(1) * Float64(y / Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.99998], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[N[(E * N[(y / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.99998:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(e \cdot \frac{y}{x + -1}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < 0.99997999999999998Initial program 99.8%
sub-neg99.8%
log1p-define99.9%
distribute-neg-frac299.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
if 0.99997999999999998 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) Initial program 6.1%
sub-neg6.1%
log1p-define6.1%
distribute-neg-frac26.1%
neg-sub06.1%
associate--r-6.1%
metadata-eval6.1%
+-commutative6.1%
Simplified6.1%
Taylor expanded in y around inf 6.1%
+-commutative6.1%
associate--r+6.1%
sub-neg6.1%
div-sub6.1%
sub-neg6.1%
metadata-eval6.1%
metadata-eval6.1%
Simplified6.1%
*-un-lft-identity6.1%
+-commutative6.1%
Applied egg-rr6.1%
*-lft-identity6.1%
log1p-define6.1%
associate-+r+99.2%
metadata-eval99.2%
+-lft-identity99.2%
+-commutative99.2%
Simplified99.2%
add-log-exp99.2%
sub-neg99.2%
exp-sum99.2%
e-exp-199.2%
neg-log99.2%
clear-num99.2%
add-exp-log99.2%
+-commutative99.2%
Applied egg-rr99.2%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.75) (not (<= y 1.0))) (log (* E (/ y (+ x -1.0)))) (- (- 1.0 y) (log1p (- x)))))
double code(double x, double y) {
double tmp;
if ((y <= -1.75) || !(y <= 1.0)) {
tmp = log((((double) M_E) * (y / (x + -1.0))));
} else {
tmp = (1.0 - y) - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((y <= -1.75) || !(y <= 1.0)) {
tmp = Math.log((Math.E * (y / (x + -1.0))));
} else {
tmp = (1.0 - y) - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.75) or not (y <= 1.0): tmp = math.log((math.e * (y / (x + -1.0)))) else: tmp = (1.0 - y) - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.75) || !(y <= 1.0)) tmp = log(Float64(exp(1) * Float64(y / Float64(x + -1.0)))); else tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -1.75], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[Log[N[(E * N[(y / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;\log \left(e \cdot \frac{y}{x + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -1.75 or 1 < y Initial program 35.1%
sub-neg35.1%
log1p-define35.1%
distribute-neg-frac235.1%
neg-sub035.1%
associate--r-35.1%
metadata-eval35.1%
+-commutative35.1%
Simplified35.1%
Taylor expanded in y around inf 32.5%
+-commutative32.5%
associate--r+32.5%
sub-neg32.5%
div-sub32.5%
sub-neg32.5%
metadata-eval32.5%
metadata-eval32.5%
Simplified32.5%
*-un-lft-identity32.5%
+-commutative32.5%
Applied egg-rr32.5%
*-lft-identity32.5%
log1p-define32.5%
associate-+r+96.7%
metadata-eval96.7%
+-lft-identity96.7%
+-commutative96.7%
Simplified96.7%
add-log-exp96.7%
sub-neg96.7%
exp-sum96.7%
e-exp-196.7%
neg-log96.7%
clear-num96.7%
add-exp-log96.7%
+-commutative96.7%
Applied egg-rr96.7%
if -1.75 < y < 1Initial program 99.9%
sub-neg99.9%
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 98.4%
Simplified98.4%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (<= y -1.85) (log (* E (/ y (+ x -1.0)))) (if (<= y 1.0) (- (- 1.0 y) (log1p (- x))) (- 1.0 (log (/ (+ x -1.0) y))))))
double code(double x, double y) {
double tmp;
if (y <= -1.85) {
tmp = log((((double) M_E) * (y / (x + -1.0))));
} else if (y <= 1.0) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = 1.0 - log(((x + -1.0) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1.85) {
tmp = Math.log((Math.E * (y / (x + -1.0))));
} else if (y <= 1.0) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log(((x + -1.0) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.85: tmp = math.log((math.e * (y / (x + -1.0)))) elif y <= 1.0: tmp = (1.0 - y) - math.log1p(-x) else: tmp = 1.0 - math.log(((x + -1.0) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.85) tmp = log(Float64(exp(1) * Float64(y / Float64(x + -1.0)))); elseif (y <= 1.0) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.85], N[Log[N[(E * N[(y / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85:\\
\;\;\;\;\log \left(e \cdot \frac{y}{x + -1}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\end{array}
\end{array}
if y < -1.8500000000000001Initial program 25.4%
sub-neg25.4%
log1p-define25.4%
distribute-neg-frac225.4%
neg-sub025.4%
associate--r-25.4%
metadata-eval25.4%
+-commutative25.4%
Simplified25.4%
Taylor expanded in y around inf 22.8%
+-commutative22.8%
associate--r+22.8%
sub-neg22.8%
div-sub22.8%
sub-neg22.8%
metadata-eval22.8%
metadata-eval22.8%
Simplified22.8%
*-un-lft-identity22.8%
+-commutative22.8%
Applied egg-rr22.8%
*-lft-identity22.8%
log1p-define22.8%
associate-+r+96.4%
metadata-eval96.4%
+-lft-identity96.4%
+-commutative96.4%
Simplified96.4%
add-log-exp96.4%
sub-neg96.4%
exp-sum96.4%
e-exp-196.4%
neg-log96.4%
clear-num96.4%
add-exp-log96.4%
+-commutative96.4%
Applied egg-rr96.4%
if -1.8500000000000001 < y < 1Initial program 99.9%
sub-neg99.9%
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 98.4%
Simplified98.4%
if 1 < y Initial program 65.4%
sub-neg65.4%
log1p-define65.4%
distribute-neg-frac265.4%
neg-sub065.4%
associate--r-65.4%
metadata-eval65.4%
+-commutative65.4%
Simplified65.4%
Taylor expanded in y around inf 63.2%
+-commutative63.2%
associate--r+63.2%
sub-neg63.2%
div-sub63.2%
sub-neg63.2%
metadata-eval63.2%
metadata-eval63.2%
Simplified63.2%
*-un-lft-identity63.2%
+-commutative63.2%
Applied egg-rr63.2%
*-lft-identity63.2%
log1p-define63.2%
associate-+r+97.8%
metadata-eval97.8%
+-lft-identity97.8%
+-commutative97.8%
Simplified97.8%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (<= y -1.7) (log (* y (/ E (+ x -1.0)))) (if (<= y 1.0) (- (- 1.0 y) (log1p (- x))) (- 1.0 (log (/ (+ x -1.0) y))))))
double code(double x, double y) {
double tmp;
if (y <= -1.7) {
tmp = log((y * (((double) M_E) / (x + -1.0))));
} else if (y <= 1.0) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = 1.0 - log(((x + -1.0) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1.7) {
tmp = Math.log((y * (Math.E / (x + -1.0))));
} else if (y <= 1.0) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log(((x + -1.0) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.7: tmp = math.log((y * (math.e / (x + -1.0)))) elif y <= 1.0: tmp = (1.0 - y) - math.log1p(-x) else: tmp = 1.0 - math.log(((x + -1.0) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.7) tmp = log(Float64(y * Float64(exp(1) / Float64(x + -1.0)))); elseif (y <= 1.0) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.7], N[Log[N[(y * N[(E / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7:\\
\;\;\;\;\log \left(y \cdot \frac{e}{x + -1}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\end{array}
\end{array}
if y < -1.69999999999999996Initial program 25.4%
sub-neg25.4%
log1p-define25.4%
distribute-neg-frac225.4%
neg-sub025.4%
associate--r-25.4%
metadata-eval25.4%
+-commutative25.4%
Simplified25.4%
Taylor expanded in y around -inf 97.8%
Simplified97.8%
associate--r+97.8%
add-log-exp97.8%
exp-diff97.8%
+-commutative97.8%
exp-sum97.8%
add-exp-log97.8%
Applied egg-rr97.8%
exp-diff97.8%
exp-1-e97.8%
log1p-undefine97.8%
neg-mul-197.8%
rem-exp-log98.1%
neg-mul-198.1%
sub-neg98.1%
associate-*l/98.1%
mul-1-neg98.1%
Simplified98.1%
Taylor expanded in y around inf 96.4%
mul-1-neg96.4%
associate-/l*96.5%
distribute-rgt-neg-in96.5%
distribute-neg-frac296.5%
neg-sub096.5%
sub-neg96.5%
associate--r+96.5%
metadata-eval96.5%
Simplified96.5%
if -1.69999999999999996 < y < 1Initial program 99.9%
sub-neg99.9%
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 98.4%
Simplified98.4%
if 1 < y Initial program 65.4%
sub-neg65.4%
log1p-define65.4%
distribute-neg-frac265.4%
neg-sub065.4%
associate--r-65.4%
metadata-eval65.4%
+-commutative65.4%
Simplified65.4%
Taylor expanded in y around inf 63.2%
+-commutative63.2%
associate--r+63.2%
sub-neg63.2%
div-sub63.2%
sub-neg63.2%
metadata-eval63.2%
metadata-eval63.2%
Simplified63.2%
*-un-lft-identity63.2%
+-commutative63.2%
Applied egg-rr63.2%
*-lft-identity63.2%
log1p-define63.2%
associate-+r+97.8%
metadata-eval97.8%
+-lft-identity97.8%
+-commutative97.8%
Simplified97.8%
Final simplification97.6%
(FPCore (x y) :precision binary64 (if (<= y -4.6) (- 1.0 (log (/ -1.0 y))) (- (- 1.0 y) (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -4.6) {
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 <= -4.6) {
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 <= -4.6: 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 <= -4.6) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -4.6], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -4.5999999999999996Initial program 25.4%
sub-neg25.4%
log1p-define25.4%
distribute-neg-frac225.4%
neg-sub025.4%
associate--r-25.4%
metadata-eval25.4%
+-commutative25.4%
Simplified25.4%
Taylor expanded in y around inf 22.8%
+-commutative22.8%
associate--r+22.8%
sub-neg22.8%
div-sub22.8%
sub-neg22.8%
metadata-eval22.8%
metadata-eval22.8%
Simplified22.8%
Taylor expanded in x around 0 71.4%
distribute-neg-frac71.4%
metadata-eval71.4%
Simplified71.4%
if -4.5999999999999996 < y Initial program 94.2%
sub-neg94.2%
log1p-define94.2%
distribute-neg-frac294.2%
neg-sub094.2%
associate--r-94.2%
metadata-eval94.2%
+-commutative94.2%
Simplified94.2%
Taylor expanded in y around 0 82.0%
Simplified82.0%
Final simplification78.3%
(FPCore (x y) :precision binary64 (if (<= y -4.5) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -4.5) {
tmp = 1.0 - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -4.5) {
tmp = 1.0 - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.5: tmp = 1.0 - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if (y <= -4.5) tmp = Float64(1.0 - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -4.5], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -4.5Initial program 25.4%
sub-neg25.4%
log1p-define25.4%
distribute-neg-frac225.4%
neg-sub025.4%
associate--r-25.4%
metadata-eval25.4%
+-commutative25.4%
Simplified25.4%
Taylor expanded in y around inf 22.8%
+-commutative22.8%
associate--r+22.8%
sub-neg22.8%
div-sub22.8%
sub-neg22.8%
metadata-eval22.8%
metadata-eval22.8%
Simplified22.8%
Taylor expanded in x around 0 71.4%
distribute-neg-frac71.4%
metadata-eval71.4%
Simplified71.4%
if -4.5 < y Initial program 94.2%
sub-neg94.2%
log1p-define94.2%
distribute-neg-frac294.2%
neg-sub094.2%
associate--r-94.2%
metadata-eval94.2%
+-commutative94.2%
Simplified94.2%
Taylor expanded in y around 0 81.0%
log1p-define81.1%
mul-1-neg81.1%
Simplified81.1%
Final simplification77.7%
(FPCore (x y) :precision binary64 (- 1.0 (log1p (- x))))
double code(double x, double y) {
return 1.0 - log1p(-x);
}
public static double code(double x, double y) {
return 1.0 - Math.log1p(-x);
}
def code(x, y): return 1.0 - math.log1p(-x)
function code(x, y) return Float64(1.0 - log1p(Float64(-x))) end
code[x_, y_] := N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \mathsf{log1p}\left(-x\right)
\end{array}
Initial program 70.5%
sub-neg70.5%
log1p-define70.6%
distribute-neg-frac270.6%
neg-sub070.6%
associate--r-70.6%
metadata-eval70.6%
+-commutative70.6%
Simplified70.6%
Taylor expanded in y around 0 57.9%
log1p-define57.9%
mul-1-neg57.9%
Simplified57.9%
Final simplification57.9%
(FPCore (x y) :precision binary64 (+ 1.0 x))
double code(double x, double y) {
return 1.0 + x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + x
end function
public static double code(double x, double y) {
return 1.0 + x;
}
def code(x, y): return 1.0 + x
function code(x, y) return Float64(1.0 + x) end
function tmp = code(x, y) tmp = 1.0 + x; end
code[x_, y_] := N[(1.0 + x), $MachinePrecision]
\begin{array}{l}
\\
1 + x
\end{array}
Initial program 70.5%
sub-neg70.5%
log1p-define70.6%
distribute-neg-frac270.6%
neg-sub070.6%
associate--r-70.6%
metadata-eval70.6%
+-commutative70.6%
Simplified70.6%
Taylor expanded in y around 0 57.9%
log1p-define57.9%
mul-1-neg57.9%
Simplified57.9%
Taylor expanded in x around 0 40.2%
Final simplification40.2%
(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 70.5%
sub-neg70.5%
log1p-define70.6%
distribute-neg-frac270.6%
neg-sub070.6%
associate--r-70.6%
metadata-eval70.6%
+-commutative70.6%
Simplified70.6%
Taylor expanded in y around 0 57.9%
log1p-define57.9%
mul-1-neg57.9%
Simplified57.9%
Taylor expanded in x around 0 39.7%
Final simplification39.7%
(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 2024115
(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))))))