
(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 9 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 (<= (/ (- x y) (- 1.0 y)) 2e-5) (- 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)) <= 2e-5) {
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)) <= 2e-5) {
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)) <= 2e-5: 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)) <= 2e-5) 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], 2e-5], 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 2 \cdot 10^{-5}:\\
\;\;\;\;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 1 y)) < 2.00000000000000016e-5Initial program 100.0%
sub-neg100.0%
log1p-define100.0%
distribute-neg-frac2100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
if 2.00000000000000016e-5 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 7.9%
sub-neg7.9%
log1p-define7.9%
distribute-neg-frac27.9%
neg-sub07.9%
associate--r-7.9%
metadata-eval7.9%
+-commutative7.9%
Simplified7.9%
Taylor expanded in y around -inf 85.5%
sub-neg85.5%
metadata-eval85.5%
distribute-lft-in85.5%
metadata-eval85.5%
+-commutative85.5%
log1p-define85.5%
mul-1-neg85.5%
Simplified85.5%
add-log-exp85.5%
sub-neg85.5%
exp-sum85.5%
add-log-exp85.5%
neg-log85.5%
exp-sum85.5%
add-exp-log85.7%
log1p-undefine85.7%
rem-exp-log99.3%
metadata-eval99.3%
distribute-neg-in99.3%
+-commutative99.3%
frac-2neg99.3%
metadata-eval99.3%
div-inv99.3%
frac-2neg99.3%
Applied egg-rr99.3%
exp-1-e99.3%
Simplified99.3%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (<= y -510.0)
(log (* E (/ y (+ x -1.0))))
(if (<= y 40000000000000.0)
(- 1.0 (log1p (/ x (+ y -1.0))))
(log (/ (* y E) x)))))
double code(double x, double y) {
double tmp;
if (y <= -510.0) {
tmp = log((((double) M_E) * (y / (x + -1.0))));
} else if (y <= 40000000000000.0) {
tmp = 1.0 - log1p((x / (y + -1.0)));
} else {
tmp = log(((y * ((double) M_E)) / x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -510.0) {
tmp = Math.log((Math.E * (y / (x + -1.0))));
} else if (y <= 40000000000000.0) {
tmp = 1.0 - Math.log1p((x / (y + -1.0)));
} else {
tmp = Math.log(((y * Math.E) / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -510.0: tmp = math.log((math.e * (y / (x + -1.0)))) elif y <= 40000000000000.0: tmp = 1.0 - math.log1p((x / (y + -1.0))) else: tmp = math.log(((y * math.e) / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= -510.0) tmp = log(Float64(exp(1) * Float64(y / Float64(x + -1.0)))); elseif (y <= 40000000000000.0) tmp = Float64(1.0 - log1p(Float64(x / Float64(y + -1.0)))); else tmp = log(Float64(Float64(y * exp(1)) / x)); end return tmp end
code[x_, y_] := If[LessEqual[y, -510.0], N[Log[N[(E * N[(y / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 40000000000000.0], N[(1.0 - N[Log[1 + N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(y * E), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -510:\\
\;\;\;\;\log \left(e \cdot \frac{y}{x + -1}\right)\\
\mathbf{elif}\;y \leq 40000000000000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{y \cdot e}{x}\right)\\
\end{array}
\end{array}
if y < -510Initial program 24.8%
sub-neg24.8%
log1p-define24.8%
distribute-neg-frac224.8%
neg-sub024.8%
associate--r-24.8%
metadata-eval24.8%
+-commutative24.8%
Simplified24.8%
Taylor expanded in y around -inf 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-lft-in98.5%
metadata-eval98.5%
+-commutative98.5%
log1p-define98.5%
mul-1-neg98.5%
Simplified98.5%
add-log-exp98.5%
sub-neg98.5%
exp-sum98.5%
add-log-exp98.5%
neg-log98.5%
exp-sum98.5%
add-exp-log98.5%
log1p-undefine98.5%
rem-exp-log98.9%
metadata-eval98.9%
distribute-neg-in98.9%
+-commutative98.9%
frac-2neg98.9%
metadata-eval98.9%
div-inv98.9%
frac-2neg98.9%
Applied egg-rr99.0%
exp-1-e99.0%
Simplified99.0%
if -510 < y < 4e13Initial 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 4e13 < y Initial program 63.3%
sub-neg63.3%
log1p-define63.3%
distribute-neg-frac263.3%
neg-sub063.3%
associate--r-63.3%
metadata-eval63.3%
+-commutative63.3%
Simplified63.3%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-define0.0%
mul-1-neg0.0%
Simplified0.0%
add-log-exp0.0%
sub-neg0.0%
exp-sum0.0%
add-log-exp0.0%
neg-log0.0%
exp-sum0.0%
add-exp-log0.0%
log1p-undefine0.0%
rem-exp-log99.9%
metadata-eval99.9%
distribute-neg-in99.9%
+-commutative99.9%
frac-2neg99.9%
metadata-eval99.9%
div-inv99.9%
frac-2neg99.9%
Applied egg-rr99.9%
exp-1-e99.9%
Simplified99.9%
Taylor expanded in x around inf 100.0%
Final simplification99.6%
(FPCore (x y) :precision binary64 (if (<= y -13.5) (log (* y (- E))) (if (<= y 1.0) (- (- 1.0 y) (log1p (- x))) (log (/ (* y E) x)))))
double code(double x, double y) {
double tmp;
if (y <= -13.5) {
tmp = log((y * -((double) M_E)));
} else if (y <= 1.0) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = log(((y * ((double) M_E)) / x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -13.5) {
tmp = Math.log((y * -Math.E));
} else if (y <= 1.0) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = Math.log(((y * Math.E) / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -13.5: tmp = math.log((y * -math.e)) elif y <= 1.0: tmp = (1.0 - y) - math.log1p(-x) else: tmp = math.log(((y * math.e) / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= -13.5) tmp = log(Float64(y * Float64(-exp(1)))); elseif (y <= 1.0) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = log(Float64(Float64(y * exp(1)) / x)); end return tmp end
code[x_, y_] := If[LessEqual[y, -13.5], N[Log[N[(y * (-E)), $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 1.0], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(y * E), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -13.5:\\
\;\;\;\;\log \left(y \cdot \left(-e\right)\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{y \cdot e}{x}\right)\\
\end{array}
\end{array}
if y < -13.5Initial program 24.8%
sub-neg24.8%
log1p-define24.8%
distribute-neg-frac224.8%
neg-sub024.8%
associate--r-24.8%
metadata-eval24.8%
+-commutative24.8%
Simplified24.8%
Taylor expanded in y around -inf 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-lft-in98.5%
metadata-eval98.5%
+-commutative98.5%
log1p-define98.5%
mul-1-neg98.5%
Simplified98.5%
add-log-exp98.5%
sub-neg98.5%
exp-sum98.5%
add-log-exp98.5%
neg-log98.5%
exp-sum98.5%
add-exp-log98.5%
log1p-undefine98.5%
rem-exp-log98.9%
metadata-eval98.9%
distribute-neg-in98.9%
+-commutative98.9%
frac-2neg98.9%
metadata-eval98.9%
div-inv98.9%
frac-2neg98.9%
Applied egg-rr99.0%
exp-1-e99.0%
Simplified99.0%
Taylor expanded in x around 0 66.6%
*-commutative66.6%
neg-mul-166.6%
distribute-lft-neg-in66.6%
Simplified66.6%
if -13.5 < 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.7%
Simplified99.7%
if 1 < y Initial program 64.8%
sub-neg64.8%
log1p-define64.8%
distribute-neg-frac264.8%
neg-sub064.8%
associate--r-64.8%
metadata-eval64.8%
+-commutative64.8%
Simplified64.8%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-define0.0%
mul-1-neg0.0%
Simplified0.0%
add-log-exp0.0%
sub-neg0.0%
exp-sum0.0%
add-log-exp0.0%
neg-log0.0%
exp-sum0.0%
add-exp-log0.0%
log1p-undefine0.0%
rem-exp-log98.7%
metadata-eval98.7%
distribute-neg-in98.7%
+-commutative98.7%
frac-2neg98.7%
metadata-eval98.7%
div-inv98.8%
frac-2neg98.8%
Applied egg-rr98.8%
exp-1-e98.8%
Simplified98.8%
Taylor expanded in x around inf 98.8%
Final simplification89.4%
(FPCore (x y) :precision binary64 (if (<= y -1.76) (log (* E (/ y (+ x -1.0)))) (if (<= y 1.0) (- (- 1.0 y) (log1p (- x))) (log (/ (* y E) x)))))
double code(double x, double y) {
double tmp;
if (y <= -1.76) {
tmp = log((((double) M_E) * (y / (x + -1.0))));
} else if (y <= 1.0) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = log(((y * ((double) M_E)) / x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1.76) {
tmp = Math.log((Math.E * (y / (x + -1.0))));
} else if (y <= 1.0) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = Math.log(((y * Math.E) / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.76: tmp = math.log((math.e * (y / (x + -1.0)))) elif y <= 1.0: tmp = (1.0 - y) - math.log1p(-x) else: tmp = math.log(((y * math.e) / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.76) 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 = log(Float64(Float64(y * exp(1)) / x)); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.76], 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[Log[N[(N[(y * E), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.76:\\
\;\;\;\;\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}:\\
\;\;\;\;\log \left(\frac{y \cdot e}{x}\right)\\
\end{array}
\end{array}
if y < -1.76000000000000001Initial program 24.8%
sub-neg24.8%
log1p-define24.8%
distribute-neg-frac224.8%
neg-sub024.8%
associate--r-24.8%
metadata-eval24.8%
+-commutative24.8%
Simplified24.8%
Taylor expanded in y around -inf 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-lft-in98.5%
metadata-eval98.5%
+-commutative98.5%
log1p-define98.5%
mul-1-neg98.5%
Simplified98.5%
add-log-exp98.5%
sub-neg98.5%
exp-sum98.5%
add-log-exp98.5%
neg-log98.5%
exp-sum98.5%
add-exp-log98.5%
log1p-undefine98.5%
rem-exp-log98.9%
metadata-eval98.9%
distribute-neg-in98.9%
+-commutative98.9%
frac-2neg98.9%
metadata-eval98.9%
div-inv98.9%
frac-2neg98.9%
Applied egg-rr99.0%
exp-1-e99.0%
Simplified99.0%
if -1.76000000000000001 < 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.7%
Simplified99.7%
if 1 < y Initial program 64.8%
sub-neg64.8%
log1p-define64.8%
distribute-neg-frac264.8%
neg-sub064.8%
associate--r-64.8%
metadata-eval64.8%
+-commutative64.8%
Simplified64.8%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-define0.0%
mul-1-neg0.0%
Simplified0.0%
add-log-exp0.0%
sub-neg0.0%
exp-sum0.0%
add-log-exp0.0%
neg-log0.0%
exp-sum0.0%
add-exp-log0.0%
log1p-undefine0.0%
rem-exp-log98.7%
metadata-eval98.7%
distribute-neg-in98.7%
+-commutative98.7%
frac-2neg98.7%
metadata-eval98.7%
div-inv98.8%
frac-2neg98.8%
Applied egg-rr98.8%
exp-1-e98.8%
Simplified98.8%
Taylor expanded in x around inf 98.8%
Final simplification99.4%
(FPCore (x y) :precision binary64 (if (<= y -22.0) (log (* y (- E))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (log (/ (* y E) x)))))
double code(double x, double y) {
double tmp;
if (y <= -22.0) {
tmp = log((y * -((double) M_E)));
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = log(((y * ((double) M_E)) / x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -22.0) {
tmp = Math.log((y * -Math.E));
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = Math.log(((y * Math.E) / x));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -22.0: tmp = math.log((y * -math.e)) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = math.log(((y * math.e) / x)) return tmp
function code(x, y) tmp = 0.0 if (y <= -22.0) tmp = log(Float64(y * Float64(-exp(1)))); elseif (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = log(Float64(Float64(y * exp(1)) / x)); end return tmp end
code[x_, y_] := If[LessEqual[y, -22.0], N[Log[N[(y * (-E)), $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(y * E), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -22:\\
\;\;\;\;\log \left(y \cdot \left(-e\right)\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{y \cdot e}{x}\right)\\
\end{array}
\end{array}
if y < -22Initial program 24.8%
sub-neg24.8%
log1p-define24.8%
distribute-neg-frac224.8%
neg-sub024.8%
associate--r-24.8%
metadata-eval24.8%
+-commutative24.8%
Simplified24.8%
Taylor expanded in y around -inf 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-lft-in98.5%
metadata-eval98.5%
+-commutative98.5%
log1p-define98.5%
mul-1-neg98.5%
Simplified98.5%
add-log-exp98.5%
sub-neg98.5%
exp-sum98.5%
add-log-exp98.5%
neg-log98.5%
exp-sum98.5%
add-exp-log98.5%
log1p-undefine98.5%
rem-exp-log98.9%
metadata-eval98.9%
distribute-neg-in98.9%
+-commutative98.9%
frac-2neg98.9%
metadata-eval98.9%
div-inv98.9%
frac-2neg98.9%
Applied egg-rr99.0%
exp-1-e99.0%
Simplified99.0%
Taylor expanded in x around 0 66.6%
*-commutative66.6%
neg-mul-166.6%
distribute-lft-neg-in66.6%
Simplified66.6%
if -22 < 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.5%
log1p-define99.6%
mul-1-neg99.6%
Simplified99.6%
if 1 < y Initial program 64.8%
sub-neg64.8%
log1p-define64.8%
distribute-neg-frac264.8%
neg-sub064.8%
associate--r-64.8%
metadata-eval64.8%
+-commutative64.8%
Simplified64.8%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-define0.0%
mul-1-neg0.0%
Simplified0.0%
add-log-exp0.0%
sub-neg0.0%
exp-sum0.0%
add-log-exp0.0%
neg-log0.0%
exp-sum0.0%
add-exp-log0.0%
log1p-undefine0.0%
rem-exp-log98.7%
metadata-eval98.7%
distribute-neg-in98.7%
+-commutative98.7%
frac-2neg98.7%
metadata-eval98.7%
div-inv98.8%
frac-2neg98.8%
Applied egg-rr98.8%
exp-1-e98.8%
Simplified98.8%
Taylor expanded in x around inf 98.8%
Final simplification89.3%
(FPCore (x y) :precision binary64 (if (<= y -1.35) (log (* y (- E))) (+ 1.0 (/ x (- 1.0 y)))))
double code(double x, double y) {
double tmp;
if (y <= -1.35) {
tmp = log((y * -((double) M_E)));
} else {
tmp = 1.0 + (x / (1.0 - y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1.35) {
tmp = Math.log((y * -Math.E));
} else {
tmp = 1.0 + (x / (1.0 - y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.35: tmp = math.log((y * -math.e)) else: tmp = 1.0 + (x / (1.0 - y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.35) tmp = log(Float64(y * Float64(-exp(1)))); else tmp = Float64(1.0 + Float64(x / Float64(1.0 - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.35) tmp = log((y * -2.71828182845904523536)); else tmp = 1.0 + (x / (1.0 - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.35], N[Log[N[(y * (-E)), $MachinePrecision]], $MachinePrecision], N[(1.0 + N[(x / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35:\\
\;\;\;\;\log \left(y \cdot \left(-e\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{x}{1 - y}\\
\end{array}
\end{array}
if y < -1.3500000000000001Initial program 24.8%
sub-neg24.8%
log1p-define24.8%
distribute-neg-frac224.8%
neg-sub024.8%
associate--r-24.8%
metadata-eval24.8%
+-commutative24.8%
Simplified24.8%
Taylor expanded in y around -inf 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-lft-in98.5%
metadata-eval98.5%
+-commutative98.5%
log1p-define98.5%
mul-1-neg98.5%
Simplified98.5%
add-log-exp98.5%
sub-neg98.5%
exp-sum98.5%
add-log-exp98.5%
neg-log98.5%
exp-sum98.5%
add-exp-log98.5%
log1p-undefine98.5%
rem-exp-log98.9%
metadata-eval98.9%
distribute-neg-in98.9%
+-commutative98.9%
frac-2neg98.9%
metadata-eval98.9%
div-inv98.9%
frac-2neg98.9%
Applied egg-rr99.0%
exp-1-e99.0%
Simplified99.0%
Taylor expanded in x around 0 66.6%
*-commutative66.6%
neg-mul-166.6%
distribute-lft-neg-in66.6%
Simplified66.6%
if -1.3500000000000001 < y Initial program 95.0%
sub-neg95.0%
log1p-define95.0%
distribute-neg-frac295.0%
neg-sub095.0%
associate--r-95.0%
metadata-eval95.0%
+-commutative95.0%
Simplified95.0%
add-cbrt-cube70.4%
pow1/353.3%
pow353.3%
Applied egg-rr53.3%
Taylor expanded in x around inf 53.8%
sub-neg53.8%
metadata-eval53.8%
cube-div58.4%
+-commutative58.4%
Simplified58.4%
Taylor expanded in x around 0 58.3%
mul-1-neg58.3%
sub-neg58.3%
metadata-eval58.3%
distribute-neg-frac258.3%
distribute-neg-in58.3%
metadata-eval58.3%
+-commutative58.3%
unsub-neg58.3%
Simplified58.3%
Final simplification60.9%
(FPCore (x y) :precision binary64 (if (<= y -54.0) (log (* y (- E))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -54.0) {
tmp = log((y * -((double) M_E)));
} else {
tmp = 1.0 - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -54.0) {
tmp = Math.log((y * -Math.E));
} else {
tmp = 1.0 - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -54.0: tmp = math.log((y * -math.e)) else: tmp = 1.0 - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if (y <= -54.0) tmp = log(Float64(y * Float64(-exp(1)))); else tmp = Float64(1.0 - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[LessEqual[y, -54.0], N[Log[N[(y * (-E)), $MachinePrecision]], $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -54:\\
\;\;\;\;\log \left(y \cdot \left(-e\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -54Initial program 24.8%
sub-neg24.8%
log1p-define24.8%
distribute-neg-frac224.8%
neg-sub024.8%
associate--r-24.8%
metadata-eval24.8%
+-commutative24.8%
Simplified24.8%
Taylor expanded in y around -inf 98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-lft-in98.5%
metadata-eval98.5%
+-commutative98.5%
log1p-define98.5%
mul-1-neg98.5%
Simplified98.5%
add-log-exp98.5%
sub-neg98.5%
exp-sum98.5%
add-log-exp98.5%
neg-log98.5%
exp-sum98.5%
add-exp-log98.5%
log1p-undefine98.5%
rem-exp-log98.9%
metadata-eval98.9%
distribute-neg-in98.9%
+-commutative98.9%
frac-2neg98.9%
metadata-eval98.9%
div-inv98.9%
frac-2neg98.9%
Applied egg-rr99.0%
exp-1-e99.0%
Simplified99.0%
Taylor expanded in x around 0 66.6%
*-commutative66.6%
neg-mul-166.6%
distribute-lft-neg-in66.6%
Simplified66.6%
if -54 < y Initial program 95.0%
sub-neg95.0%
log1p-define95.0%
distribute-neg-frac295.0%
neg-sub095.0%
associate--r-95.0%
metadata-eval95.0%
+-commutative95.0%
Simplified95.0%
Taylor expanded in y around 0 85.5%
log1p-define85.5%
mul-1-neg85.5%
Simplified85.5%
Final simplification79.7%
(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.4%
sub-neg73.4%
log1p-define73.4%
distribute-neg-frac273.4%
neg-sub073.4%
associate--r-73.4%
metadata-eval73.4%
+-commutative73.4%
Simplified73.4%
add-cbrt-cube52.9%
pow1/339.3%
pow339.3%
Applied egg-rr39.3%
Taylor expanded in x around inf 41.3%
sub-neg41.3%
metadata-eval41.3%
cube-div45.9%
+-commutative45.9%
Simplified45.9%
Taylor expanded in x around 0 44.2%
mul-1-neg44.2%
sub-neg44.2%
metadata-eval44.2%
distribute-neg-frac244.2%
distribute-neg-in44.2%
metadata-eval44.2%
+-commutative44.2%
unsub-neg44.2%
Simplified44.2%
Final simplification44.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 73.4%
sub-neg73.4%
log1p-define73.4%
distribute-neg-frac273.4%
neg-sub073.4%
associate--r-73.4%
metadata-eval73.4%
+-commutative73.4%
Simplified73.4%
add-cbrt-cube52.9%
pow1/339.3%
pow339.3%
Applied egg-rr39.3%
Taylor expanded in x around inf 41.3%
sub-neg41.3%
metadata-eval41.3%
cube-div45.9%
+-commutative45.9%
Simplified45.9%
Taylor expanded in x around 0 42.6%
Final simplification42.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 2024096
(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))))))