
(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
(if (<= y -8600000000.0)
(+
1.0
(- (- (/ (- 1.0 x) (* y (+ x -1.0))) (log (/ -1.0 y))) (log1p (- x))))
(if (<= y 5000.0)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(- 1.0 (log (/ (+ 1.0 x) y))))))
double code(double x, double y) {
double tmp;
if (y <= -8600000000.0) {
tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - log((-1.0 / y))) - log1p(-x));
} else if (y <= 5000.0) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - log(((1.0 + x) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -8600000000.0) {
tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - Math.log((-1.0 / y))) - Math.log1p(-x));
} else if (y <= 5000.0) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - Math.log(((1.0 + x) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8600000000.0: tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - math.log((-1.0 / y))) - math.log1p(-x)) elif y <= 5000.0: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - math.log(((1.0 + x) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -8600000000.0) tmp = Float64(1.0 + Float64(Float64(Float64(Float64(1.0 - x) / Float64(y * Float64(x + -1.0))) - log(Float64(-1.0 / y))) - log1p(Float64(-x)))); elseif (y <= 5000.0) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - log(Float64(Float64(1.0 + x) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -8600000000.0], N[(1.0 + N[(N[(N[(N[(1.0 - x), $MachinePrecision] / N[(y * N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5000.0], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8600000000:\\
\;\;\;\;1 + \left(\left(\frac{1 - x}{y \cdot \left(x + -1\right)} - \log \left(\frac{-1}{y}\right)\right) - \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{elif}\;y \leq 5000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1 + x}{y}\right)\\
\end{array}
\end{array}
if y < -8.6e9Initial program 20.3%
sub-neg20.3%
log1p-def20.3%
distribute-neg-frac20.3%
sub-neg20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
+-commutative20.3%
sub-neg20.3%
Simplified20.3%
Taylor expanded in y around -inf 99.7%
sub-neg99.7%
metadata-eval99.7%
distribute-lft-in99.7%
metadata-eval99.7%
+-commutative99.7%
log1p-def99.7%
mul-1-neg99.7%
mul-1-neg99.7%
unsub-neg99.7%
div-sub99.7%
associate-/l/99.7%
sub-neg99.7%
metadata-eval99.7%
+-commutative99.7%
Simplified99.7%
if -8.6e9 < y < 5e3Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if 5e3 < y Initial program 41.1%
sub-neg41.1%
log1p-def41.1%
distribute-neg-frac41.1%
sub-neg41.1%
distribute-neg-in41.1%
remove-double-neg41.1%
+-commutative41.1%
sub-neg41.1%
Simplified41.1%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-def0.0%
mul-1-neg0.0%
Simplified0.0%
expm1-log1p-u0.0%
expm1-udef0.0%
Applied egg-rr31.0%
expm1-def31.0%
expm1-log1p99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y)
:precision binary64
(if (<= y -8600000000.0)
(- 1.0 (+ (log1p (- x)) (log (/ -1.0 y))))
(if (<= y 5000.0)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(- 1.0 (log (/ (+ 1.0 x) y))))))
double code(double x, double y) {
double tmp;
if (y <= -8600000000.0) {
tmp = 1.0 - (log1p(-x) + log((-1.0 / y)));
} else if (y <= 5000.0) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - log(((1.0 + x) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -8600000000.0) {
tmp = 1.0 - (Math.log1p(-x) + Math.log((-1.0 / y)));
} else if (y <= 5000.0) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - Math.log(((1.0 + x) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8600000000.0: tmp = 1.0 - (math.log1p(-x) + math.log((-1.0 / y))) elif y <= 5000.0: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - math.log(((1.0 + x) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -8600000000.0) tmp = Float64(1.0 - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (y <= 5000.0) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - log(Float64(Float64(1.0 + x) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -8600000000.0], N[(1.0 - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5000.0], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8600000000:\\
\;\;\;\;1 - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 5000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1 + x}{y}\right)\\
\end{array}
\end{array}
if y < -8.6e9Initial program 20.3%
sub-neg20.3%
log1p-def20.3%
distribute-neg-frac20.3%
sub-neg20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
+-commutative20.3%
sub-neg20.3%
Simplified20.3%
Taylor expanded in y around -inf 99.4%
sub-neg99.4%
metadata-eval99.4%
distribute-lft-in99.4%
metadata-eval99.4%
+-commutative99.4%
log1p-def99.4%
mul-1-neg99.4%
Simplified99.4%
if -8.6e9 < y < 5e3Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
if 5e3 < y Initial program 41.1%
sub-neg41.1%
log1p-def41.1%
distribute-neg-frac41.1%
sub-neg41.1%
distribute-neg-in41.1%
remove-double-neg41.1%
+-commutative41.1%
sub-neg41.1%
Simplified41.1%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-def0.0%
mul-1-neg0.0%
Simplified0.0%
expm1-log1p-u0.0%
expm1-udef0.0%
Applied egg-rr31.0%
expm1-def31.0%
expm1-log1p99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.999999998) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (+ 1.0 (- (/ -1.0 y) (log (/ -1.0 y))))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.999999998) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + ((-1.0 / y) - log((-1.0 / y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.999999998) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + ((-1.0 / y) - Math.log((-1.0 / y)));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.999999998: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 + ((-1.0 / y) - math.log((-1.0 / y))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.999999998) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 + Float64(Float64(-1.0 / y) - log(Float64(-1.0 / y)))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.999999998], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(-1.0 / y), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.999999998:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\frac{-1}{y} - \log \left(\frac{-1}{y}\right)\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.999999997999999946Initial program 99.7%
sub-neg99.7%
log1p-def99.7%
distribute-neg-frac99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
Simplified99.7%
if 0.999999997999999946 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 5.0%
sub-neg5.0%
log1p-def5.0%
distribute-neg-frac5.0%
sub-neg5.0%
distribute-neg-in5.0%
remove-double-neg5.0%
+-commutative5.0%
sub-neg5.0%
Simplified5.0%
Taylor expanded in x around 0 4.4%
log1p-def4.4%
Simplified4.4%
Taylor expanded in y around inf 0.0%
log-rec0.0%
associate-+r+0.0%
sub-neg0.0%
log-div68.5%
+-commutative68.5%
Simplified68.5%
Final simplification90.5%
(FPCore (x y)
:precision binary64
(if (<= y -7.5e+24)
(- 1.0 (log (/ -1.0 y)))
(if (<= y 5000.0)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(- 1.0 (log (/ (+ 1.0 x) y))))))
double code(double x, double y) {
double tmp;
if (y <= -7.5e+24) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 5000.0) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - log(((1.0 + x) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -7.5e+24) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 5000.0) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 - Math.log(((1.0 + x) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7.5e+24: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 5000.0: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 - math.log(((1.0 + x) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -7.5e+24) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 5000.0) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - log(Float64(Float64(1.0 + x) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -7.5e+24], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5000.0], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+24}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 5000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1 + x}{y}\right)\\
\end{array}
\end{array}
if y < -7.50000000000000014e24Initial program 16.2%
sub-neg16.2%
log1p-def16.2%
distribute-neg-frac16.2%
sub-neg16.2%
distribute-neg-in16.2%
remove-double-neg16.2%
+-commutative16.2%
sub-neg16.2%
Simplified16.2%
Taylor expanded in x around 0 2.8%
log1p-def2.8%
Simplified2.8%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.3%
Simplified69.3%
if -7.50000000000000014e24 < y < 5e3Initial program 98.8%
sub-neg98.8%
log1p-def98.8%
distribute-neg-frac98.8%
sub-neg98.8%
distribute-neg-in98.8%
remove-double-neg98.8%
+-commutative98.8%
sub-neg98.8%
Simplified98.8%
if 5e3 < y Initial program 41.1%
sub-neg41.1%
log1p-def41.1%
distribute-neg-frac41.1%
sub-neg41.1%
distribute-neg-in41.1%
remove-double-neg41.1%
+-commutative41.1%
sub-neg41.1%
Simplified41.1%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-def0.0%
mul-1-neg0.0%
Simplified0.0%
expm1-log1p-u0.0%
expm1-udef0.0%
Applied egg-rr31.0%
expm1-def31.0%
expm1-log1p99.9%
Simplified99.9%
Final simplification90.8%
(FPCore (x y)
:precision binary64
(if (<= y -6.6e+24)
(- 1.0 (log (/ -1.0 y)))
(if (<= y 5000.0)
(- 1.0 (log1p (/ (- x) (- 1.0 y))))
(- 1.0 (log (/ (+ 1.0 x) y))))))
double code(double x, double y) {
double tmp;
if (y <= -6.6e+24) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 5000.0) {
tmp = 1.0 - log1p((-x / (1.0 - y)));
} else {
tmp = 1.0 - log(((1.0 + x) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -6.6e+24) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 5000.0) {
tmp = 1.0 - Math.log1p((-x / (1.0 - y)));
} else {
tmp = 1.0 - Math.log(((1.0 + x) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -6.6e+24: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 5000.0: tmp = 1.0 - math.log1p((-x / (1.0 - y))) else: tmp = 1.0 - math.log(((1.0 + x) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -6.6e+24) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 5000.0) tmp = Float64(1.0 - log1p(Float64(Float64(-x) / Float64(1.0 - y)))); else tmp = Float64(1.0 - log(Float64(Float64(1.0 + x) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -6.6e+24], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5000.0], N[(1.0 - N[Log[1 + N[((-x) / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{+24}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 5000:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1 + x}{y}\right)\\
\end{array}
\end{array}
if y < -6.5999999999999998e24Initial program 16.2%
sub-neg16.2%
log1p-def16.2%
distribute-neg-frac16.2%
sub-neg16.2%
distribute-neg-in16.2%
remove-double-neg16.2%
+-commutative16.2%
sub-neg16.2%
Simplified16.2%
Taylor expanded in x around 0 2.8%
log1p-def2.8%
Simplified2.8%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div69.3%
Simplified69.3%
if -6.5999999999999998e24 < y < 5e3Initial program 98.8%
sub-neg98.8%
log1p-def98.8%
distribute-neg-frac98.8%
sub-neg98.8%
distribute-neg-in98.8%
remove-double-neg98.8%
+-commutative98.8%
sub-neg98.8%
Simplified98.8%
Taylor expanded in x around inf 97.7%
neg-mul-197.7%
distribute-neg-frac97.7%
Simplified97.7%
if 5e3 < y Initial program 41.1%
sub-neg41.1%
log1p-def41.1%
distribute-neg-frac41.1%
sub-neg41.1%
distribute-neg-in41.1%
remove-double-neg41.1%
+-commutative41.1%
sub-neg41.1%
Simplified41.1%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-def0.0%
mul-1-neg0.0%
Simplified0.0%
expm1-log1p-u0.0%
expm1-udef0.0%
Applied egg-rr31.0%
expm1-def31.0%
expm1-log1p99.9%
Simplified99.9%
Final simplification90.1%
(FPCore (x y) :precision binary64 (if (<= y -8600000000.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log (/ (+ 1.0 x) y))))))
double code(double x, double y) {
double tmp;
if (y <= -8600000000.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log(((1.0 + x) / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -8600000000.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.log(((1.0 + x) / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8600000000.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log(((1.0 + x) / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -8600000000.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 - log(Float64(Float64(1.0 + x) / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -8600000000.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[N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8600000000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1 + x}{y}\right)\\
\end{array}
\end{array}
if y < -8.6e9Initial program 20.3%
sub-neg20.3%
log1p-def20.3%
distribute-neg-frac20.3%
sub-neg20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
+-commutative20.3%
sub-neg20.3%
Simplified20.3%
Taylor expanded in x around 0 4.0%
log1p-def4.0%
Simplified4.0%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div67.5%
Simplified67.5%
if -8.6e9 < y < 1Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 98.0%
log1p-def98.0%
mul-1-neg98.0%
Simplified98.0%
if 1 < y Initial program 44.0%
sub-neg44.0%
log1p-def44.0%
distribute-neg-frac44.0%
sub-neg44.0%
distribute-neg-in44.0%
remove-double-neg44.0%
+-commutative44.0%
sub-neg44.0%
Simplified44.0%
Taylor expanded in y around -inf 0.0%
sub-neg0.0%
metadata-eval0.0%
distribute-lft-in0.0%
metadata-eval0.0%
+-commutative0.0%
log1p-def0.0%
mul-1-neg0.0%
Simplified0.0%
expm1-log1p-u0.0%
expm1-udef0.0%
Applied egg-rr31.9%
expm1-def31.9%
expm1-log1p97.3%
Simplified97.3%
Final simplification88.9%
(FPCore (x y) :precision binary64 (if (<= y -8600000000.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 0.18) (- 1.0 (log1p (- x))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -8600000000.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 0.18) {
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 <= -8600000000.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 0.18) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8600000000.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 0.18: 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 <= -8600000000.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 0.18) 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, -8600000000.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.18], 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 -8600000000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 0.18:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -8.6e9Initial program 20.3%
sub-neg20.3%
log1p-def20.3%
distribute-neg-frac20.3%
sub-neg20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
+-commutative20.3%
sub-neg20.3%
Simplified20.3%
Taylor expanded in x around 0 4.0%
log1p-def4.0%
Simplified4.0%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div67.5%
Simplified67.5%
if -8.6e9 < y < 0.17999999999999999Initial program 100.0%
sub-neg100.0%
log1p-def100.0%
distribute-neg-frac100.0%
sub-neg100.0%
distribute-neg-in100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 98.5%
log1p-def98.5%
mul-1-neg98.5%
Simplified98.5%
if 0.17999999999999999 < y Initial program 46.7%
sub-neg46.7%
log1p-def46.7%
distribute-neg-frac46.7%
sub-neg46.7%
distribute-neg-in46.7%
remove-double-neg46.7%
+-commutative46.7%
sub-neg46.7%
Simplified46.7%
Taylor expanded in y around inf 39.7%
Taylor expanded in x around inf 40.7%
Final simplification84.6%
(FPCore (x y) :precision binary64 (if (<= y -8600000000.0) (- 1.0 (log (/ -1.0 y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if (y <= -8600000000.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 <= -8600000000.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 <= -8600000000.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 <= -8600000000.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, -8600000000.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 -8600000000:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -8.6e9Initial program 20.3%
sub-neg20.3%
log1p-def20.3%
distribute-neg-frac20.3%
sub-neg20.3%
distribute-neg-in20.3%
remove-double-neg20.3%
+-commutative20.3%
sub-neg20.3%
Simplified20.3%
Taylor expanded in x around 0 4.0%
log1p-def4.0%
Simplified4.0%
Taylor expanded in y around inf 0.0%
log-rec0.0%
sub-neg0.0%
log-div67.5%
Simplified67.5%
if -8.6e9 < y Initial program 93.8%
sub-neg93.8%
log1p-def93.8%
distribute-neg-frac93.8%
sub-neg93.8%
distribute-neg-in93.8%
remove-double-neg93.8%
+-commutative93.8%
sub-neg93.8%
Simplified93.8%
Taylor expanded in y around 0 87.1%
log1p-def87.1%
mul-1-neg87.1%
Simplified87.1%
Final simplification81.3%
(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 71.9%
sub-neg71.9%
log1p-def72.0%
distribute-neg-frac72.0%
sub-neg72.0%
distribute-neg-in72.0%
remove-double-neg72.0%
+-commutative72.0%
sub-neg72.0%
Simplified72.0%
Taylor expanded in y around 0 65.0%
log1p-def65.0%
mul-1-neg65.0%
Simplified65.0%
Final simplification65.0%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 71.9%
sub-neg71.9%
log1p-def72.0%
distribute-neg-frac72.0%
sub-neg72.0%
distribute-neg-in72.0%
remove-double-neg72.0%
+-commutative72.0%
sub-neg72.0%
Simplified72.0%
Taylor expanded in y around 0 65.0%
log1p-def65.0%
mul-1-neg65.0%
Simplified65.0%
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 2023335
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, B"
:precision binary64
:herbie-target
(if (< y -81284752.61947241) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y))))) (if (< y 3.0094271212461764e+25) (log (/ (exp 1.0) (- 1.0 (/ (- x y) (- 1.0 y))))) (- 1.0 (log (- (/ x (* y y)) (- (/ 1.0 y) (/ x y)))))))
(- 1.0 (log (- 1.0 (/ (- x y) (- 1.0 y))))))