
(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 15 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 -8000000000000.0)
(+
1.0
(- (- (/ (- 1.0 x) (* y (+ x -1.0))) (log (/ -1.0 y))) (log1p (- x))))
(if (<= y 5.5e+91)
(- 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 <= -8000000000000.0) {
tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - log((-1.0 / y))) - log1p(-x));
} else if (y <= 5.5e+91) {
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 <= -8000000000000.0) {
tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - Math.log((-1.0 / y))) - Math.log1p(-x));
} else if (y <= 5.5e+91) {
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 <= -8000000000000.0: tmp = 1.0 + ((((1.0 - x) / (y * (x + -1.0))) - math.log((-1.0 / y))) - math.log1p(-x)) elif y <= 5.5e+91: 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 <= -8000000000000.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 <= 5.5e+91) 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, -8000000000000.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, 5.5e+91], 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 -8000000000000:\\
\;\;\;\;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 5.5 \cdot 10^{+91}:\\
\;\;\;\;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 < -8e12Initial program 20.4%
sub-neg20.4%
log1p-def20.4%
distribute-neg-frac20.4%
sub-neg20.4%
distribute-neg-in20.4%
remove-double-neg20.4%
+-commutative20.4%
sub-neg20.4%
Simplified20.4%
Taylor expanded in y around -inf 99.6%
sub-neg99.6%
metadata-eval99.6%
distribute-lft-in99.6%
metadata-eval99.6%
+-commutative99.6%
log1p-def99.6%
mul-1-neg99.6%
mul-1-neg99.6%
unsub-neg99.6%
div-sub99.6%
associate-/l/99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
if -8e12 < y < 5.4999999999999998e91Initial program 99.8%
sub-neg99.8%
log1p-def99.9%
distribute-neg-frac99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if 5.4999999999999998e91 < y Initial program 57.5%
sub-neg57.5%
log1p-def57.5%
distribute-neg-frac57.5%
sub-neg57.5%
distribute-neg-in57.5%
remove-double-neg57.5%
+-commutative57.5%
sub-neg57.5%
Simplified57.5%
Taylor expanded in y around inf 97.9%
log-rec97.9%
unsub-neg97.9%
sub-neg97.9%
metadata-eval97.9%
+-commutative97.9%
Simplified97.9%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (<= y -8000000000000.0)
(- (- 1.0 (log (/ -1.0 y))) (log1p (- x)))
(if (<= y 3.8e+100)
(- 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 <= -8000000000000.0) {
tmp = (1.0 - log((-1.0 / y))) - log1p(-x);
} else if (y <= 3.8e+100) {
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 <= -8000000000000.0) {
tmp = (1.0 - Math.log((-1.0 / y))) - Math.log1p(-x);
} else if (y <= 3.8e+100) {
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 <= -8000000000000.0: tmp = (1.0 - math.log((-1.0 / y))) - math.log1p(-x) elif y <= 3.8e+100: 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 <= -8000000000000.0) tmp = Float64(Float64(1.0 - log(Float64(-1.0 / y))) - log1p(Float64(-x))); elseif (y <= 3.8e+100) 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, -8000000000000.0], N[(N[(1.0 - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e+100], 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 -8000000000000:\\
\;\;\;\;\left(1 - \log \left(\frac{-1}{y}\right)\right) - \mathsf{log1p}\left(-x\right)\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+100}:\\
\;\;\;\;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 < -8e12Initial program 20.4%
sub-neg20.4%
log1p-def20.4%
distribute-neg-frac20.4%
sub-neg20.4%
distribute-neg-in20.4%
remove-double-neg20.4%
+-commutative20.4%
sub-neg20.4%
Simplified20.4%
Taylor expanded in y around -inf 99.5%
+-commutative99.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%
if -8e12 < y < 3.79999999999999963e100Initial program 99.8%
sub-neg99.8%
log1p-def99.9%
distribute-neg-frac99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
if 3.79999999999999963e100 < y Initial program 57.5%
sub-neg57.5%
log1p-def57.5%
distribute-neg-frac57.5%
sub-neg57.5%
distribute-neg-in57.5%
remove-double-neg57.5%
+-commutative57.5%
sub-neg57.5%
Simplified57.5%
Taylor expanded in y around inf 97.9%
log-rec97.9%
unsub-neg97.9%
sub-neg97.9%
metadata-eval97.9%
+-commutative97.9%
Simplified97.9%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (<= (+ 1.0 (/ (- y x) (- 1.0 y))) 5e-14) (- (+ 1.0 (/ -1.0 y)) (log (/ -1.0 y))) (- 1.0 (log1p (+ (/ y (- 1.0 y)) (* x (/ -1.0 (- 1.0 y))))))))
double code(double x, double y) {
double tmp;
if ((1.0 + ((y - x) / (1.0 - y))) <= 5e-14) {
tmp = (1.0 + (-1.0 / y)) - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(((y / (1.0 - y)) + (x * (-1.0 / (1.0 - y)))));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((1.0 + ((y - x) / (1.0 - y))) <= 5e-14) {
tmp = (1.0 + (-1.0 / y)) - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(((y / (1.0 - y)) + (x * (-1.0 / (1.0 - y)))));
}
return tmp;
}
def code(x, y): tmp = 0 if (1.0 + ((y - x) / (1.0 - y))) <= 5e-14: tmp = (1.0 + (-1.0 / y)) - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(((y / (1.0 - y)) + (x * (-1.0 / (1.0 - y))))) return tmp
function code(x, y) tmp = 0.0 if (Float64(1.0 + Float64(Float64(y - x) / Float64(1.0 - y))) <= 5e-14) tmp = Float64(Float64(1.0 + Float64(-1.0 / y)) - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(Float64(y / Float64(1.0 - y)) + Float64(x * Float64(-1.0 / Float64(1.0 - y)))))); end return tmp end
code[x_, y_] := If[LessEqual[N[(1.0 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e-14], N[(N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(N[(y / N[(1.0 - y), $MachinePrecision]), $MachinePrecision] + N[(x * N[(-1.0 / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 + \frac{y - x}{1 - y} \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\left(1 + \frac{-1}{y}\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y}{1 - y} + x \cdot \frac{-1}{1 - y}\right)\\
\end{array}
\end{array}
if (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) < 5.0000000000000002e-14Initial program 4.3%
sub-neg4.3%
log1p-def4.3%
distribute-neg-frac4.3%
sub-neg4.3%
distribute-neg-in4.3%
remove-double-neg4.3%
+-commutative4.3%
sub-neg4.3%
Simplified4.3%
Taylor expanded in y around -inf 89.4%
sub-neg89.4%
metadata-eval89.4%
distribute-lft-in89.4%
metadata-eval89.4%
+-commutative89.4%
log1p-def89.4%
mul-1-neg89.4%
mul-1-neg89.4%
unsub-neg89.4%
div-sub89.4%
associate-/l/89.4%
sub-neg89.4%
metadata-eval89.4%
+-commutative89.4%
Simplified89.4%
Taylor expanded in x around 0 78.7%
+-commutative78.7%
associate--r+78.7%
Simplified78.7%
if 5.0000000000000002e-14 < (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) Initial program 99.9%
sub-neg99.9%
log1p-def99.9%
distribute-neg-frac99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
div-inv99.9%
*-commutative99.9%
sub-neg99.9%
distribute-lft-in99.9%
*-commutative99.9%
div-inv99.9%
Applied egg-rr99.9%
Final simplification94.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (- y x) (- 1.0 y))))
(if (<= (+ 1.0 t_0) 5e-14)
(- (+ 1.0 (/ -1.0 y)) (log (/ -1.0 y)))
(- 1.0 (log1p t_0)))))
double code(double x, double y) {
double t_0 = (y - x) / (1.0 - y);
double tmp;
if ((1.0 + t_0) <= 5e-14) {
tmp = (1.0 + (-1.0 / y)) - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(t_0);
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = (y - x) / (1.0 - y);
double tmp;
if ((1.0 + t_0) <= 5e-14) {
tmp = (1.0 + (-1.0 / y)) - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(t_0);
}
return tmp;
}
def code(x, y): t_0 = (y - x) / (1.0 - y) tmp = 0 if (1.0 + t_0) <= 5e-14: tmp = (1.0 + (-1.0 / y)) - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(t_0) return tmp
function code(x, y) t_0 = Float64(Float64(y - x) / Float64(1.0 - y)) tmp = 0.0 if (Float64(1.0 + t_0) <= 5e-14) tmp = Float64(Float64(1.0 + Float64(-1.0 / y)) - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(t_0)); end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], 5e-14], N[(N[(1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + t$95$0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y - x}{1 - y}\\
\mathbf{if}\;1 + t_0 \leq 5 \cdot 10^{-14}:\\
\;\;\;\;\left(1 + \frac{-1}{y}\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(t_0\right)\\
\end{array}
\end{array}
if (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) < 5.0000000000000002e-14Initial program 4.3%
sub-neg4.3%
log1p-def4.3%
distribute-neg-frac4.3%
sub-neg4.3%
distribute-neg-in4.3%
remove-double-neg4.3%
+-commutative4.3%
sub-neg4.3%
Simplified4.3%
Taylor expanded in y around -inf 89.4%
sub-neg89.4%
metadata-eval89.4%
distribute-lft-in89.4%
metadata-eval89.4%
+-commutative89.4%
log1p-def89.4%
mul-1-neg89.4%
mul-1-neg89.4%
unsub-neg89.4%
div-sub89.4%
associate-/l/89.4%
sub-neg89.4%
metadata-eval89.4%
+-commutative89.4%
Simplified89.4%
Taylor expanded in x around 0 78.7%
+-commutative78.7%
associate--r+78.7%
Simplified78.7%
if 5.0000000000000002e-14 < (-.f64 1 (/.f64 (-.f64 x y) (-.f64 1 y))) Initial program 99.9%
sub-neg99.9%
log1p-def99.9%
distribute-neg-frac99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Final simplification94.3%
(FPCore (x y) :precision binary64 (if (<= y -1.15e+20) (- (+ 1.0 x) (log (/ -1.0 y))) (- 1.0 (log1p (/ (- y x) (- 1.0 y))))))
double code(double x, double y) {
double tmp;
if (y <= -1.15e+20) {
tmp = (1.0 + x) - log((-1.0 / y));
} else {
tmp = 1.0 - log1p(((y - x) / (1.0 - y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1.15e+20) {
tmp = (1.0 + x) - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p(((y - x) / (1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.15e+20: tmp = (1.0 + x) - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p(((y - x) / (1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.15e+20) tmp = Float64(Float64(1.0 + x) - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(Float64(y - x) / Float64(1.0 - y)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.15e+20], N[(N[(1.0 + x), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(N[(y - x), $MachinePrecision] / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+20}:\\
\;\;\;\;\left(1 + x\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{y - x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -1.15e20Initial program 17.4%
sub-neg17.4%
log1p-def17.4%
distribute-neg-frac17.4%
sub-neg17.4%
distribute-neg-in17.4%
remove-double-neg17.4%
+-commutative17.4%
sub-neg17.4%
Simplified17.4%
Taylor expanded in y around -inf 99.6%
sub-neg99.6%
metadata-eval99.6%
distribute-lft-in99.6%
metadata-eval99.6%
+-commutative99.6%
log1p-def99.6%
mul-1-neg99.6%
mul-1-neg99.6%
unsub-neg99.6%
div-sub99.6%
associate-/l/99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in x around 0 73.5%
associate--r+73.5%
Simplified73.5%
Taylor expanded in y around -inf 73.5%
if -1.15e20 < y Initial program 95.6%
sub-neg95.6%
log1p-def95.7%
distribute-neg-frac95.7%
sub-neg95.7%
distribute-neg-in95.7%
remove-double-neg95.7%
+-commutative95.7%
sub-neg95.7%
Simplified95.7%
Final simplification89.8%
(FPCore (x y) :precision binary64 (if (or (<= y -2.0) (not (<= y 1.0))) (- 1.0 (log1p (/ x y))) (- 1.0 (+ y (log1p (- x))))))
double code(double x, double y) {
double tmp;
if ((y <= -2.0) || !(y <= 1.0)) {
tmp = 1.0 - log1p((x / y));
} else {
tmp = 1.0 - (y + log1p(-x));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((y <= -2.0) || !(y <= 1.0)) {
tmp = 1.0 - Math.log1p((x / y));
} else {
tmp = 1.0 - (y + Math.log1p(-x));
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.0) or not (y <= 1.0): tmp = 1.0 - math.log1p((x / y)) else: tmp = 1.0 - (y + math.log1p(-x)) return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.0) || !(y <= 1.0)) tmp = Float64(1.0 - log1p(Float64(x / y))); else tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -2.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\end{array}
\end{array}
if y < -2 or 1 < y Initial program 37.6%
sub-neg37.6%
log1p-def37.6%
distribute-neg-frac37.6%
sub-neg37.6%
distribute-neg-in37.6%
remove-double-neg37.6%
+-commutative37.6%
sub-neg37.6%
Simplified37.6%
div-inv38.9%
*-commutative38.9%
Applied egg-rr38.9%
Taylor expanded in y around inf 37.2%
Taylor expanded in y around 0 41.4%
if -2 < y < 1Initial program 99.9%
sub-neg99.9%
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 99.7%
+-commutative99.7%
*-commutative99.7%
mul-1-neg99.7%
sub-neg99.7%
mul-1-neg99.7%
sub-neg99.7%
div-sub99.7%
*-inverses99.7%
metadata-eval99.7%
distribute-lft-neg-in99.7%
neg-mul-199.7%
remove-double-neg99.7%
log1p-def99.7%
mul-1-neg99.7%
Simplified99.7%
Final simplification76.2%
(FPCore (x y) :precision binary64 (if (<= y -20.0) (- (+ 1.0 x) (log (/ -1.0 y))) (if (<= y 1.0) (- 1.0 (+ y (log1p (- x)))) (- 1.0 (log1p (/ x y))))))
double code(double x, double y) {
double tmp;
if (y <= -20.0) {
tmp = (1.0 + x) - log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - (y + log1p(-x));
} else {
tmp = 1.0 - log1p((x / y));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -20.0) {
tmp = (1.0 + x) - Math.log((-1.0 / y));
} else if (y <= 1.0) {
tmp = 1.0 - (y + Math.log1p(-x));
} else {
tmp = 1.0 - Math.log1p((x / y));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -20.0: tmp = (1.0 + x) - math.log((-1.0 / y)) elif y <= 1.0: tmp = 1.0 - (y + math.log1p(-x)) else: tmp = 1.0 - math.log1p((x / y)) return tmp
function code(x, y) tmp = 0.0 if (y <= -20.0) tmp = Float64(Float64(1.0 + x) - log(Float64(-1.0 / y))); elseif (y <= 1.0) tmp = Float64(1.0 - Float64(y + log1p(Float64(-x)))); else tmp = Float64(1.0 - log1p(Float64(x / y))); end return tmp end
code[x_, y_] := If[LessEqual[y, -20.0], N[(N[(1.0 + x), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(1.0 - N[(y + N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -20:\\
\;\;\;\;\left(1 + x\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;1 - \left(y + \mathsf{log1p}\left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if y < -20Initial program 23.3%
sub-neg23.3%
log1p-def23.3%
distribute-neg-frac23.3%
sub-neg23.3%
distribute-neg-in23.3%
remove-double-neg23.3%
+-commutative23.3%
sub-neg23.3%
Simplified23.3%
Taylor expanded in y around -inf 99.3%
sub-neg99.3%
metadata-eval99.3%
distribute-lft-in99.3%
metadata-eval99.3%
+-commutative99.3%
log1p-def99.3%
mul-1-neg99.3%
mul-1-neg99.3%
unsub-neg99.3%
div-sub99.3%
associate-/l/99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in x around 0 70.6%
associate--r+70.6%
Simplified70.6%
Taylor expanded in y around -inf 70.2%
if -20 < y < 1Initial program 99.9%
sub-neg99.9%
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 99.7%
+-commutative99.7%
*-commutative99.7%
mul-1-neg99.7%
sub-neg99.7%
mul-1-neg99.7%
sub-neg99.7%
div-sub99.7%
*-inverses99.7%
metadata-eval99.7%
distribute-lft-neg-in99.7%
neg-mul-199.7%
remove-double-neg99.7%
log1p-def99.7%
mul-1-neg99.7%
Simplified99.7%
if 1 < y Initial program 75.7%
sub-neg75.7%
log1p-def75.7%
distribute-neg-frac75.7%
sub-neg75.7%
distribute-neg-in75.7%
remove-double-neg75.7%
+-commutative75.7%
sub-neg75.7%
Simplified75.7%
div-inv76.2%
*-commutative76.2%
Applied egg-rr76.2%
Taylor expanded in y around inf 75.1%
Taylor expanded in y around 0 75.1%
Final simplification88.3%
(FPCore (x y) :precision binary64 (if (<= y -1.2e+19) (- (+ 1.0 x) (log (/ -1.0 y))) (- 1.0 (log1p (/ (- x) (- 1.0 y))))))
double code(double x, double y) {
double tmp;
if (y <= -1.2e+19) {
tmp = (1.0 + x) - log((-1.0 / y));
} else {
tmp = 1.0 - log1p((-x / (1.0 - y)));
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if (y <= -1.2e+19) {
tmp = (1.0 + x) - Math.log((-1.0 / y));
} else {
tmp = 1.0 - Math.log1p((-x / (1.0 - y)));
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.2e+19: tmp = (1.0 + x) - math.log((-1.0 / y)) else: tmp = 1.0 - math.log1p((-x / (1.0 - y))) return tmp
function code(x, y) tmp = 0.0 if (y <= -1.2e+19) tmp = Float64(Float64(1.0 + x) - log(Float64(-1.0 / y))); else tmp = Float64(1.0 - log1p(Float64(Float64(-x) / Float64(1.0 - y)))); end return tmp end
code[x_, y_] := If[LessEqual[y, -1.2e+19], N[(N[(1.0 + x), $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + N[((-x) / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+19}:\\
\;\;\;\;\left(1 + x\right) - \log \left(\frac{-1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{-x}{1 - y}\right)\\
\end{array}
\end{array}
if y < -1.2e19Initial program 17.4%
sub-neg17.4%
log1p-def17.4%
distribute-neg-frac17.4%
sub-neg17.4%
distribute-neg-in17.4%
remove-double-neg17.4%
+-commutative17.4%
sub-neg17.4%
Simplified17.4%
Taylor expanded in y around -inf 99.6%
sub-neg99.6%
metadata-eval99.6%
distribute-lft-in99.6%
metadata-eval99.6%
+-commutative99.6%
log1p-def99.6%
mul-1-neg99.6%
mul-1-neg99.6%
unsub-neg99.6%
div-sub99.6%
associate-/l/99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in x around 0 73.5%
associate--r+73.5%
Simplified73.5%
Taylor expanded in y around -inf 73.5%
if -1.2e19 < y Initial program 95.6%
sub-neg95.6%
log1p-def95.7%
distribute-neg-frac95.7%
sub-neg95.7%
distribute-neg-in95.7%
remove-double-neg95.7%
+-commutative95.7%
sub-neg95.7%
Simplified95.7%
Taylor expanded in x around inf 94.3%
mul-1-neg94.3%
distribute-neg-frac94.3%
Simplified94.3%
Final simplification88.8%
(FPCore (x y) :precision binary64 (if (or (<= y -120000.0) (not (<= y 1.38e-14))) (- 1.0 (log1p (/ x y))) (- 1.0 (log1p (- x)))))
double code(double x, double y) {
double tmp;
if ((y <= -120000.0) || !(y <= 1.38e-14)) {
tmp = 1.0 - log1p((x / y));
} else {
tmp = 1.0 - log1p(-x);
}
return tmp;
}
public static double code(double x, double y) {
double tmp;
if ((y <= -120000.0) || !(y <= 1.38e-14)) {
tmp = 1.0 - Math.log1p((x / y));
} else {
tmp = 1.0 - Math.log1p(-x);
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -120000.0) or not (y <= 1.38e-14): tmp = 1.0 - math.log1p((x / y)) else: tmp = 1.0 - math.log1p(-x) return tmp
function code(x, y) tmp = 0.0 if ((y <= -120000.0) || !(y <= 1.38e-14)) tmp = Float64(1.0 - log1p(Float64(x / y))); else tmp = Float64(1.0 - log1p(Float64(-x))); end return tmp end
code[x_, y_] := If[Or[LessEqual[y, -120000.0], N[Not[LessEqual[y, 1.38e-14]], $MachinePrecision]], N[(1.0 - N[Log[1 + N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Log[1 + (-x)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -120000 \lor \neg \left(y \leq 1.38 \cdot 10^{-14}\right):\\
\;\;\;\;1 - \mathsf{log1p}\left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \mathsf{log1p}\left(-x\right)\\
\end{array}
\end{array}
if y < -1.2e5 or 1.38000000000000002e-14 < y Initial program 39.5%
sub-neg39.5%
log1p-def39.5%
distribute-neg-frac39.5%
sub-neg39.5%
distribute-neg-in39.5%
remove-double-neg39.5%
+-commutative39.5%
sub-neg39.5%
Simplified39.5%
div-inv40.8%
*-commutative40.8%
Applied egg-rr40.8%
Taylor expanded in y around inf 36.1%
Taylor expanded in y around 0 42.5%
if -1.2e5 < y < 1.38000000000000002e-14Initial program 99.8%
sub-neg99.8%
log1p-def99.9%
distribute-neg-frac99.9%
sub-neg99.9%
distribute-neg-in99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 99.3%
log1p-def99.3%
mul-1-neg99.3%
Simplified99.3%
Final simplification75.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 74.8%
sub-neg74.8%
log1p-def74.9%
distribute-neg-frac74.9%
sub-neg74.9%
distribute-neg-in74.9%
remove-double-neg74.9%
+-commutative74.9%
sub-neg74.9%
Simplified74.9%
Taylor expanded in y around 0 63.1%
log1p-def63.2%
mul-1-neg63.2%
Simplified63.2%
Final simplification63.2%
(FPCore (x y) :precision binary64 (if (<= y -8000000000000.0) (+ 1.0 (/ (- (/ 1.0 (+ x -1.0)) (/ x (+ x -1.0))) y)) (+ 1.0 (- (/ x (* (- 1.0 y) (+ 1.0 (+ -1.0 (/ -1.0 y))))) y))))
double code(double x, double y) {
double tmp;
if (y <= -8000000000000.0) {
tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y);
} else {
tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (-1.0 + (-1.0 / y))))) - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-8000000000000.0d0)) then
tmp = 1.0d0 + (((1.0d0 / (x + (-1.0d0))) - (x / (x + (-1.0d0)))) / y)
else
tmp = 1.0d0 + ((x / ((1.0d0 - y) * (1.0d0 + ((-1.0d0) + ((-1.0d0) / y))))) - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8000000000000.0) {
tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y);
} else {
tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (-1.0 + (-1.0 / y))))) - y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8000000000000.0: tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y) else: tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (-1.0 + (-1.0 / y))))) - y) return tmp
function code(x, y) tmp = 0.0 if (y <= -8000000000000.0) tmp = Float64(1.0 + Float64(Float64(Float64(1.0 / Float64(x + -1.0)) - Float64(x / Float64(x + -1.0))) / y)); else tmp = Float64(1.0 + Float64(Float64(x / Float64(Float64(1.0 - y) * Float64(1.0 + Float64(-1.0 + Float64(-1.0 / y))))) - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8000000000000.0) tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y); else tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (-1.0 + (-1.0 / y))))) - y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8000000000000.0], N[(1.0 + N[(N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / N[(N[(1.0 - y), $MachinePrecision] * N[(1.0 + N[(-1.0 + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8000000000000:\\
\;\;\;\;1 + \frac{\frac{1}{x + -1} - \frac{x}{x + -1}}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\frac{x}{\left(1 - y\right) \cdot \left(1 + \left(-1 + \frac{-1}{y}\right)\right)} - y\right)\\
\end{array}
\end{array}
if y < -8e12Initial program 20.4%
sub-neg20.4%
log1p-def20.4%
distribute-neg-frac20.4%
sub-neg20.4%
distribute-neg-in20.4%
remove-double-neg20.4%
+-commutative20.4%
sub-neg20.4%
Simplified20.4%
Taylor expanded in y around -inf 99.6%
sub-neg99.6%
metadata-eval99.6%
distribute-lft-in99.6%
metadata-eval99.6%
+-commutative99.6%
log1p-def99.6%
mul-1-neg99.6%
mul-1-neg99.6%
unsub-neg99.6%
div-sub99.6%
associate-/l/99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in y around 0 12.2%
if -8e12 < y Initial program 96.2%
sub-neg96.2%
log1p-def96.2%
distribute-neg-frac96.2%
sub-neg96.2%
distribute-neg-in96.2%
remove-double-neg96.2%
+-commutative96.2%
sub-neg96.2%
Simplified96.2%
Taylor expanded in x around 0 55.0%
mul-1-neg55.0%
unsub-neg55.0%
log1p-def55.0%
*-commutative55.0%
Simplified55.0%
Taylor expanded in y around 0 54.7%
Taylor expanded in y around inf 52.7%
neg-sub052.7%
associate--r+52.7%
metadata-eval52.7%
Simplified52.7%
Final simplification41.3%
(FPCore (x y) :precision binary64 (if (<= y -8000000000000.0) (+ 1.0 (/ (- (/ 1.0 (+ x -1.0)) (/ x (+ x -1.0))) y)) (+ 1.0 (- (/ x (* (- 1.0 y) (+ 1.0 (/ y (- 1.0 y))))) y))))
double code(double x, double y) {
double tmp;
if (y <= -8000000000000.0) {
tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y);
} else {
tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (y / (1.0 - y))))) - y);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-8000000000000.0d0)) then
tmp = 1.0d0 + (((1.0d0 / (x + (-1.0d0))) - (x / (x + (-1.0d0)))) / y)
else
tmp = 1.0d0 + ((x / ((1.0d0 - y) * (1.0d0 + (y / (1.0d0 - y))))) - y)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -8000000000000.0) {
tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y);
} else {
tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (y / (1.0 - y))))) - y);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -8000000000000.0: tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y) else: tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (y / (1.0 - y))))) - y) return tmp
function code(x, y) tmp = 0.0 if (y <= -8000000000000.0) tmp = Float64(1.0 + Float64(Float64(Float64(1.0 / Float64(x + -1.0)) - Float64(x / Float64(x + -1.0))) / y)); else tmp = Float64(1.0 + Float64(Float64(x / Float64(Float64(1.0 - y) * Float64(1.0 + Float64(y / Float64(1.0 - y))))) - y)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -8000000000000.0) tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y); else tmp = 1.0 + ((x / ((1.0 - y) * (1.0 + (y / (1.0 - y))))) - y); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -8000000000000.0], N[(1.0 + N[(N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x / N[(N[(1.0 - y), $MachinePrecision] * N[(1.0 + N[(y / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8000000000000:\\
\;\;\;\;1 + \frac{\frac{1}{x + -1} - \frac{x}{x + -1}}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(\frac{x}{\left(1 - y\right) \cdot \left(1 + \frac{y}{1 - y}\right)} - y\right)\\
\end{array}
\end{array}
if y < -8e12Initial program 20.4%
sub-neg20.4%
log1p-def20.4%
distribute-neg-frac20.4%
sub-neg20.4%
distribute-neg-in20.4%
remove-double-neg20.4%
+-commutative20.4%
sub-neg20.4%
Simplified20.4%
Taylor expanded in y around -inf 99.6%
sub-neg99.6%
metadata-eval99.6%
distribute-lft-in99.6%
metadata-eval99.6%
+-commutative99.6%
log1p-def99.6%
mul-1-neg99.6%
mul-1-neg99.6%
unsub-neg99.6%
div-sub99.6%
associate-/l/99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in y around 0 12.2%
if -8e12 < y Initial program 96.2%
sub-neg96.2%
log1p-def96.2%
distribute-neg-frac96.2%
sub-neg96.2%
distribute-neg-in96.2%
remove-double-neg96.2%
+-commutative96.2%
sub-neg96.2%
Simplified96.2%
Taylor expanded in x around 0 55.0%
mul-1-neg55.0%
unsub-neg55.0%
log1p-def55.0%
*-commutative55.0%
Simplified55.0%
Taylor expanded in y around 0 54.7%
Final simplification42.7%
(FPCore (x y) :precision binary64 (+ 1.0 (/ (- (/ 1.0 (+ x -1.0)) (/ x (+ x -1.0))) y)))
double code(double x, double y) {
return 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 + (((1.0d0 / (x + (-1.0d0))) - (x / (x + (-1.0d0)))) / y)
end function
public static double code(double x, double y) {
return 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y);
}
def code(x, y): return 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y)
function code(x, y) return Float64(1.0 + Float64(Float64(Float64(1.0 / Float64(x + -1.0)) - Float64(x / Float64(x + -1.0))) / y)) end
function tmp = code(x, y) tmp = 1.0 + (((1.0 / (x + -1.0)) - (x / (x + -1.0))) / y); end
code[x_, y_] := N[(1.0 + N[(N[(N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision] - N[(x / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{\frac{1}{x + -1} - \frac{x}{x + -1}}{y}
\end{array}
Initial program 74.8%
sub-neg74.8%
log1p-def74.9%
distribute-neg-frac74.9%
sub-neg74.9%
distribute-neg-in74.9%
remove-double-neg74.9%
+-commutative74.9%
sub-neg74.9%
Simplified74.9%
Taylor expanded in y around -inf 30.1%
sub-neg30.1%
metadata-eval30.1%
distribute-lft-in30.1%
metadata-eval30.1%
+-commutative30.1%
log1p-def30.1%
mul-1-neg30.1%
mul-1-neg30.1%
unsub-neg30.1%
div-sub30.1%
associate-/l/30.1%
sub-neg30.1%
metadata-eval30.1%
+-commutative30.1%
Simplified30.1%
Taylor expanded in y around 0 6.0%
Final simplification6.0%
(FPCore (x y) :precision binary64 (/ (+ -1.0 (/ 1.0 (+ x -1.0))) y))
double code(double x, double y) {
return (-1.0 + (1.0 / (x + -1.0))) / y;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((-1.0d0) + (1.0d0 / (x + (-1.0d0)))) / y
end function
public static double code(double x, double y) {
return (-1.0 + (1.0 / (x + -1.0))) / y;
}
def code(x, y): return (-1.0 + (1.0 / (x + -1.0))) / y
function code(x, y) return Float64(Float64(-1.0 + Float64(1.0 / Float64(x + -1.0))) / y) end
function tmp = code(x, y) tmp = (-1.0 + (1.0 / (x + -1.0))) / y; end
code[x_, y_] := N[(N[(-1.0 + N[(1.0 / N[(x + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{-1 + \frac{1}{x + -1}}{y}
\end{array}
Initial program 74.8%
sub-neg74.8%
log1p-def74.9%
distribute-neg-frac74.9%
sub-neg74.9%
distribute-neg-in74.9%
remove-double-neg74.9%
+-commutative74.9%
sub-neg74.9%
Simplified74.9%
Taylor expanded in y around -inf 30.1%
sub-neg30.1%
metadata-eval30.1%
distribute-lft-in30.1%
metadata-eval30.1%
+-commutative30.1%
log1p-def30.1%
mul-1-neg30.1%
mul-1-neg30.1%
unsub-neg30.1%
div-sub30.1%
associate-/l/30.1%
sub-neg30.1%
metadata-eval30.1%
+-commutative30.1%
Simplified30.1%
Taylor expanded in y around 0 3.9%
Taylor expanded in x around inf 3.9%
Final simplification3.9%
(FPCore (x y) :precision binary64 (+ x (/ -1.0 y)))
double code(double x, double y) {
return x + (-1.0 / y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((-1.0d0) / y)
end function
public static double code(double x, double y) {
return x + (-1.0 / y);
}
def code(x, y): return x + (-1.0 / y)
function code(x, y) return Float64(x + Float64(-1.0 / y)) end
function tmp = code(x, y) tmp = x + (-1.0 / y); end
code[x_, y_] := N[(x + N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{y}
\end{array}
Initial program 74.8%
sub-neg74.8%
log1p-def74.9%
distribute-neg-frac74.9%
sub-neg74.9%
distribute-neg-in74.9%
remove-double-neg74.9%
+-commutative74.9%
sub-neg74.9%
Simplified74.9%
Taylor expanded in y around -inf 30.1%
sub-neg30.1%
metadata-eval30.1%
distribute-lft-in30.1%
metadata-eval30.1%
+-commutative30.1%
log1p-def30.1%
mul-1-neg30.1%
mul-1-neg30.1%
unsub-neg30.1%
div-sub30.1%
associate-/l/30.1%
sub-neg30.1%
metadata-eval30.1%
+-commutative30.1%
Simplified30.1%
Taylor expanded in x around 0 21.8%
associate--r+21.8%
Simplified21.8%
Taylor expanded in x around inf 3.6%
Final simplification3.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 2023301
(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))))))