
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ y (+ y x)) (/ (/ x (+ y x)) (+ y (+ x 1.0)))))
assert(x < y);
double code(double x, double y) {
return (y / (y + x)) * ((x / (y + x)) / (y + (x + 1.0)));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / (y + x)) * ((x / (y + x)) / (y + (x + 1.0d0)))
end function
assert x < y;
public static double code(double x, double y) {
return (y / (y + x)) * ((x / (y + x)) / (y + (x + 1.0)));
}
[x, y] = sort([x, y]) def code(x, y): return (y / (y + x)) * ((x / (y + x)) / (y + (x + 1.0)))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(y / Float64(y + x)) * Float64(Float64(x / Float64(y + x)) / Float64(y + Float64(x + 1.0)))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (y / (y + x)) * ((x / (y + x)) / (y + (x + 1.0)));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{y}{y + x} \cdot \frac{\frac{x}{y + x}}{y + \left(x + 1\right)}
\end{array}
Initial program 71.2%
*-commutative71.2%
associate-*l*71.3%
times-frac95.2%
+-commutative95.2%
+-commutative95.2%
associate-+r+95.2%
+-commutative95.2%
associate-+l+95.2%
Applied egg-rr95.2%
div-inv95.1%
distribute-rgt-in92.4%
+-commutative92.4%
distribute-rgt-in95.1%
+-commutative95.1%
Applied egg-rr95.1%
associate-*r/95.2%
*-rgt-identity95.2%
associate-/r*99.8%
Simplified99.8%
Final simplification99.8%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y x))))
(if (<= x -1.16e+85)
(/ t_0 (+ y x))
(if (<= x -2.05e-13)
(* x (/ y (* (* (+ y x) (+ y x)) (+ x (+ y 1.0)))))
(/ t_0 (* (+ y x) (/ (+ y 1.0) x)))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (y + x);
double tmp;
if (x <= -1.16e+85) {
tmp = t_0 / (y + x);
} else if (x <= -2.05e-13) {
tmp = x * (y / (((y + x) * (y + x)) * (x + (y + 1.0))));
} else {
tmp = t_0 / ((y + x) * ((y + 1.0) / x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 = y / (y + x)
if (x <= (-1.16d+85)) then
tmp = t_0 / (y + x)
else if (x <= (-2.05d-13)) then
tmp = x * (y / (((y + x) * (y + x)) * (x + (y + 1.0d0))))
else
tmp = t_0 / ((y + x) * ((y + 1.0d0) / x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (y + x);
double tmp;
if (x <= -1.16e+85) {
tmp = t_0 / (y + x);
} else if (x <= -2.05e-13) {
tmp = x * (y / (((y + x) * (y + x)) * (x + (y + 1.0))));
} else {
tmp = t_0 / ((y + x) * ((y + 1.0) / x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (y + x) tmp = 0 if x <= -1.16e+85: tmp = t_0 / (y + x) elif x <= -2.05e-13: tmp = x * (y / (((y + x) * (y + x)) * (x + (y + 1.0)))) else: tmp = t_0 / ((y + x) * ((y + 1.0) / x)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(y + x)) tmp = 0.0 if (x <= -1.16e+85) tmp = Float64(t_0 / Float64(y + x)); elseif (x <= -2.05e-13) tmp = Float64(x * Float64(y / Float64(Float64(Float64(y + x) * Float64(y + x)) * Float64(x + Float64(y + 1.0))))); else tmp = Float64(t_0 / Float64(Float64(y + x) * Float64(Float64(y + 1.0) / x))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (y + x);
tmp = 0.0;
if (x <= -1.16e+85)
tmp = t_0 / (y + x);
elseif (x <= -2.05e-13)
tmp = x * (y / (((y + x) * (y + x)) * (x + (y + 1.0))));
else
tmp = t_0 / ((y + x) * ((y + 1.0) / x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.16e+85], N[(t$95$0 / N[(y + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.05e-13], N[(x * N[(y / N[(N[(N[(y + x), $MachinePrecision] * N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x + N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(N[(y + x), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{y + x}\\
\mathbf{if}\;x \leq -1.16 \cdot 10^{+85}:\\
\;\;\;\;\frac{t\_0}{y + x}\\
\mathbf{elif}\;x \leq -2.05 \cdot 10^{-13}:\\
\;\;\;\;x \cdot \frac{y}{\left(\left(y + x\right) \cdot \left(y + x\right)\right) \cdot \left(x + \left(y + 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\left(y + x\right) \cdot \frac{y + 1}{x}}\\
\end{array}
\end{array}
if x < -1.15999999999999995e85Initial program 66.5%
*-commutative66.5%
associate-*l*66.5%
times-frac90.2%
+-commutative90.2%
+-commutative90.2%
associate-+r+90.2%
+-commutative90.2%
associate-+l+90.2%
Applied egg-rr90.2%
div-inv90.2%
distribute-rgt-in82.3%
+-commutative82.3%
distribute-rgt-in90.2%
+-commutative90.2%
Applied egg-rr90.2%
associate-*r/90.2%
*-rgt-identity90.2%
associate-/r*99.9%
Simplified99.9%
associate-/l/90.2%
*-commutative90.2%
clear-num90.2%
un-div-inv90.2%
associate-/l*100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 93.3%
if -1.15999999999999995e85 < x < -2.0500000000000001e-13Initial program 78.6%
associate-/l*94.6%
associate-+l+94.6%
Simplified94.6%
if -2.0500000000000001e-13 < x Initial program 71.5%
*-commutative71.5%
associate-*l*71.6%
times-frac95.9%
+-commutative95.9%
+-commutative95.9%
associate-+r+95.9%
+-commutative95.9%
associate-+l+95.9%
Applied egg-rr95.9%
div-inv95.7%
distribute-rgt-in94.4%
+-commutative94.4%
distribute-rgt-in95.7%
+-commutative95.7%
Applied egg-rr95.7%
associate-*r/95.9%
*-rgt-identity95.9%
associate-/r*99.8%
Simplified99.8%
associate-/l/95.9%
*-commutative95.9%
clear-num95.8%
un-div-inv95.8%
associate-/l*99.6%
+-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 78.4%
+-commutative78.4%
Simplified78.4%
Final simplification82.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ y (+ x 1.0))))
(if (<= y 7.8e+174)
(* (/ y (+ y x)) (/ x (* (+ y x) t_0)))
(/ (/ x (+ y x)) t_0))))assert(x < y);
double code(double x, double y) {
double t_0 = y + (x + 1.0);
double tmp;
if (y <= 7.8e+174) {
tmp = (y / (y + x)) * (x / ((y + x) * t_0));
} else {
tmp = (x / (y + x)) / t_0;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 = y + (x + 1.0d0)
if (y <= 7.8d+174) then
tmp = (y / (y + x)) * (x / ((y + x) * t_0))
else
tmp = (x / (y + x)) / t_0
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y + (x + 1.0);
double tmp;
if (y <= 7.8e+174) {
tmp = (y / (y + x)) * (x / ((y + x) * t_0));
} else {
tmp = (x / (y + x)) / t_0;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y + (x + 1.0) tmp = 0 if y <= 7.8e+174: tmp = (y / (y + x)) * (x / ((y + x) * t_0)) else: tmp = (x / (y + x)) / t_0 return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y + Float64(x + 1.0)) tmp = 0.0 if (y <= 7.8e+174) tmp = Float64(Float64(y / Float64(y + x)) * Float64(x / Float64(Float64(y + x) * t_0))); else tmp = Float64(Float64(x / Float64(y + x)) / t_0); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y + (x + 1.0);
tmp = 0.0;
if (y <= 7.8e+174)
tmp = (y / (y + x)) * (x / ((y + x) * t_0));
else
tmp = (x / (y + x)) / t_0;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 7.8e+174], N[(N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(x / N[(N[(y + x), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := y + \left(x + 1\right)\\
\mathbf{if}\;y \leq 7.8 \cdot 10^{+174}:\\
\;\;\;\;\frac{y}{y + x} \cdot \frac{x}{\left(y + x\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{t\_0}\\
\end{array}
\end{array}
if y < 7.79999999999999962e174Initial program 72.1%
*-commutative72.1%
associate-*l*72.1%
times-frac95.3%
+-commutative95.3%
+-commutative95.3%
associate-+r+95.3%
+-commutative95.3%
associate-+l+95.3%
Applied egg-rr95.3%
if 7.79999999999999962e174 < y Initial program 61.9%
*-commutative61.9%
associate-*l*61.9%
times-frac94.7%
+-commutative94.7%
+-commutative94.7%
associate-+r+94.7%
+-commutative94.7%
associate-+l+94.7%
Applied egg-rr94.7%
div-inv94.7%
distribute-rgt-in76.5%
+-commutative76.5%
distribute-rgt-in94.7%
+-commutative94.7%
Applied egg-rr94.7%
associate-*r/94.7%
*-rgt-identity94.7%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in y around inf 88.9%
Final simplification94.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ y (+ y x))))
(if (<= x -1.8)
(* t_0 (/ 1.0 (+ y (+ x 1.0))))
(/ t_0 (* (+ y x) (/ (+ y 1.0) x))))))assert(x < y);
double code(double x, double y) {
double t_0 = y / (y + x);
double tmp;
if (x <= -1.8) {
tmp = t_0 * (1.0 / (y + (x + 1.0)));
} else {
tmp = t_0 / ((y + x) * ((y + 1.0) / x));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
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 = y / (y + x)
if (x <= (-1.8d0)) then
tmp = t_0 * (1.0d0 / (y + (x + 1.0d0)))
else
tmp = t_0 / ((y + x) * ((y + 1.0d0) / x))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double t_0 = y / (y + x);
double tmp;
if (x <= -1.8) {
tmp = t_0 * (1.0 / (y + (x + 1.0)));
} else {
tmp = t_0 / ((y + x) * ((y + 1.0) / x));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): t_0 = y / (y + x) tmp = 0 if x <= -1.8: tmp = t_0 * (1.0 / (y + (x + 1.0))) else: tmp = t_0 / ((y + x) * ((y + 1.0) / x)) return tmp
x, y = sort([x, y]) function code(x, y) t_0 = Float64(y / Float64(y + x)) tmp = 0.0 if (x <= -1.8) tmp = Float64(t_0 * Float64(1.0 / Float64(y + Float64(x + 1.0)))); else tmp = Float64(t_0 / Float64(Float64(y + x) * Float64(Float64(y + 1.0) / x))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
t_0 = y / (y + x);
tmp = 0.0;
if (x <= -1.8)
tmp = t_0 * (1.0 / (y + (x + 1.0)));
else
tmp = t_0 / ((y + x) * ((y + 1.0) / x));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_] := Block[{t$95$0 = N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.8], N[(t$95$0 * N[(1.0 / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(N[(y + x), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_0 := \frac{y}{y + x}\\
\mathbf{if}\;x \leq -1.8:\\
\;\;\;\;t\_0 \cdot \frac{1}{y + \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\left(y + x\right) \cdot \frac{y + 1}{x}}\\
\end{array}
\end{array}
if x < -1.80000000000000004Initial program 68.8%
*-commutative68.8%
associate-*l*68.8%
times-frac92.8%
+-commutative92.8%
+-commutative92.8%
associate-+r+92.8%
+-commutative92.8%
associate-+l+92.8%
Applied egg-rr92.8%
div-inv92.8%
distribute-rgt-in85.4%
+-commutative85.4%
distribute-rgt-in92.8%
+-commutative92.8%
Applied egg-rr92.8%
associate-*r/92.8%
*-rgt-identity92.8%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in x around inf 83.7%
if -1.80000000000000004 < x Initial program 72.0%
*-commutative72.0%
associate-*l*72.0%
times-frac95.9%
+-commutative95.9%
+-commutative95.9%
associate-+r+95.9%
+-commutative95.9%
associate-+l+95.9%
Applied egg-rr95.9%
div-inv95.8%
distribute-rgt-in94.4%
+-commutative94.4%
distribute-rgt-in95.8%
+-commutative95.8%
Applied egg-rr95.8%
associate-*r/95.9%
*-rgt-identity95.9%
associate-/r*99.8%
Simplified99.8%
associate-/l/95.9%
*-commutative95.9%
clear-num95.8%
un-div-inv95.8%
associate-/l*99.6%
+-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 78.1%
+-commutative78.1%
Simplified78.1%
Final simplification79.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.1e-88) (/ (/ y x) (+ x 1.0)) (/ (/ x (+ y x)) (+ y (+ x 1.0)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.1e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + x)) / (y + (x + 1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.1d-88) then
tmp = (y / x) / (x + 1.0d0)
else
tmp = (x / (y + x)) / (y + (x + 1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.1e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + x)) / (y + (x + 1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.1e-88: tmp = (y / x) / (x + 1.0) else: tmp = (x / (y + x)) / (y + (x + 1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.1e-88) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); else tmp = Float64(Float64(x / Float64(y + x)) / Float64(y + Float64(x + 1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.1e-88)
tmp = (y / x) / (x + 1.0);
else
tmp = (x / (y + x)) / (y + (x + 1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.1e-88], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{-88}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + x}}{y + \left(x + 1\right)}\\
\end{array}
\end{array}
if y < 1.10000000000000002e-88Initial program 72.3%
associate-/l*85.9%
associate-+l+85.9%
Simplified85.9%
Taylor expanded in y around 0 57.3%
associate-/r*60.0%
+-commutative60.0%
Simplified60.0%
if 1.10000000000000002e-88 < y Initial program 68.8%
*-commutative68.8%
associate-*l*68.8%
times-frac93.5%
+-commutative93.5%
+-commutative93.5%
associate-+r+93.5%
+-commutative93.5%
associate-+l+93.5%
Applied egg-rr93.5%
div-inv93.3%
distribute-rgt-in87.8%
+-commutative87.8%
distribute-rgt-in93.3%
+-commutative93.3%
Applied egg-rr93.3%
associate-*r/93.5%
*-rgt-identity93.5%
associate-/r*99.8%
Simplified99.8%
Taylor expanded in y around inf 65.5%
Final simplification61.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.1e-88) (/ (/ y x) (+ x 1.0)) (/ (/ x (+ y 1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.1e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + 1.0)) / (y + x);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.1d-88) then
tmp = (y / x) / (x + 1.0d0)
else
tmp = (x / (y + 1.0d0)) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.1e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / (y + 1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.1e-88: tmp = (y / x) / (x + 1.0) else: tmp = (x / (y + 1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.1e-88) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); else tmp = Float64(Float64(x / Float64(y + 1.0)) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.1e-88)
tmp = (y / x) / (x + 1.0);
else
tmp = (x / (y + 1.0)) / (y + x);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.1e-88], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{-88}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + 1}}{y + x}\\
\end{array}
\end{array}
if y < 1.10000000000000002e-88Initial program 72.3%
associate-/l*85.9%
associate-+l+85.9%
Simplified85.9%
Taylor expanded in y around 0 57.3%
associate-/r*60.0%
+-commutative60.0%
Simplified60.0%
if 1.10000000000000002e-88 < y Initial program 68.8%
*-commutative68.8%
associate-*l*68.8%
times-frac93.5%
+-commutative93.5%
+-commutative93.5%
associate-+r+93.5%
+-commutative93.5%
associate-+l+93.5%
Applied egg-rr93.5%
add-sqr-sqrt93.2%
associate-*l/93.2%
*-commutative93.2%
clear-num93.0%
associate-*l/93.0%
add-sqr-sqrt93.3%
frac-times88.6%
*-un-lft-identity88.6%
distribute-rgt-in83.2%
+-commutative83.2%
distribute-rgt-in88.6%
+-commutative88.6%
+-commutative88.6%
Applied egg-rr88.6%
Taylor expanded in x around 0 63.2%
associate-/l*63.1%
+-commutative63.1%
Simplified63.1%
*-un-lft-identity63.1%
+-commutative63.1%
*-commutative63.1%
times-frac64.3%
*-un-lft-identity64.3%
*-commutative64.3%
times-frac64.6%
clear-num64.5%
Applied egg-rr64.5%
associate-*l/64.6%
*-inverses64.6%
*-rgt-identity64.6%
*-lft-identity64.6%
Simplified64.6%
Final simplification61.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 4.5e-95) (/ y x) (/ x (* y (+ y 1.0)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 4.5e-95) {
tmp = y / x;
} else {
tmp = x / (y * (y + 1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 4.5d-95) then
tmp = y / x
else
tmp = x / (y * (y + 1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 4.5e-95) {
tmp = y / x;
} else {
tmp = x / (y * (y + 1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 4.5e-95: tmp = y / x else: tmp = x / (y * (y + 1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 4.5e-95) tmp = Float64(y / x); else tmp = Float64(x / Float64(y * Float64(y + 1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 4.5e-95)
tmp = y / x;
else
tmp = x / (y * (y + 1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 4.5e-95], N[(y / x), $MachinePrecision], N[(x / N[(y * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{-95}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\
\end{array}
\end{array}
if y < 4.5e-95Initial program 71.9%
associate-/l*86.2%
associate-+l+86.2%
Simplified86.2%
Taylor expanded in y around 0 56.6%
associate-/r*59.4%
+-commutative59.4%
Simplified59.4%
Taylor expanded in x around 0 34.1%
if 4.5e-95 < y Initial program 69.9%
associate-/l*81.4%
associate-+l+81.4%
Simplified81.4%
Taylor expanded in x around 0 65.4%
+-commutative65.4%
Simplified65.4%
Final simplification44.1%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1e-88) (/ y (* x (+ x 1.0))) (/ x (* y (+ y 1.0)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1e-88) {
tmp = y / (x * (x + 1.0));
} else {
tmp = x / (y * (y + 1.0));
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1d-88) then
tmp = y / (x * (x + 1.0d0))
else
tmp = x / (y * (y + 1.0d0))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1e-88) {
tmp = y / (x * (x + 1.0));
} else {
tmp = x / (y * (y + 1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1e-88: tmp = y / (x * (x + 1.0)) else: tmp = x / (y * (y + 1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1e-88) tmp = Float64(y / Float64(x * Float64(x + 1.0))); else tmp = Float64(x / Float64(y * Float64(y + 1.0))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1e-88)
tmp = y / (x * (x + 1.0));
else
tmp = x / (y * (y + 1.0));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1e-88], N[(y / N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{-88}:\\
\;\;\;\;\frac{y}{x \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\
\end{array}
\end{array}
if y < 9.99999999999999934e-89Initial program 72.3%
associate-/l*85.9%
associate-+l+85.9%
Simplified85.9%
Taylor expanded in y around 0 57.3%
if 9.99999999999999934e-89 < y Initial program 68.8%
associate-/l*81.8%
associate-+l+81.8%
Simplified81.8%
Taylor expanded in x around 0 67.8%
+-commutative67.8%
Simplified67.8%
Final simplification60.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1e-88) (/ y (* x (+ x 1.0))) (/ (/ x y) (+ y 1.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1e-88) {
tmp = y / (x * (x + 1.0));
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1d-88) then
tmp = y / (x * (x + 1.0d0))
else
tmp = (x / y) / (y + 1.0d0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1e-88) {
tmp = y / (x * (x + 1.0));
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1e-88: tmp = y / (x * (x + 1.0)) else: tmp = (x / y) / (y + 1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1e-88) tmp = Float64(y / Float64(x * Float64(x + 1.0))); else tmp = Float64(Float64(x / y) / Float64(y + 1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1e-88)
tmp = y / (x * (x + 1.0));
else
tmp = (x / y) / (y + 1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1e-88], N[(y / N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{-88}:\\
\;\;\;\;\frac{y}{x \cdot \left(x + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if y < 9.99999999999999934e-89Initial program 72.3%
associate-/l*85.9%
associate-+l+85.9%
Simplified85.9%
Taylor expanded in y around 0 57.3%
if 9.99999999999999934e-89 < y Initial program 68.8%
associate-/l*81.8%
associate-+l+81.8%
Simplified81.8%
Taylor expanded in x around 0 67.6%
+-commutative67.6%
div-inv67.8%
associate-/r*64.2%
Applied egg-rr64.2%
Final simplification59.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.1e-88) (/ (/ y x) (+ x 1.0)) (/ (/ x y) (+ y 1.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.1e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= 1.1d-88) then
tmp = (y / x) / (x + 1.0d0)
else
tmp = (x / y) / (y + 1.0d0)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 1.1e-88) {
tmp = (y / x) / (x + 1.0);
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.1e-88: tmp = (y / x) / (x + 1.0) else: tmp = (x / y) / (y + 1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.1e-88) tmp = Float64(Float64(y / x) / Float64(x + 1.0)); else tmp = Float64(Float64(x / y) / Float64(y + 1.0)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 1.1e-88)
tmp = (y / x) / (x + 1.0);
else
tmp = (x / y) / (y + 1.0);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[y, 1.1e-88], N[(N[(y / x), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.1 \cdot 10^{-88}:\\
\;\;\;\;\frac{\frac{y}{x}}{x + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if y < 1.10000000000000002e-88Initial program 72.3%
associate-/l*85.9%
associate-+l+85.9%
Simplified85.9%
Taylor expanded in y around 0 57.3%
associate-/r*60.0%
+-commutative60.0%
Simplified60.0%
if 1.10000000000000002e-88 < y Initial program 68.8%
associate-/l*81.8%
associate-+l+81.8%
Simplified81.8%
Taylor expanded in x around 0 67.6%
+-commutative67.6%
div-inv67.8%
associate-/r*64.2%
Applied egg-rr64.2%
Final simplification61.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= x -4.305e-172) (/ y x) (/ x y)))
assert(x < y);
double code(double x, double y) {
double tmp;
if (x <= -4.305e-172) {
tmp = y / x;
} else {
tmp = x / y;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-4.305d-172)) then
tmp = y / x
else
tmp = x / y
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (x <= -4.305e-172) {
tmp = y / x;
} else {
tmp = x / y;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if x <= -4.305e-172: tmp = y / x else: tmp = x / y return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (x <= -4.305e-172) tmp = Float64(y / x); else tmp = Float64(x / y); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (x <= -4.305e-172)
tmp = y / x;
else
tmp = x / y;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := If[LessEqual[x, -4.305e-172], N[(y / x), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.305 \cdot 10^{-172}:\\
\;\;\;\;\frac{y}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if x < -4.3049999999999998e-172Initial program 72.1%
associate-/l*88.9%
associate-+l+88.9%
Simplified88.9%
Taylor expanded in y around 0 66.2%
associate-/r*69.8%
+-commutative69.8%
Simplified69.8%
Taylor expanded in x around 0 36.4%
if -4.3049999999999998e-172 < x Initial program 70.8%
associate-/l*82.3%
associate-+l+82.3%
Simplified82.3%
Taylor expanded in x around 0 56.5%
+-commutative56.5%
Simplified56.5%
Taylor expanded in y around 0 33.6%
Final simplification34.6%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x y))
assert(x < y);
double code(double x, double y) {
return x / y;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / y
end function
assert x < y;
public static double code(double x, double y) {
return x / y;
}
[x, y] = sort([x, y]) def code(x, y): return x / y
x, y = sort([x, y]) function code(x, y) return Float64(x / y) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / y;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y}
\end{array}
Initial program 71.2%
associate-/l*84.6%
associate-+l+84.6%
Simplified84.6%
Taylor expanded in x around 0 48.5%
+-commutative48.5%
Simplified48.5%
Taylor expanded in y around 0 24.7%
Final simplification24.7%
(FPCore (x y) :precision binary64 (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x)))))
double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / ((y + 1.0d0) + x)) / (y + x)) / (1.0d0 / (y / (y + x)))
end function
public static double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
def code(x, y): return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)))
function code(x, y) return Float64(Float64(Float64(x / Float64(Float64(y + 1.0) + x)) / Float64(y + x)) / Float64(1.0 / Float64(y / Float64(y + x)))) end
function tmp = code(x, y) tmp = ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x))); end
code[x_, y_] := N[(N[(N[(x / N[(N[(y + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}}
\end{array}
herbie shell --seed 2024077
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
:alt
(/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))