
(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
(let* ((t_0 (/ E (- 1.0 x))))
(if (<= (/ (- x y) (- 1.0 y)) 0.6)
(- 1.0 (log1p (* x (- (/ 1.0 (+ y -1.0)) (/ y (* x (+ y -1.0)))))))
(log1p
(+ t_0 (fma y (* t_0 (+ (/ x (- 1.0 x)) (/ -1.0 (- 1.0 x)))) -1.0))))))
double code(double x, double y) {
double t_0 = ((double) M_E) / (1.0 - x);
double tmp;
if (((x - y) / (1.0 - y)) <= 0.6) {
tmp = 1.0 - log1p((x * ((1.0 / (y + -1.0)) - (y / (x * (y + -1.0))))));
} else {
tmp = log1p((t_0 + fma(y, (t_0 * ((x / (1.0 - x)) + (-1.0 / (1.0 - x)))), -1.0)));
}
return tmp;
}
function code(x, y) t_0 = Float64(exp(1) / Float64(1.0 - x)) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.6) tmp = Float64(1.0 - log1p(Float64(x * Float64(Float64(1.0 / Float64(y + -1.0)) - Float64(y / Float64(x * Float64(y + -1.0))))))); else tmp = log1p(Float64(t_0 + fma(y, Float64(t_0 * Float64(Float64(x / Float64(1.0 - x)) + Float64(-1.0 / Float64(1.0 - x)))), -1.0))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(E / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.6], N[(1.0 - N[Log[1 + N[(x * N[(N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - N[(y / N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Log[1 + N[(t$95$0 + N[(y * N[(t$95$0 * N[(N[(x / N[(1.0 - x), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{e}{1 - x}\\
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.6:\\
\;\;\;\;1 - \mathsf{log1p}\left(x \cdot \left(\frac{1}{y + -1} - \frac{y}{x \cdot \left(y + -1\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(t\_0 + \mathsf{fma}\left(y, t\_0 \cdot \left(\frac{x}{1 - x} + \frac{-1}{1 - x}\right), -1\right)\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) < 0.599999999999999978Initial 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 x around inf 100.0%
+-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
mul-1-neg100.0%
unsub-neg100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
if 0.599999999999999978 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) Initial program 6.5%
sub-neg6.5%
log1p-define6.5%
distribute-neg-frac26.5%
neg-sub06.5%
associate--r-6.5%
metadata-eval6.5%
+-commutative6.5%
Simplified6.5%
log1p-expm1-u6.5%
Applied egg-rr6.5%
Taylor expanded in y around 0 82.8%
associate--l+82.8%
exp-diff82.8%
exp-1-e82.8%
rem-exp-log82.8%
mul-1-neg82.8%
sub-neg82.8%
fma-neg82.8%
Simplified100.0%
Final simplification100.0%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.99999995) (- 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.99999995) {
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.99999995) {
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.99999995: 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.99999995) 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.99999995], 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.99999995:\\
\;\;\;\;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.999999949999999971Initial program 99.6%
sub-neg99.6%
log1p-define99.7%
distribute-neg-frac299.7%
neg-sub099.7%
associate--r-99.7%
metadata-eval99.7%
+-commutative99.7%
Simplified99.7%
if 0.999999949999999971 < (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y)) Initial program 3.7%
sub-neg3.7%
log1p-define3.7%
distribute-neg-frac23.7%
neg-sub03.7%
associate--r-3.7%
metadata-eval3.7%
+-commutative3.7%
Simplified3.7%
Taylor expanded in y around -inf 82.0%
sub-neg82.0%
metadata-eval82.0%
distribute-lft-in82.0%
metadata-eval82.0%
+-commutative82.0%
log1p-define82.0%
mul-1-neg82.0%
Simplified82.0%
add-log-exp82.0%
sub-neg82.0%
exp-sum82.0%
add-log-exp82.0%
neg-log82.0%
exp-sum82.0%
add-exp-log82.1%
log1p-undefine82.1%
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%
+-commutative99.9%
Simplified99.9%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= y -1.7) (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.7) || !(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.7) || !(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.7) 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.7) || !(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.7], 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.7 \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.69999999999999996 or 1 < y Initial program 24.1%
sub-neg24.1%
log1p-define24.1%
distribute-neg-frac224.1%
neg-sub024.1%
associate--r-24.1%
metadata-eval24.1%
+-commutative24.1%
Simplified24.1%
Taylor expanded in y around -inf 74.6%
sub-neg74.6%
metadata-eval74.6%
distribute-lft-in74.6%
metadata-eval74.6%
+-commutative74.6%
log1p-define74.6%
mul-1-neg74.6%
Simplified74.6%
add-log-exp74.6%
sub-neg74.6%
exp-sum74.6%
add-log-exp74.6%
neg-log74.6%
exp-sum74.6%
add-exp-log74.6%
log1p-undefine74.6%
rem-exp-log98.6%
metadata-eval98.6%
distribute-neg-in98.6%
+-commutative98.6%
frac-2neg98.6%
metadata-eval98.6%
div-inv98.6%
frac-2neg98.6%
Applied egg-rr98.6%
exp-1-e98.6%
+-commutative98.6%
Simplified98.6%
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.2%
Simplified98.2%
Final simplification98.4%
(FPCore (x y) :precision binary64 (if (<= y -16.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- (- 1.0 y) (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -16.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = 1.0 - log1p((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -16.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 1.0) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -16.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = (1.0 - y) - math.log1p(-x) else: tmp = 1.0 - math.log1p((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -16.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = Float64(1.0 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -16.0], N[(1.0 - N[Log[N[(-1.0 / y), $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[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -16:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -16Initial program 18.1%
sub-neg18.1%
log1p-define18.1%
distribute-neg-frac218.1%
neg-sub018.1%
associate--r-18.1%
metadata-eval18.1%
+-commutative18.1%
Simplified18.1%
Taylor expanded in y around inf 17.0%
+-commutative17.0%
associate--r+17.0%
sub-neg17.0%
div-sub17.0%
sub-neg17.0%
metadata-eval17.0%
metadata-eval17.0%
Simplified17.0%
Taylor expanded in x around 0 76.3%
distribute-neg-frac76.3%
metadata-eval76.3%
Simplified76.3%
if -16 < 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.2%
Simplified98.2%
if 1 < y Initial program 43.5%
sub-neg43.5%
log1p-define43.5%
distribute-neg-frac243.5%
neg-sub043.5%
associate--r-43.5%
metadata-eval43.5%
+-commutative43.5%
Simplified43.5%
Taylor expanded in y around inf 43.5%
+-commutative43.5%
associate--r+43.5%
sub-neg43.5%
div-sub43.5%
sub-neg43.5%
metadata-eval43.5%
metadata-eval43.5%
Simplified43.5%
Taylor expanded in x around inf 49.9%
Final simplification87.1%
(FPCore (x y) :precision binary64 (if (<= y -70000.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -70000.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log1p((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -70000.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -70000.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log1p((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -70000.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = Float64(1.0 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -70000.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -70000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -7e4Initial program 17.0%
sub-neg17.0%
log1p-define17.0%
distribute-neg-frac217.0%
neg-sub017.0%
associate--r-17.0%
metadata-eval17.0%
+-commutative17.0%
Simplified17.0%
Taylor expanded in y around inf 16.5%
+-commutative16.5%
associate--r+16.5%
sub-neg16.5%
div-sub16.5%
sub-neg16.5%
metadata-eval16.5%
metadata-eval16.5%
Simplified16.5%
Taylor expanded in x around 0 77.3%
distribute-neg-frac77.3%
metadata-eval77.3%
Simplified77.3%
if -7e4 < 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 96.3%
log1p-define96.3%
mul-1-neg96.3%
Simplified96.3%
if 1 < y Initial program 43.5%
sub-neg43.5%
log1p-define43.5%
distribute-neg-frac243.5%
neg-sub043.5%
associate--r-43.5%
metadata-eval43.5%
+-commutative43.5%
Simplified43.5%
Taylor expanded in y around inf 43.5%
+-commutative43.5%
associate--r+43.5%
sub-neg43.5%
div-sub43.5%
sub-neg43.5%
metadata-eval43.5%
metadata-eval43.5%
Simplified43.5%
Taylor expanded in x around inf 49.9%
Final simplification86.3%
(FPCore (x y) :precision binary64 (if (<= y -70000.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -70000.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 <= -70000.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 <= -70000.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 <= -70000.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, -70000.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 -70000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -7e4Initial program 17.0%
sub-neg17.0%
log1p-define17.0%
distribute-neg-frac217.0%
neg-sub017.0%
associate--r-17.0%
metadata-eval17.0%
+-commutative17.0%
Simplified17.0%
Taylor expanded in y around inf 16.5%
+-commutative16.5%
associate--r+16.5%
sub-neg16.5%
div-sub16.5%
sub-neg16.5%
metadata-eval16.5%
metadata-eval16.5%
Simplified16.5%
Taylor expanded in x around 0 77.3%
distribute-neg-frac77.3%
metadata-eval77.3%
Simplified77.3%
if -7e4 < y Initial program 92.4%
sub-neg92.4%
log1p-define92.4%
distribute-neg-frac292.4%
neg-sub092.4%
associate--r-92.4%
metadata-eval92.4%
+-commutative92.4%
Simplified92.4%
Taylor expanded in y around 0 83.4%
log1p-define83.4%
mul-1-neg83.4%
Simplified83.4%
Final simplification81.6%
(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.0%
sub-neg70.0%
log1p-define70.0%
distribute-neg-frac270.0%
neg-sub070.0%
associate--r-70.0%
metadata-eval70.0%
+-commutative70.0%
Simplified70.0%
Taylor expanded in y around 0 62.5%
log1p-define62.5%
mul-1-neg62.5%
Simplified62.5%
Final simplification62.5%
(FPCore (x y) :precision binary64 (- (+ x 1.0) y))
double code(double x, double y) {
return (x + 1.0) - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x + 1.0d0) - y
end function
public static double code(double x, double y) {
return (x + 1.0) - y;
}
def code(x, y): return (x + 1.0) - y
function code(x, y) return Float64(Float64(x + 1.0) - y) end
function tmp = code(x, y) tmp = (x + 1.0) - y; end
code[x_, y_] := N[(N[(x + 1.0), $MachinePrecision] - y), $MachinePrecision]
\begin{array}{l}
\\
\left(x + 1\right) - y
\end{array}
Initial program 70.0%
sub-neg70.0%
log1p-define70.0%
distribute-neg-frac270.0%
neg-sub070.0%
associate--r-70.0%
metadata-eval70.0%
+-commutative70.0%
Simplified70.0%
Taylor expanded in y around 0 60.9%
Simplified60.9%
Taylor expanded in x around 0 44.8%
Final simplification44.8%
(FPCore (x y) :precision binary64 (- 1.0 y))
double code(double x, double y) {
return 1.0 - y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - y
end function
public static double code(double x, double y) {
return 1.0 - y;
}
def code(x, y): return 1.0 - y
function code(x, y) return Float64(1.0 - y) end
function tmp = code(x, y) tmp = 1.0 - y; end
code[x_, y_] := N[(1.0 - y), $MachinePrecision]
\begin{array}{l}
\\
1 - y
\end{array}
Initial program 70.0%
sub-neg70.0%
log1p-define70.0%
distribute-neg-frac270.0%
neg-sub070.0%
associate--r-70.0%
metadata-eval70.0%
+-commutative70.0%
Simplified70.0%
Taylor expanded in y around 0 60.9%
Simplified60.9%
Taylor expanded in x around 0 43.7%
Final simplification43.7%
(FPCore (x y) :precision binary64 (- y))
double code(double x, double y) {
return -y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = -y
end function
public static double code(double x, double y) {
return -y;
}
def code(x, y): return -y
function code(x, y) return Float64(-y) end
function tmp = code(x, y) tmp = -y; end
code[x_, y_] := (-y)
\begin{array}{l}
\\
-y
\end{array}
Initial program 70.0%
sub-neg70.0%
log1p-define70.0%
distribute-neg-frac270.0%
neg-sub070.0%
associate--r-70.0%
metadata-eval70.0%
+-commutative70.0%
Simplified70.0%
Taylor expanded in y around 0 60.9%
Simplified60.9%
Taylor expanded in y around inf 4.1%
neg-mul-14.1%
Simplified4.1%
Final simplification4.1%
(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 2024076
(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))))))