
(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 12 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 (+ 1.0 (/ (- x y) (+ y -1.0))))) (if (<= t_0 0.0) (- 1.0 (log (/ (+ x -1.0) y))) (- 1.0 (log t_0)))))
double code(double x, double y) {
double t_0 = 1.0 + ((x - y) / (y + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = 1.0 - log(((x + -1.0) / y));
} else {
tmp = 1.0 - log(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 + ((x - y) / (y + (-1.0d0)))
if (t_0 <= 0.0d0) then
tmp = 1.0d0 - log(((x + (-1.0d0)) / y))
else
tmp = 1.0d0 - log(t_0)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 + ((x - y) / (y + -1.0));
double tmp;
if (t_0 <= 0.0) {
tmp = 1.0 - Math.log(((x + -1.0) / y));
} else {
tmp = 1.0 - Math.log(t_0);
}
return tmp;
}
def code(x, y): t_0 = 1.0 + ((x - y) / (y + -1.0)) tmp = 0 if t_0 <= 0.0: tmp = 1.0 - math.log(((x + -1.0) / y)) else: tmp = 1.0 - math.log(t_0) return tmp
function code(x, y) t_0 = Float64(1.0 + Float64(Float64(x - y) / Float64(y + -1.0))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); else tmp = Float64(1.0 - log(t_0)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 + ((x - y) / (y + -1.0)); tmp = 0.0; if (t_0 <= 0.0) tmp = 1.0 - log(((x + -1.0) / y)); else tmp = 1.0 - log(t_0); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[t$95$0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{x - y}{y + -1}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log t\_0\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))) < 0.0Initial program 3.1%
Taylor expanded in y around inf 100.0%
associate-*r/100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
Simplified100.0%
if 0.0 < (-.f64 #s(literal 1 binary64) (/.f64 (-.f64 x y) (-.f64 #s(literal 1 binary64) y))) Initial program 99.9%
Final simplification100.0%
(FPCore (x y)
:precision binary64
(if (<= y -4.8e+21)
(- 1.0 (log (/ (+ x -1.0) y)))
(if (<= y 9.5e-26)
(- 1.0 (log1p (/ (- x y) (+ y -1.0))))
(- 1.0 (log (/ 1.0 (/ (+ y -1.0) x)))))))
double code(double x, double y) {
double tmp;
if (y <= -4.8e+21) {
tmp = 1.0 - log(((x + -1.0) / y));
} else if (y <= 9.5e-26) {
tmp = 1.0 - log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - log((1.0 / ((y + -1.0) / x)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -4.8e+21) {
tmp = 1.0 - Math.log(((x + -1.0) / y));
} else if (y <= 9.5e-26) {
tmp = 1.0 - Math.log1p(((x - y) / (y + -1.0)));
} else {
tmp = 1.0 - Math.log((1.0 / ((y + -1.0) / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.8e+21: tmp = 1.0 - math.log(((x + -1.0) / y)) elif y <= 9.5e-26: tmp = 1.0 - math.log1p(((x - y) / (y + -1.0))) else: tmp = 1.0 - math.log((1.0 / ((y + -1.0) / x))) return tmp
function code(x, y) tmp = 0.0 if (y <= -4.8e+21) tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); elseif (y <= 9.5e-26) tmp = Float64(1.0 - log1p(Float64(Float64(x - y) / Float64(y + -1.0)))); else tmp = Float64(1.0 - log(Float64(1.0 / Float64(Float64(y + -1.0) / x)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -4.8e+21], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e-26], N[(1.0 - N[Log[1 + N[(N[(x - y), $MachinePrecision] / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(1.0 / N[(N[(y + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-26}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x - y}{y + -1}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1}{\frac{y + -1}{x}}\right)\\
\end{array}
\end{array}
if y < -4.8e21Initial program 16.1%
Taylor expanded in y around inf 100.0%
associate-*r/100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
Simplified100.0%
if -4.8e21 < y < 9.4999999999999995e-26Initial program 99.3%
sub-neg99.3%
log1p-define99.3%
distribute-neg-frac299.3%
neg-sub099.3%
associate--r-99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
if 9.4999999999999995e-26 < y Initial program 63.7%
Taylor expanded in x around inf 91.5%
mul-1-neg91.5%
distribute-neg-frac291.5%
sub-neg91.5%
distribute-neg-in91.5%
metadata-eval91.5%
remove-double-neg91.5%
+-commutative91.5%
Simplified91.5%
clear-num91.5%
inv-pow91.5%
Applied egg-rr91.5%
unpow-191.5%
Simplified91.5%
Final simplification98.5%
(FPCore (x y)
:precision binary64
(if (<= y -4.8e+21)
(- 1.0 (log (/ (+ x -1.0) y)))
(if (<= y 2.8e-5)
(- (- 1.0 y) (log1p (- x)))
(- 1.0 (log (/ 1.0 (/ (+ y -1.0) x)))))))
double code(double x, double y) {
double tmp;
if (y <= -4.8e+21) {
tmp = 1.0 - log(((x + -1.0) / y));
} else if (y <= 2.8e-5) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = 1.0 - log((1.0 / ((y + -1.0) / x)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -4.8e+21) {
tmp = 1.0 - Math.log(((x + -1.0) / y));
} else if (y <= 2.8e-5) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log((1.0 / ((y + -1.0) / x)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.8e+21: tmp = 1.0 - math.log(((x + -1.0) / y)) elif y <= 2.8e-5: tmp = (1.0 - y) - math.log1p(-x) else: tmp = 1.0 - math.log((1.0 / ((y + -1.0) / x))) return tmp
function code(x, y) tmp = 0.0 if (y <= -4.8e+21) tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); elseif (y <= 2.8e-5) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(1.0 / Float64(Float64(y + -1.0) / x)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -4.8e+21], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-5], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(1.0 / N[(N[(y + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-5}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{1}{\frac{y + -1}{x}}\right)\\
\end{array}
\end{array}
if y < -4.8e21Initial program 16.1%
Taylor expanded in y around inf 100.0%
associate-*r/100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
Simplified100.0%
if -4.8e21 < y < 2.79999999999999996e-5Initial program 99.3%
Taylor expanded in y around 0 97.4%
Simplified97.5%
if 2.79999999999999996e-5 < y Initial program 59.9%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
distribute-neg-frac297.0%
sub-neg97.0%
distribute-neg-in97.0%
metadata-eval97.0%
remove-double-neg97.0%
+-commutative97.0%
Simplified97.0%
clear-num97.0%
inv-pow97.0%
Applied egg-rr97.0%
unpow-197.0%
Simplified97.0%
Final simplification98.2%
(FPCore (x y)
:precision binary64
(if (<= y -4.8e+21)
(- 1.0 (log (/ (+ x -1.0) y)))
(if (<= y 2.8e-5)
(- (- 1.0 y) (log1p (- x)))
(- 1.0 (log (/ x (+ y -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -4.8e+21) {
tmp = 1.0 - log(((x + -1.0) / y));
} else if (y <= 2.8e-5) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = 1.0 - log((x / (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -4.8e+21) {
tmp = 1.0 - Math.log(((x + -1.0) / y));
} else if (y <= 2.8e-5) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log((x / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4.8e+21: tmp = 1.0 - math.log(((x + -1.0) / y)) elif y <= 2.8e-5: tmp = (1.0 - y) - math.log1p(-x) else: tmp = 1.0 - math.log((x / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -4.8e+21) tmp = Float64(1.0 - log(Float64(Float64(x + -1.0) / y))); elseif (y <= 2.8e-5) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(x / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -4.8e+21], N[(1.0 - N[Log[N[(N[(x + -1.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-5], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+21}:\\
\;\;\;\;1 - \log \left(\frac{x + -1}{y}\right)\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-5}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y + -1}\right)\\
\end{array}
\end{array}
if y < -4.8e21Initial program 16.1%
Taylor expanded in y around inf 100.0%
associate-*r/100.0%
distribute-lft-in100.0%
metadata-eval100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
Simplified100.0%
if -4.8e21 < y < 2.79999999999999996e-5Initial program 99.3%
Taylor expanded in y around 0 97.4%
Simplified97.5%
if 2.79999999999999996e-5 < y Initial program 59.9%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
distribute-neg-frac297.0%
sub-neg97.0%
distribute-neg-in97.0%
metadata-eval97.0%
remove-double-neg97.0%
+-commutative97.0%
Simplified97.0%
Final simplification98.1%
(FPCore (x y)
:precision binary64
(if (<= y -38.0)
(- 1.0 (log (/ -1.0 y)))
(if (<= y 2.8e-5)
(- (- 1.0 y) (log1p (- x)))
(- 1.0 (log (/ x (+ y -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -38.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 2.8e-5) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = 1.0 - log((x / (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -38.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 2.8e-5) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log((x / (y + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -38.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 2.8e-5: tmp = (1.0 - y) - math.log1p(-x) else: tmp = 1.0 - math.log((x / (y + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -38.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 2.8e-5) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = Float64(1.0 - log(Float64(x / Float64(y + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -38.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-5], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[N[(x / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -38:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-5}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \log \left(\frac{x}{y + -1}\right)\\
\end{array}
\end{array}
if y < -38Initial program 17.0%
Taylor expanded in x around 0 2.8%
log1p-define2.8%
Simplified2.8%
Taylor expanded in y around -inf 74.7%
if -38 < y < 2.79999999999999996e-5Initial program 99.9%
Taylor expanded in y around 0 98.7%
Simplified98.7%
if 2.79999999999999996e-5 < y Initial program 59.9%
Taylor expanded in x around inf 97.0%
mul-1-neg97.0%
distribute-neg-frac297.0%
sub-neg97.0%
distribute-neg-in97.0%
metadata-eval97.0%
remove-double-neg97.0%
+-commutative97.0%
Simplified97.0%
(FPCore (x y) :precision binary64 (if (<= y -38.0) (- 1.0 (log (/ -1.0 y))) (if (<= y 9.5e-26) (- (- 1.0 y) (log1p (- x))) (log (* (/ y x) E)))))
double code(double x, double y) {
double tmp;
if (y <= -38.0) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 9.5e-26) {
tmp = (1.0 - y) - log1p(-x);
} else {
tmp = log(((y / x) * ((double) M_E)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -38.0) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 9.5e-26) {
tmp = (1.0 - y) - Math.log1p(-x);
} else {
tmp = Math.log(((y / x) * Math.E));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -38.0: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 9.5e-26: tmp = (1.0 - y) - math.log1p(-x) else: tmp = math.log(((y / x) * math.e)) return tmp
function code(x, y) tmp = 0.0 if (y <= -38.0) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 9.5e-26) tmp = Float64(Float64(1.0 - y) - log1p(Float64(-x))); else tmp = log(Float64(Float64(y / x) * exp(1))); end return tmp end
code[x_, y_] := If[LessEqual[y, -38.0], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e-26], N[(N[(1.0 - y), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(y / x), $MachinePrecision] * E), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -38:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-26}:\\
\;\;\;\;\left(1 - y\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{y}{x} \cdot e\right)\\
\end{array}
\end{array}
if y < -38Initial program 17.0%
Taylor expanded in x around 0 2.8%
log1p-define2.8%
Simplified2.8%
Taylor expanded in y around -inf 74.7%
if -38 < y < 9.4999999999999995e-26Initial program 99.9%
Taylor expanded in y around 0 98.6%
Simplified98.6%
if 9.4999999999999995e-26 < y Initial program 63.7%
Taylor expanded in x around inf 91.5%
mul-1-neg91.5%
distribute-neg-frac291.5%
sub-neg91.5%
distribute-neg-in91.5%
metadata-eval91.5%
remove-double-neg91.5%
+-commutative91.5%
Simplified91.5%
Taylor expanded in y around inf 85.1%
add-log-exp85.1%
sub-neg85.1%
exp-sum85.1%
neg-log85.1%
clear-num85.1%
add-exp-log85.1%
Applied egg-rr85.1%
*-commutative85.1%
exp-1-e85.1%
Simplified85.1%
(FPCore (x y) :precision binary64 (if (or (<= y -6.5e+25) (not (<= y 9.5e-26))) (log (* (/ y x) E)) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if ((y <= -6.5e+25) || !(y <= 9.5e-26)) {
tmp = log(((y / x) * ((double) M_E)));
} else {
tmp = 1.0 - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((y <= -6.5e+25) || !(y <= 9.5e-26)) {
tmp = Math.log(((y / x) * Math.E));
} else {
tmp = 1.0 - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -6.5e+25) or not (y <= 9.5e-26): tmp = math.log(((y / x) * math.e)) else: tmp = 1.0 - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -6.5e+25) || !(y <= 9.5e-26)) tmp = log(Float64(Float64(y / x) * exp(1))); else tmp = Float64(1.0 - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -6.5e+25], N[Not[LessEqual[y, 9.5e-26]], $MachinePrecision]], N[Log[N[(N[(y / x), $MachinePrecision] * E), $MachinePrecision]], $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+25} \lor \neg \left(y \leq 9.5 \cdot 10^{-26}\right):\\
\;\;\;\;\log \left(\frac{y}{x} \cdot e\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -6.50000000000000005e25 or 9.4999999999999995e-26 < y Initial program 30.6%
Taylor expanded in x around inf 49.9%
mul-1-neg49.9%
distribute-neg-frac249.9%
sub-neg49.9%
distribute-neg-in49.9%
metadata-eval49.9%
remove-double-neg49.9%
+-commutative49.9%
Simplified49.9%
Taylor expanded in y around inf 48.0%
add-log-exp47.4%
sub-neg47.4%
exp-sum47.4%
neg-log47.0%
clear-num47.0%
add-exp-log47.0%
Applied egg-rr47.0%
*-commutative47.0%
exp-1-e47.0%
Simplified47.0%
if -6.50000000000000005e25 < y < 9.4999999999999995e-26Initial program 98.6%
Taylor expanded in y around 0 96.6%
sub-neg96.6%
mul-1-neg96.6%
log1p-define96.6%
mul-1-neg96.6%
Simplified96.6%
Final simplification76.1%
(FPCore (x y) :precision binary64 (if (<= y -2.6e+54) (- 1.0 (log (/ -1.0 y))) (if (<= y 9.5e-26) (- 1.0 (log1p (- x))) (log (* (/ y x) E)))))
double code(double x, double y) {
double tmp;
if (y <= -2.6e+54) {
tmp = 1.0 - log((-1.0 / y));
} else if (y <= 9.5e-26) {
tmp = 1.0 - log1p(-x);
} else {
tmp = log(((y / x) * ((double) M_E)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -2.6e+54) {
tmp = 1.0 - Math.log((-1.0 / y));
} else if (y <= 9.5e-26) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = Math.log(((y / x) * Math.E));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.6e+54: tmp = 1.0 - math.log((-1.0 / y)) elif y <= 9.5e-26: tmp = 1.0 - math.log1p(-x) else: tmp = math.log(((y / x) * math.e)) return tmp
function code(x, y) tmp = 0.0 if (y <= -2.6e+54) tmp = Float64(1.0 - log(Float64(-1.0 / y))); elseif (y <= 9.5e-26) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = log(Float64(Float64(y / x) * exp(1))); end return tmp end
code[x_, y_] := If[LessEqual[y, -2.6e+54], N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e-26], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[Log[N[(N[(y / x), $MachinePrecision] * E), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+54}:\\
\;\;\;\;1 - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-26}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{y}{x} \cdot e\right)\\
\end{array}
\end{array}
if y < -2.60000000000000007e54Initial program 14.4%
Taylor expanded in x around 0 2.9%
log1p-define2.9%
Simplified2.9%
Taylor expanded in y around -inf 76.1%
if -2.60000000000000007e54 < y < 9.4999999999999995e-26Initial program 96.8%
Taylor expanded in y around 0 94.0%
sub-neg94.0%
mul-1-neg94.0%
log1p-define94.0%
mul-1-neg94.0%
Simplified94.0%
if 9.4999999999999995e-26 < y Initial program 63.7%
Taylor expanded in x around inf 91.5%
mul-1-neg91.5%
distribute-neg-frac291.5%
sub-neg91.5%
distribute-neg-in91.5%
metadata-eval91.5%
remove-double-neg91.5%
+-commutative91.5%
Simplified91.5%
Taylor expanded in y around inf 85.1%
add-log-exp85.1%
sub-neg85.1%
exp-sum85.1%
neg-log85.1%
clear-num85.1%
add-exp-log85.1%
Applied egg-rr85.1%
*-commutative85.1%
exp-1-e85.1%
Simplified85.1%
(FPCore (x y) :precision binary64 (if (<= x -1.25e+14) (- 1.0 (log (- x))) (- 1.0 (log1p x))))
double code(double x, double y) {
double tmp;
if (x <= -1.25e+14) {
tmp = 1.0 - log(-x);
} else {
tmp = 1.0 - log1p(x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (x <= -1.25e+14) {
tmp = 1.0 - Math.log(-x);
} else {
tmp = 1.0 - Math.log1p(x);
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.25e+14: tmp = 1.0 - math.log(-x) else: tmp = 1.0 - math.log1p(x) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.25e+14) tmp = Float64(1.0 - log(Float64(-x))); else tmp = Float64(1.0 - log1p(x)); end return tmp end
code[x_, y_] := If[LessEqual[x, -1.25e+14], N[(1.0 - N[Log[(-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+14}:\\
\;\;\;\;1 - \log \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(x\right)\\
\end{array}
\end{array}
if x < -1.25e14Initial program 86.8%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
sub-neg100.0%
distribute-neg-in100.0%
metadata-eval100.0%
remove-double-neg100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 71.4%
mul-1-neg71.4%
Simplified71.4%
if -1.25e14 < x Initial program 64.8%
Taylor expanded in y around 0 58.3%
sub-neg58.3%
mul-1-neg58.3%
log1p-define58.3%
mul-1-neg58.3%
Simplified58.3%
sub-neg58.3%
add-sqr-sqrt27.2%
sqrt-unprod58.5%
sqr-neg58.5%
sqrt-unprod32.4%
add-sqr-sqrt56.8%
Applied egg-rr56.8%
sub-neg56.8%
Simplified56.8%
(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.4%
Taylor expanded in y around 0 61.7%
sub-neg61.7%
mul-1-neg61.7%
log1p-define61.7%
mul-1-neg61.7%
Simplified61.7%
(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.4%
Taylor expanded in y around 0 61.7%
sub-neg61.7%
mul-1-neg61.7%
log1p-define61.7%
mul-1-neg61.7%
Simplified61.7%
Taylor expanded in x around 0 42.9%
+-commutative42.9%
Simplified42.9%
Final simplification42.9%
(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.4%
Taylor expanded in y around 0 61.7%
sub-neg61.7%
mul-1-neg61.7%
log1p-define61.7%
mul-1-neg61.7%
Simplified61.7%
Taylor expanded in x around 0 42.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 2024107
(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))))))