
(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
(if (<= y -4500000.0)
(-
(- 1.0 (/ (+ (/ x (+ x -1.0)) (/ -1.0 (+ x -1.0))) y))
(+ (log1p (- x)) (log (/ -1.0 y))))
(if (<= y 3.1e+41)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -4500000.0) {
tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -1.0))) / y)) - (log1p(-x) + log((-1.0 / y)));
} else if (y <= 3.1e+41) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -4500000.0) {
tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -1.0))) / y)) - (Math.log1p(-x) + Math.log((-1.0 / y)));
} else if (y <= 3.1e+41) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4500000.0: tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -1.0))) / y)) - (math.log1p(-x) + math.log((-1.0 / y))) elif y <= 3.1e+41: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -4500000.0) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(x / Float64(x + -1.0)) + Float64(-1.0 / Float64(x + -1.0))) / y)) - Float64(log1p(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (y <= 3.1e+41) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -4500000.0], N[(N[(1.0 - N[(N[(N[(x / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - N[(N[Log[1 + (-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+41], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4500000:\\
\;\;\;\;\left(1 - \frac{\frac{x}{x + -1} + \frac{-1}{x + -1}}{y}\right) - \left(\mathsf{log1p}\left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+41}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if y < -4.5e6Initial program 24.5%
sub-neg24.5%
log1p-def24.5%
distribute-neg-frac24.5%
sub-neg24.5%
distribute-neg-in24.5%
remove-double-neg24.5%
+-commutative24.5%
sub-neg24.5%
Simplified24.5%
Taylor expanded in y around -inf 99.5%
mul-1-neg99.5%
unsub-neg99.5%
sub-neg99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
distribute-neg-frac99.5%
metadata-eval99.5%
sub-neg99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
if -4.5e6 < y < 3.1e41Initial 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 3.1e41 < y Initial program 67.2%
sub-neg67.2%
log1p-def67.2%
distribute-neg-frac67.2%
sub-neg67.2%
distribute-neg-in67.2%
remove-double-neg67.2%
+-commutative67.2%
sub-neg67.2%
Simplified67.2%
Taylor expanded in y around inf 98.4%
log-rec98.4%
unsub-neg98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
Simplified98.4%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ E (+ 1.0 x))))
(if (<= x -2.4e-6)
(- 1.0 (log1p (* (- y x) (/ 1.0 (- 1.0 y)))))
(if (<= x 1.0)
(log
(/
(+ t_0 (/ t_0 (/ y (+ (/ x (+ x -1.0)) (/ -1.0 (- 1.0 x))))))
(/ -1.0 y)))
(+ 1.0 (- (log y) (log (+ x -1.0))))))))
double code(double x, double y) {
double t_0 = ((double) M_E) / (1.0 + x);
double tmp;
if (x <= -2.4e-6) {
tmp = 1.0 - log1p(((y - x) * (1.0 / (1.0 - y))));
} else if (x <= 1.0) {
tmp = log(((t_0 + (t_0 / (y / ((x / (x + -1.0)) + (-1.0 / (1.0 - x)))))) / (-1.0 / y)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = Math.E / (1.0 + x);
double tmp;
if (x <= -2.4e-6) {
tmp = 1.0 - Math.log1p(((y - x) * (1.0 / (1.0 - y))));
} else if (x <= 1.0) {
tmp = Math.log(((t_0 + (t_0 / (y / ((x / (x + -1.0)) + (-1.0 / (1.0 - x)))))) / (-1.0 / y)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): t_0 = math.e / (1.0 + x) tmp = 0 if x <= -2.4e-6: tmp = 1.0 - math.log1p(((y - x) * (1.0 / (1.0 - y)))) elif x <= 1.0: tmp = math.log(((t_0 + (t_0 / (y / ((x / (x + -1.0)) + (-1.0 / (1.0 - x)))))) / (-1.0 / y))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) t_0 = Float64(exp(1) / Float64(1.0 + x)) tmp = 0.0 if (x <= -2.4e-6) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) * Float64(1.0 / Float64(1.0 - y))))); elseif (x <= 1.0) tmp = log(Float64(Float64(t_0 + Float64(t_0 / Float64(y / Float64(Float64(x / Float64(x + -1.0)) + Float64(-1.0 / Float64(1.0 - x)))))) / Float64(-1.0 / y))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(E / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.4e-6], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] * N[(1.0 / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[Log[N[(N[(t$95$0 + N[(t$95$0 / N[(y / N[(N[(x / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{e}{1 + x}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{-6}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\left(y - x\right) \cdot \frac{1}{1 - y}\right)\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\log \left(\frac{t\_0 + \frac{t\_0}{\frac{y}{\frac{x}{x + -1} + \frac{-1}{1 - x}}}}{\frac{-1}{y}}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if x < -2.3999999999999999e-6Initial program 89.1%
sub-neg89.1%
log1p-def89.1%
distribute-neg-frac89.1%
sub-neg89.1%
distribute-neg-in89.1%
remove-double-neg89.1%
+-commutative89.1%
sub-neg89.1%
Simplified89.1%
clear-num89.1%
associate-/r/89.6%
Applied egg-rr89.6%
if -2.3999999999999999e-6 < x < 1Initial program 67.3%
sub-neg67.3%
log1p-def67.3%
distribute-neg-frac67.3%
sub-neg67.3%
distribute-neg-in67.3%
remove-double-neg67.3%
+-commutative67.3%
sub-neg67.3%
Simplified67.3%
Taylor expanded in y around -inf 36.1%
mul-1-neg36.1%
unsub-neg36.1%
sub-neg36.1%
sub-neg36.1%
metadata-eval36.1%
+-commutative36.1%
distribute-neg-frac36.1%
metadata-eval36.1%
sub-neg36.1%
metadata-eval36.1%
+-commutative36.1%
Simplified36.1%
add-log-exp35.4%
associate--r+35.4%
exp-diff35.4%
Applied egg-rr35.4%
Taylor expanded in y around inf 99.6%
Simplified99.6%
if 1 < x Initial program 71.5%
sub-neg71.5%
log1p-def71.5%
distribute-neg-frac71.5%
sub-neg71.5%
distribute-neg-in71.5%
remove-double-neg71.5%
+-commutative71.5%
sub-neg71.5%
Simplified71.5%
Taylor expanded in y around inf 96.4%
log-rec96.4%
unsub-neg96.4%
sub-neg96.4%
metadata-eval96.4%
+-commutative96.4%
Simplified96.4%
Final simplification95.8%
(FPCore (x y)
:precision binary64
(if (<= y -19000000000.0)
(- (- 1.0 (log1p (- x))) (log (/ -1.0 y)))
(if (<= y 1.8e+41)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(+ 1.0 (- (log y) (log (+ x -1.0)))))))
double code(double x, double y) {
double tmp;
if (y <= -19000000000.0) {
tmp = (1.0 - log1p(-x)) - log((-1.0 / y));
} else if (y <= 1.8e+41) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (log(y) - log((x + -1.0)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -19000000000.0) {
tmp = (1.0 - Math.log1p(-x)) - Math.log((-1.0 / y));
} else if (y <= 1.8e+41) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + (Math.log(y) - Math.log((x + -1.0)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -19000000000.0: tmp = (1.0 - math.log1p(-x)) - math.log((-1.0 / y)) elif y <= 1.8e+41: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 + (math.log(y) - math.log((x + -1.0))) return tmp
function code(x, y) tmp = 0.0 if (y <= -19000000000.0) tmp = Float64(Float64(1.0 - log1p(Float64(-x))) - log(Float64(-1.0 / y))); elseif (y <= 1.8e+41) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 + Float64(log(y) - log(Float64(x + -1.0)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -19000000000.0], N[(N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+41], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[Log[y], $MachinePrecision] - N[Log[N[(x + -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -19000000000:\\
\;\;\;\;\left(1 - \mathsf{log1p}\left(-x\right)\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+41}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\log y - \log \left(x + -1\right)\right)\\
\end{array}
\end{array}
if y < -1.9e10Initial program 24.5%
sub-neg24.5%
log1p-def24.5%
distribute-neg-frac24.5%
sub-neg24.5%
distribute-neg-in24.5%
remove-double-neg24.5%
+-commutative24.5%
sub-neg24.5%
Simplified24.5%
Taylor expanded in y around -inf 99.4%
associate--r+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 -1.9e10 < y < 1.80000000000000013e41Initial 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 1.80000000000000013e41 < y Initial program 67.2%
sub-neg67.2%
log1p-def67.2%
distribute-neg-frac67.2%
sub-neg67.2%
distribute-neg-in67.2%
remove-double-neg67.2%
+-commutative67.2%
sub-neg67.2%
Simplified67.2%
Taylor expanded in y around inf 98.4%
log-rec98.4%
unsub-neg98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
Simplified98.4%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= (/ (- x y) (- 1.0 y)) 0.999999999996)
(- 1.0 (log1p (/ (- y x) (- 1.0 y))))
(-
(- 1.0 (/ (+ (/ x (+ x -1.0)) (/ -1.0 (+ x -1.0))) y))
(log (/ -1.0 y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.999999999996) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -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.999999999996) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -1.0))) / y)) - Math.log((-1.0 / y));
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.999999999996: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = (1.0 - (((x / (x + -1.0)) + (-1.0 / (x + -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.999999999996) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(Float64(1.0 - Float64(Float64(Float64(x / Float64(x + -1.0)) + Float64(-1.0 / Float64(x + -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.999999999996], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(x / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.999999999996:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{\frac{x}{x + -1} + \frac{-1}{x + -1}}{y}\right) - \log \left(\frac{-1}{y}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.999999999995999977Initial program 99.5%
sub-neg99.5%
log1p-def99.5%
distribute-neg-frac99.5%
sub-neg99.5%
distribute-neg-in99.5%
remove-double-neg99.5%
+-commutative99.5%
sub-neg99.5%
Simplified99.5%
if 0.999999999995999977 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 4.8%
sub-neg4.8%
log1p-def4.8%
distribute-neg-frac4.8%
sub-neg4.8%
distribute-neg-in4.8%
remove-double-neg4.8%
+-commutative4.8%
sub-neg4.8%
Simplified4.8%
Taylor expanded in y around -inf 86.2%
mul-1-neg86.2%
unsub-neg86.2%
sub-neg86.2%
sub-neg86.2%
metadata-eval86.2%
+-commutative86.2%
distribute-neg-frac86.2%
metadata-eval86.2%
sub-neg86.2%
metadata-eval86.2%
+-commutative86.2%
Simplified86.2%
Taylor expanded in x around 0 75.0%
Final simplification93.2%
(FPCore (x y)
:precision binary64
(let* ((t_0 (log (- y))) (t_1 (- 1.0 (log1p (/ x y)))))
(if (<= y -1.95e+148)
(+ 1.0 t_0)
(if (<= y -3.1e+128)
t_1
(if (<= y -460.0)
(+ 1.0 (+ x t_0))
(if (<= y 1.0) (- 1.0 (+ y (log1p (- x)))) t_1))))))
double code(double x, double y) {
double t_0 = log(-y);
double t_1 = 1.0 - log1p((x / y));
double tmp;
if (y <= -1.95e+148) {
tmp = 1.0 + t_0;
} else if (y <= -3.1e+128) {
tmp = t_1;
} else if (y <= -460.0) {
tmp = 1.0 + (x + t_0);
} else if (y <= 1.0) {
tmp = 1.0 - (y + log1p(-x));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = Math.log(-y);
double t_1 = 1.0 - Math.log1p((x / y));
double tmp;
if (y <= -1.95e+148) {
tmp = 1.0 + t_0;
} else if (y <= -3.1e+128) {
tmp = t_1;
} else if (y <= -460.0) {
tmp = 1.0 + (x + t_0);
} else if (y <= 1.0) {
tmp = 1.0 - (y + Math.log1p(-x));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = math.log(-y) t_1 = 1.0 - math.log1p((x / y)) tmp = 0 if y <= -1.95e+148: tmp = 1.0 + t_0 elif y <= -3.1e+128: tmp = t_1 elif y <= -460.0: tmp = 1.0 + (x + t_0) elif y <= 1.0: tmp = 1.0 - (y + math.log1p(-x)) else: tmp = t_1 return tmp
function code(x, y) t_0 = log(Float64(-y)) t_1 = Float64(1.0 - log1p(Float64(x / y))) tmp = 0.0 if (y <= -1.95e+148) tmp = Float64(1.0 + t_0); elseif (y <= -3.1e+128) tmp = t_1; elseif (y <= -460.0) tmp = Float64(1.0 + Float64(x + t_0)); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[Log[(-y)], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.95e+148], N[(1.0 + t$95$0), $MachinePrecision], If[LessEqual[y, -3.1e+128], t$95$1, If[LessEqual[y, -460.0], N[(1.0 + N[(x + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(-y\right)\\
t_1 := 1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\mathbf{if}\;y \leq -1.95 \cdot 10^{+148}:\\
\;\;\;\;1 + t\_0\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{+128}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -460:\\
\;\;\;\;1 + \left(x + t\_0\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.95000000000000001e148Initial program 10.4%
sub-neg10.4%
log1p-def10.4%
distribute-neg-frac10.4%
sub-neg10.4%
distribute-neg-in10.4%
remove-double-neg10.4%
+-commutative10.4%
sub-neg10.4%
Simplified10.4%
Taylor expanded in y around -inf 99.5%
associate--r+99.5%
sub-neg99.5%
metadata-eval99.5%
distribute-lft-in99.5%
metadata-eval99.5%
+-commutative99.5%
log1p-def99.5%
mul-1-neg99.5%
Simplified99.5%
Taylor expanded in x around 0 74.1%
Taylor expanded in x around 0 77.8%
Simplified77.8%
if -1.95000000000000001e148 < y < -3.10000000000000004e128 or 1 < y Initial program 73.6%
sub-neg73.6%
log1p-def73.6%
distribute-neg-frac73.6%
sub-neg73.6%
distribute-neg-in73.6%
remove-double-neg73.6%
+-commutative73.6%
sub-neg73.6%
Simplified73.6%
Taylor expanded in x around inf 72.8%
neg-mul-172.8%
distribute-neg-frac72.8%
Simplified72.8%
Taylor expanded in y around inf 71.0%
if -3.10000000000000004e128 < y < -460Initial program 35.1%
sub-neg35.1%
log1p-def35.1%
distribute-neg-frac35.1%
sub-neg35.1%
distribute-neg-in35.1%
remove-double-neg35.1%
+-commutative35.1%
sub-neg35.1%
Simplified35.1%
Taylor expanded in y around -inf 96.9%
associate--r+96.9%
sub-neg96.9%
metadata-eval96.9%
distribute-lft-in96.9%
metadata-eval96.9%
+-commutative96.9%
log1p-def96.9%
mul-1-neg96.9%
Simplified96.9%
Taylor expanded in x around 0 62.8%
associate--l+62.8%
+-commutative62.8%
sub-neg62.8%
neg-log62.8%
frac-2neg62.8%
metadata-eval62.8%
remove-double-div62.8%
Applied egg-rr62.8%
if -460 < 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 96.9%
+-commutative96.9%
div-sub96.9%
mul-1-neg96.9%
sub-neg96.9%
*-inverses96.9%
*-rgt-identity96.9%
log1p-def96.9%
mul-1-neg96.9%
Simplified96.9%
Final simplification86.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (log (- y)))) (t_1 (- 1.0 (log1p (/ x y)))))
(if (<= y -1.7e+148)
t_0
(if (<= y -1.24e+129)
t_1
(if (<= y -4500000.0) t_0 (if (<= y 1.0) (- 1.0 (log1p (- x))) t_1))))))
double code(double x, double y) {
double t_0 = 1.0 + log(-y);
double t_1 = 1.0 - log1p((x / y));
double tmp;
if (y <= -1.7e+148) {
tmp = t_0;
} else if (y <= -1.24e+129) {
tmp = t_1;
} else if (y <= -4500000.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = 1.0 + Math.log(-y);
double t_1 = 1.0 - Math.log1p((x / y));
double tmp;
if (y <= -1.7e+148) {
tmp = t_0;
} else if (y <= -1.24e+129) {
tmp = t_1;
} else if (y <= -4500000.0) {
tmp = t_0;
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = 1.0 + math.log(-y) t_1 = 1.0 - math.log1p((x / y)) tmp = 0 if y <= -1.7e+148: tmp = t_0 elif y <= -1.24e+129: tmp = t_1 elif y <= -4500000.0: tmp = t_0 elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(1.0 + log(Float64(-y))) t_1 = Float64(1.0 - log1p(Float64(x / y))) tmp = 0.0 if (y <= -1.7e+148) tmp = t_0; elseif (y <= -1.24e+129) tmp = t_1; elseif (y <= -4500000.0) tmp = t_0; elseif (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+148], t$95$0, If[LessEqual[y, -1.24e+129], t$95$1, If[LessEqual[y, -4500000.0], t$95$0, If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \log \left(-y\right)\\
t_1 := 1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.24 \cdot 10^{+129}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -4500000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.7000000000000001e148 or -1.24000000000000002e129 < y < -4.5e6Initial program 19.2%
sub-neg19.2%
log1p-def19.2%
distribute-neg-frac19.2%
sub-neg19.2%
distribute-neg-in19.2%
remove-double-neg19.2%
+-commutative19.2%
sub-neg19.2%
Simplified19.2%
Taylor expanded in y around -inf 99.5%
associate--r+99.5%
sub-neg99.5%
metadata-eval99.5%
distribute-lft-in99.5%
metadata-eval99.5%
+-commutative99.5%
log1p-def99.5%
mul-1-neg99.5%
Simplified99.5%
Taylor expanded in x around 0 70.9%
Taylor expanded in x around 0 73.1%
Simplified73.1%
if -1.7000000000000001e148 < y < -1.24000000000000002e129 or 1 < y Initial program 73.6%
sub-neg73.6%
log1p-def73.6%
distribute-neg-frac73.6%
sub-neg73.6%
distribute-neg-in73.6%
remove-double-neg73.6%
+-commutative73.6%
sub-neg73.6%
Simplified73.6%
Taylor expanded in x around inf 72.8%
neg-mul-172.8%
distribute-neg-frac72.8%
Simplified72.8%
Taylor expanded in y around inf 71.0%
if -4.5e6 < 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 95.4%
log1p-def95.4%
mul-1-neg95.4%
Simplified95.4%
Final simplification86.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (log (- y)))))
(if (<= y -1.7e+148)
t_0
(if (<= y -1.24e+129)
(- 1.0 (log1p (/ x y)))
(if (<= y -460000000000.0) t_0 (- 1.0 (log1p (/ (- x) (- 1.0 y)))))))))
double code(double x, double y) {
double t_0 = 1.0 + log(-y);
double tmp;
if (y <= -1.7e+148) {
tmp = t_0;
} else if (y <= -1.24e+129) {
tmp = 1.0 - log1p((x / y));
} else if (y <= -460000000000.0) {
tmp = t_0;
} else {
tmp = 1.0 - log1p((-x / (1.0 - y)));
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = 1.0 + Math.log(-y);
double tmp;
if (y <= -1.7e+148) {
tmp = t_0;
} else if (y <= -1.24e+129) {
tmp = 1.0 - Math.log1p((x / y));
} else if (y <= -460000000000.0) {
tmp = t_0;
} else {
tmp = 1.0 - Math.log1p((-x / (1.0 - y)));
}
return tmp;
}
def code(x, y): t_0 = 1.0 + math.log(-y) tmp = 0 if y <= -1.7e+148: tmp = t_0 elif y <= -1.24e+129: tmp = 1.0 - math.log1p((x / y)) elif y <= -460000000000.0: tmp = t_0 else: tmp = 1.0 - math.log1p((-x / (1.0 - y))) return tmp
function code(x, y) t_0 = Float64(1.0 + log(Float64(-y))) tmp = 0.0 if (y <= -1.7e+148) tmp = t_0; elseif (y <= -1.24e+129) tmp = Float64(1.0 - log1p(Float64(x / y))); elseif (y <= -460000000000.0) tmp = t_0; else tmp = Float64(1.0 - log1p(Float64(Float64(-x) / Float64(1.0 - y)))); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e+148], t$95$0, If[LessEqual[y, -1.24e+129], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -460000000000.0], t$95$0, N[(1.0 - N[Log[1 + N[((-x) / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \log \left(-y\right)\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.24 \cdot 10^{+129}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\mathbf{elif}\;y \leq -460000000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -1.7000000000000001e148 or -1.24000000000000002e129 < y < -4.6e11Initial program 19.2%
sub-neg19.2%
log1p-def19.2%
distribute-neg-frac19.2%
sub-neg19.2%
distribute-neg-in19.2%
remove-double-neg19.2%
+-commutative19.2%
sub-neg19.2%
Simplified19.2%
Taylor expanded in y around -inf 99.5%
associate--r+99.5%
sub-neg99.5%
metadata-eval99.5%
distribute-lft-in99.5%
metadata-eval99.5%
+-commutative99.5%
log1p-def99.5%
mul-1-neg99.5%
Simplified99.5%
Taylor expanded in x around 0 70.9%
Taylor expanded in x around 0 73.1%
Simplified73.1%
if -1.7000000000000001e148 < y < -1.24000000000000002e129Initial program 83.9%
sub-neg83.9%
log1p-def83.9%
distribute-neg-frac83.9%
sub-neg83.9%
distribute-neg-in83.9%
remove-double-neg83.9%
+-commutative83.9%
sub-neg83.9%
Simplified83.9%
Taylor expanded in x around inf 85.7%
neg-mul-185.7%
distribute-neg-frac85.7%
Simplified85.7%
Taylor expanded in y around inf 85.7%
if -4.6e11 < y Initial program 95.3%
sub-neg95.3%
log1p-def95.3%
distribute-neg-frac95.3%
sub-neg95.3%
distribute-neg-in95.3%
remove-double-neg95.3%
+-commutative95.3%
sub-neg95.3%
Simplified95.3%
Taylor expanded in x around inf 93.6%
neg-mul-193.6%
distribute-neg-frac93.6%
Simplified93.6%
Final simplification88.1%
(FPCore (x y) :precision binary64 (if (<= (/ (- x y) (- 1.0 y)) 0.999999999996) (- 1.0 (log1p (/ (- y x) (- 1.0 y)))) (+ 1.0 (log (- y)))))
double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.999999999996) {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + log(-y);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (((x - y) / (1.0 - y)) <= 0.999999999996) {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
} else {
tmp = 1.0 + Math.log(-y);
}
return tmp;
}
def code(x, y): tmp = 0 if ((x - y) / (1.0 - y)) <= 0.999999999996: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) else: tmp = 1.0 + math.log(-y) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(x - y) / Float64(1.0 - y)) <= 0.999999999996) tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); else tmp = Float64(1.0 + log(Float64(-y))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(x - y), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 0.999999999996], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x - y}{1 - y} \leq 0.999999999996:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \log \left(-y\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 x y) (-.f64 1 y)) < 0.999999999995999977Initial program 99.5%
sub-neg99.5%
log1p-def99.5%
distribute-neg-frac99.5%
sub-neg99.5%
distribute-neg-in99.5%
remove-double-neg99.5%
+-commutative99.5%
sub-neg99.5%
Simplified99.5%
if 0.999999999995999977 < (/.f64 (-.f64 x y) (-.f64 1 y)) Initial program 4.8%
sub-neg4.8%
log1p-def4.8%
distribute-neg-frac4.8%
sub-neg4.8%
distribute-neg-in4.8%
remove-double-neg4.8%
+-commutative4.8%
sub-neg4.8%
Simplified4.8%
Taylor expanded in y around -inf 86.2%
associate--r+86.2%
sub-neg86.2%
metadata-eval86.2%
distribute-lft-in86.2%
metadata-eval86.2%
+-commutative86.2%
log1p-def86.2%
mul-1-neg86.2%
Simplified86.2%
Taylor expanded in x around 0 72.8%
Taylor expanded in x around 0 75.0%
Simplified75.0%
Final simplification93.2%
(FPCore (x y) :precision binary64 (if (<= y -4500000.0) (+ 1.0 (log (- y))) (if (<= y 1.0) (- 1.0 (log1p (- x))) (- 1.0 (log1p x)))))
double code(double x, double y) {
double tmp;
if (y <= -4500000.0) {
tmp = 1.0 + log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - log1p(-x);
} else {
tmp = 1.0 - log1p(x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -4500000.0) {
tmp = 1.0 + Math.log(-y);
} else if (y <= 1.0) {
tmp = 1.0 - Math.log1p(-x);
} else {
tmp = 1.0 - Math.log1p(x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -4500000.0: tmp = 1.0 + math.log(-y) elif y <= 1.0: tmp = 1.0 - math.log1p(-x) else: tmp = 1.0 - math.log1p(x) return tmp
function code(x, y) tmp = 0.0 if (y <= -4500000.0) tmp = Float64(1.0 + log(Float64(-y))); elseif (y <= 1.0) tmp = Float64(1.0 - log1p(Float64(-x))); else tmp = Float64(1.0 - log1p(x)); end return tmp end
code[x_, y_] := If[LessEqual[y, -4500000.0], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + x], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4500000:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(x\right)\\
\end{array}
\end{array}
if y < -4.5e6Initial program 24.5%
sub-neg24.5%
log1p-def24.5%
distribute-neg-frac24.5%
sub-neg24.5%
distribute-neg-in24.5%
remove-double-neg24.5%
+-commutative24.5%
sub-neg24.5%
Simplified24.5%
Taylor expanded in y around -inf 99.4%
associate--r+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%
Taylor expanded in x around 0 66.7%
Taylor expanded in x around 0 68.5%
Simplified68.5%
if -4.5e6 < 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 95.4%
log1p-def95.4%
mul-1-neg95.4%
Simplified95.4%
if 1 < y Initial program 71.5%
sub-neg71.5%
log1p-def71.5%
distribute-neg-frac71.5%
sub-neg71.5%
distribute-neg-in71.5%
remove-double-neg71.5%
+-commutative71.5%
sub-neg71.5%
Simplified71.5%
Taylor expanded in y around 0 0.0%
*-un-lft-identity0.0%
log-prod0.0%
metadata-eval0.0%
log1p-def0.0%
neg-mul-10.0%
add-sqr-sqrt0.0%
sqrt-unprod7.0%
sqr-neg7.0%
sqrt-unprod13.5%
add-sqr-sqrt13.5%
Applied egg-rr13.5%
+-lft-identity13.5%
Simplified13.5%
Final simplification78.2%
(FPCore (x y) :precision binary64 (if (<= y -0.35) (+ 1.0 (log (- y))) (- 1.0 (log1p x))))
double code(double x, double y) {
double tmp;
if (y <= -0.35) {
tmp = 1.0 + log(-y);
} else {
tmp = 1.0 - log1p(x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -0.35) {
tmp = 1.0 + Math.log(-y);
} else {
tmp = 1.0 - Math.log1p(x);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -0.35: tmp = 1.0 + math.log(-y) else: tmp = 1.0 - math.log1p(x) return tmp
function code(x, y) tmp = 0.0 if (y <= -0.35) tmp = Float64(1.0 + log(Float64(-y))); else tmp = Float64(1.0 - log1p(x)); end return tmp end
code[x_, y_] := If[LessEqual[y, -0.35], N[(1.0 + N[Log[(-y)], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.35:\\
\;\;\;\;1 + \log \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(x\right)\\
\end{array}
\end{array}
if y < -0.34999999999999998Initial program 28.4%
sub-neg28.4%
log1p-def28.4%
distribute-neg-frac28.4%
sub-neg28.4%
distribute-neg-in28.4%
remove-double-neg28.4%
+-commutative28.4%
sub-neg28.4%
Simplified28.4%
Taylor expanded in y around -inf 97.0%
associate--r+97.0%
sub-neg97.0%
metadata-eval97.0%
distribute-lft-in97.0%
metadata-eval97.0%
+-commutative97.0%
log1p-def97.0%
mul-1-neg97.0%
Simplified97.0%
Taylor expanded in x around 0 63.5%
Taylor expanded in x around 0 65.1%
Simplified65.1%
if -0.34999999999999998 < y Initial program 95.2%
sub-neg95.2%
log1p-def95.2%
distribute-neg-frac95.2%
sub-neg95.2%
distribute-neg-in95.2%
remove-double-neg95.2%
+-commutative95.2%
sub-neg95.2%
Simplified95.2%
Taylor expanded in y around 0 80.9%
*-un-lft-identity80.9%
log-prod80.9%
metadata-eval80.9%
log1p-def81.0%
neg-mul-181.0%
add-sqr-sqrt56.2%
sqrt-unprod65.5%
sqr-neg65.5%
sqrt-unprod25.8%
add-sqr-sqrt51.5%
Applied egg-rr51.5%
+-lft-identity51.5%
Simplified51.5%
Final simplification55.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(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 75.1%
sub-neg75.1%
log1p-def75.1%
distribute-neg-frac75.1%
sub-neg75.1%
distribute-neg-in75.1%
remove-double-neg75.1%
+-commutative75.1%
sub-neg75.1%
Simplified75.1%
Taylor expanded in y around 0 60.7%
*-un-lft-identity60.7%
log-prod60.7%
metadata-eval60.7%
log1p-def60.7%
neg-mul-160.7%
add-sqr-sqrt42.1%
sqrt-unprod49.0%
sqr-neg49.0%
sqrt-unprod19.4%
add-sqr-sqrt38.6%
Applied egg-rr38.6%
+-lft-identity38.6%
Simplified38.6%
Final simplification38.6%
(FPCore (x y) :precision binary64 x)
double code(double x, double y) {
return x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x
end function
public static double code(double x, double y) {
return x;
}
def code(x, y): return x
function code(x, y) return x end
function tmp = code(x, y) tmp = x; end
code[x_, y_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 75.1%
sub-neg75.1%
log1p-def75.1%
distribute-neg-frac75.1%
sub-neg75.1%
distribute-neg-in75.1%
remove-double-neg75.1%
+-commutative75.1%
sub-neg75.1%
Simplified75.1%
Taylor expanded in y around -inf 31.8%
associate--r+31.8%
sub-neg31.8%
metadata-eval31.8%
distribute-lft-in31.8%
metadata-eval31.8%
+-commutative31.8%
log1p-def31.8%
mul-1-neg31.8%
Simplified31.8%
Taylor expanded in x around 0 20.0%
Taylor expanded in x around inf 3.9%
Final simplification3.9%
(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 2024031
(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))))))