
(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 14 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 (+ 1.0 (+ y x))) (+ y x)) (/ (+ y x) x)))
assert(x < y);
double code(double x, double y) {
return ((y / (1.0 + (y + x))) / (y + x)) / ((y + x) / x);
}
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 / (1.0d0 + (y + x))) / (y + x)) / ((y + x) / x)
end function
assert x < y;
public static double code(double x, double y) {
return ((y / (1.0 + (y + x))) / (y + x)) / ((y + x) / x);
}
[x, y] = sort([x, y]) def code(x, y): return ((y / (1.0 + (y + x))) / (y + x)) / ((y + x) / x)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(Float64(y / Float64(1.0 + Float64(y + x))) / Float64(y + x)) / Float64(Float64(y + x) / x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = ((y / (1.0 + (y + x))) / (y + x)) / ((y + x) / x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(N[(y / N[(1.0 + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(N[(y + x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{\frac{y}{1 + \left(y + x\right)}}{y + x}}{\frac{y + x}{x}}
\end{array}
Initial program 64.3%
associate-*l*64.3%
times-frac91.8%
+-commutative91.8%
+-commutative91.8%
associate-+r+91.8%
+-commutative91.8%
associate-+l+91.8%
Applied egg-rr91.8%
clear-num91.7%
associate-/r*99.7%
frac-times99.0%
*-un-lft-identity99.0%
+-commutative99.0%
Applied egg-rr99.0%
div-inv98.9%
*-commutative98.9%
times-frac99.7%
Applied egg-rr99.7%
associate-*r/99.7%
un-div-inv99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
Applied egg-rr99.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 6.2e+144) (* (/ x (+ y x)) (/ y (* (+ y x) (+ y (+ 1.0 x))))) (/ (/ x (* (+ y x) (/ (+ y 1.0) y))) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 6.2e+144) {
tmp = (x / (y + x)) * (y / ((y + x) * (y + (1.0 + x))));
} else {
tmp = (x / ((y + x) * ((y + 1.0) / y))) / (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 <= 6.2d+144) then
tmp = (x / (y + x)) * (y / ((y + x) * (y + (1.0d0 + x))))
else
tmp = (x / ((y + x) * ((y + 1.0d0) / y))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 6.2e+144) {
tmp = (x / (y + x)) * (y / ((y + x) * (y + (1.0 + x))));
} else {
tmp = (x / ((y + x) * ((y + 1.0) / y))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 6.2e+144: tmp = (x / (y + x)) * (y / ((y + x) * (y + (1.0 + x)))) else: tmp = (x / ((y + x) * ((y + 1.0) / y))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 6.2e+144) tmp = Float64(Float64(x / Float64(y + x)) * Float64(y / Float64(Float64(y + x) * Float64(y + Float64(1.0 + x))))); else tmp = Float64(Float64(x / Float64(Float64(y + x) * Float64(Float64(y + 1.0) / y))) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 6.2e+144)
tmp = (x / (y + x)) * (y / ((y + x) * (y + (1.0 + x))));
else
tmp = (x / ((y + x) * ((y + 1.0) / y))) / (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, 6.2e+144], N[(N[(x / N[(y + x), $MachinePrecision]), $MachinePrecision] * N[(y / N[(N[(y + x), $MachinePrecision] * N[(y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+144}:\\
\;\;\;\;\frac{x}{y + x} \cdot \frac{y}{\left(y + x\right) \cdot \left(y + \left(1 + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\left(y + x\right) \cdot \frac{y + 1}{y}}}{y + x}\\
\end{array}
\end{array}
if y < 6.2000000000000003e144Initial program 67.2%
associate-*l*67.2%
times-frac95.3%
+-commutative95.3%
+-commutative95.3%
associate-+r+95.3%
+-commutative95.3%
associate-+l+95.3%
Applied egg-rr95.3%
if 6.2000000000000003e144 < y Initial program 48.8%
associate-*l*48.8%
times-frac72.6%
+-commutative72.6%
+-commutative72.6%
associate-+r+72.6%
+-commutative72.6%
associate-+l+72.6%
Applied egg-rr72.6%
associate-*l/72.6%
clear-num72.6%
un-div-inv72.6%
*-un-lft-identity72.6%
times-frac99.8%
/-rgt-identity99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 87.7%
+-commutative87.7%
Simplified87.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.4e-8) (/ (/ x (* (+ y x) (/ (+ 1.0 x) y))) (+ y x)) (/ (/ x (* (+ y x) (/ (+ y 1.0) y))) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.4e-8) {
tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x);
} else {
tmp = (x / ((y + x) * ((y + 1.0) / y))) / (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 <= 5.4d-8) then
tmp = (x / ((y + x) * ((1.0d0 + x) / y))) / (y + x)
else
tmp = (x / ((y + x) * ((y + 1.0d0) / y))) / (y + x)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y) {
double tmp;
if (y <= 5.4e-8) {
tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x);
} else {
tmp = (x / ((y + x) * ((y + 1.0) / y))) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.4e-8: tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x) else: tmp = (x / ((y + x) * ((y + 1.0) / y))) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.4e-8) tmp = Float64(Float64(x / Float64(Float64(y + x) * Float64(Float64(1.0 + x) / y))) / Float64(y + x)); else tmp = Float64(Float64(x / Float64(Float64(y + x) * Float64(Float64(y + 1.0) / y))) / Float64(y + x)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y)
tmp = 0.0;
if (y <= 5.4e-8)
tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x);
else
tmp = (x / ((y + x) * ((y + 1.0) / y))) / (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, 5.4e-8], N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{x}{\left(y + x\right) \cdot \frac{1 + x}{y}}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\left(y + x\right) \cdot \frac{y + 1}{y}}}{y + x}\\
\end{array}
\end{array}
if y < 5.40000000000000005e-8Initial program 66.8%
associate-*l*66.8%
times-frac96.1%
+-commutative96.1%
+-commutative96.1%
associate-+r+96.1%
+-commutative96.1%
associate-+l+96.1%
Applied egg-rr96.1%
associate-*l/96.1%
clear-num96.0%
un-div-inv95.9%
*-un-lft-identity95.9%
times-frac99.6%
/-rgt-identity99.6%
+-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 80.6%
+-commutative80.6%
Simplified80.6%
if 5.40000000000000005e-8 < y Initial program 57.0%
associate-*l*57.0%
times-frac79.1%
+-commutative79.1%
+-commutative79.1%
associate-+r+79.1%
+-commutative79.1%
associate-+l+79.1%
Applied egg-rr79.1%
associate-*l/79.1%
clear-num79.1%
un-div-inv79.2%
*-un-lft-identity79.2%
times-frac98.7%
/-rgt-identity98.7%
+-commutative98.7%
Applied egg-rr98.7%
Taylor expanded in x around 0 81.3%
+-commutative81.3%
Simplified81.3%
Final simplification80.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 5.2e-8) (/ (/ x (* (+ y x) (/ (+ 1.0 x) y))) (+ y x)) (/ (/ x (+ y 1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 5.2e-8) {
tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x);
} 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 <= 5.2d-8) then
tmp = (x / ((y + x) * ((1.0d0 + x) / y))) / (y + x)
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 <= 5.2e-8) {
tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x);
} else {
tmp = (x / (y + 1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 5.2e-8: tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x) else: tmp = (x / (y + 1.0)) / (y + x) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 5.2e-8) tmp = Float64(Float64(x / Float64(Float64(y + x) * Float64(Float64(1.0 + x) / y))) / Float64(y + x)); 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 <= 5.2e-8)
tmp = (x / ((y + x) * ((1.0 + x) / y))) / (y + x);
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, 5.2e-8], N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(N[(1.0 + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $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 5.2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{x}{\left(y + x\right) \cdot \frac{1 + x}{y}}}{y + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + 1}}{y + x}\\
\end{array}
\end{array}
if y < 5.2000000000000002e-8Initial program 66.8%
associate-*l*66.8%
times-frac96.1%
+-commutative96.1%
+-commutative96.1%
associate-+r+96.1%
+-commutative96.1%
associate-+l+96.1%
Applied egg-rr96.1%
associate-*l/96.1%
clear-num96.0%
un-div-inv95.9%
*-un-lft-identity95.9%
times-frac99.6%
/-rgt-identity99.6%
+-commutative99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 80.6%
+-commutative80.6%
Simplified80.6%
if 5.2000000000000002e-8 < y Initial program 57.0%
associate-*l*57.0%
times-frac79.1%
+-commutative79.1%
+-commutative79.1%
associate-+r+79.1%
+-commutative79.1%
associate-+l+79.1%
Applied egg-rr79.1%
associate-*l/79.1%
clear-num79.1%
un-div-inv79.2%
*-un-lft-identity79.2%
times-frac98.7%
/-rgt-identity98.7%
+-commutative98.7%
Applied egg-rr98.7%
Taylor expanded in x around 0 81.0%
+-commutative81.0%
Simplified81.0%
Final simplification80.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (/ y (+ y x)) (* (/ (+ y x) x) (+ y (+ 1.0 x)))))
assert(x < y);
double code(double x, double y) {
return (y / (y + x)) / (((y + x) / x) * (y + (1.0 + x)));
}
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)) / (((y + x) / x) * (y + (1.0d0 + x)))
end function
assert x < y;
public static double code(double x, double y) {
return (y / (y + x)) / (((y + x) / x) * (y + (1.0 + x)));
}
[x, y] = sort([x, y]) def code(x, y): return (y / (y + x)) / (((y + x) / x) * (y + (1.0 + x)))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(y / Float64(y + x)) / Float64(Float64(Float64(y + x) / x) * Float64(y + Float64(1.0 + x)))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (y / (y + x)) / (((y + x) / x) * (y + (1.0 + x)));
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[(N[(y + x), $MachinePrecision] / x), $MachinePrecision] * N[(y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{y}{y + x}}{\frac{y + x}{x} \cdot \left(y + \left(1 + x\right)\right)}
\end{array}
Initial program 64.3%
associate-*l*64.3%
times-frac91.8%
+-commutative91.8%
+-commutative91.8%
associate-+r+91.8%
+-commutative91.8%
associate-+l+91.8%
Applied egg-rr91.8%
clear-num91.7%
associate-/r*99.7%
frac-times99.0%
*-un-lft-identity99.0%
+-commutative99.0%
Applied egg-rr99.0%
Final simplification99.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (/ x (* (+ y x) (/ (+ y (+ 1.0 x)) y))) (+ y x)))
assert(x < y);
double code(double x, double y) {
return (x / ((y + x) * ((y + (1.0 + x)) / y))) / (y + x);
}
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 + x) * ((y + (1.0d0 + x)) / y))) / (y + x)
end function
assert x < y;
public static double code(double x, double y) {
return (x / ((y + x) * ((y + (1.0 + x)) / y))) / (y + x);
}
[x, y] = sort([x, y]) def code(x, y): return (x / ((y + x) * ((y + (1.0 + x)) / y))) / (y + x)
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(Float64(y + x) * Float64(Float64(y + Float64(1.0 + x)) / y))) / Float64(y + x)) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / ((y + x) * ((y + (1.0 + x)) / y))) / (y + x);
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(x / N[(N[(y + x), $MachinePrecision] * N[(N[(y + N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{\frac{x}{\left(y + x\right) \cdot \frac{y + \left(1 + x\right)}{y}}}{y + x}
\end{array}
Initial program 64.3%
associate-*l*64.3%
times-frac91.8%
+-commutative91.8%
+-commutative91.8%
associate-+r+91.8%
+-commutative91.8%
associate-+l+91.8%
Applied egg-rr91.8%
associate-*l/91.8%
clear-num91.7%
un-div-inv91.7%
*-un-lft-identity91.7%
times-frac99.3%
/-rgt-identity99.3%
+-commutative99.3%
Applied egg-rr99.3%
Final simplification99.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.55e-140) (/ (/ y x) (+ 1.0 x)) (/ (/ x (+ y 1.0)) (+ y x))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.55e-140) {
tmp = (y / x) / (1.0 + x);
} 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.55d-140) then
tmp = (y / x) / (1.0d0 + x)
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.55e-140) {
tmp = (y / x) / (1.0 + x);
} else {
tmp = (x / (y + 1.0)) / (y + x);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.55e-140: tmp = (y / x) / (1.0 + x) 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.55e-140) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); 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.55e-140)
tmp = (y / x) / (1.0 + x);
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.55e-140], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $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.55 \cdot 10^{-140}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y + 1}}{y + x}\\
\end{array}
\end{array}
if y < 1.55e-140Initial program 64.3%
associate-/l*78.2%
associate-+l+78.2%
Simplified78.2%
Taylor expanded in y around 0 59.1%
associate-/r*56.7%
+-commutative56.7%
Simplified56.7%
if 1.55e-140 < y Initial program 64.4%
associate-*l*64.4%
times-frac85.2%
+-commutative85.2%
+-commutative85.2%
associate-+r+85.2%
+-commutative85.2%
associate-+l+85.2%
Applied egg-rr85.2%
associate-*l/85.2%
clear-num85.2%
un-div-inv85.2%
*-un-lft-identity85.2%
times-frac98.9%
/-rgt-identity98.9%
+-commutative98.9%
Applied egg-rr98.9%
Taylor expanded in x around 0 67.8%
+-commutative67.8%
Simplified67.8%
Final simplification60.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.55e-140) (/ (/ y x) (+ 1.0 x)) (/ (/ x y) (+ y 1.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.55e-140) {
tmp = (y / x) / (1.0 + 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 <= 1.55d-140) then
tmp = (y / x) / (1.0d0 + 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 <= 1.55e-140) {
tmp = (y / x) / (1.0 + x);
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.55e-140: tmp = (y / x) / (1.0 + x) else: tmp = (x / y) / (y + 1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.55e-140) tmp = Float64(Float64(y / x) / Float64(1.0 + x)); 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.55e-140)
tmp = (y / x) / (1.0 + 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, 1.55e-140], N[(N[(y / x), $MachinePrecision] / N[(1.0 + x), $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.55 \cdot 10^{-140}:\\
\;\;\;\;\frac{\frac{y}{x}}{1 + x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if y < 1.55e-140Initial program 64.3%
associate-/l*78.2%
associate-+l+78.2%
Simplified78.2%
Taylor expanded in y around 0 59.1%
associate-/r*56.7%
+-commutative56.7%
Simplified56.7%
if 1.55e-140 < y Initial program 64.4%
associate-/l*79.1%
associate-+l+79.1%
Simplified79.1%
Taylor expanded in x around 0 61.1%
associate-/r*61.1%
+-commutative61.1%
Simplified61.1%
associate-*r/67.2%
div-inv67.3%
Applied egg-rr67.3%
Final simplification60.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.4e-140) (/ y (* x (+ 1.0 x))) (/ (/ x y) (+ y 1.0))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.4e-140) {
tmp = y / (x * (1.0 + 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 <= 1.4d-140) then
tmp = y / (x * (1.0d0 + 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 <= 1.4e-140) {
tmp = y / (x * (1.0 + x));
} else {
tmp = (x / y) / (y + 1.0);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.4e-140: tmp = y / (x * (1.0 + x)) else: tmp = (x / y) / (y + 1.0) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.4e-140) tmp = Float64(y / Float64(x * Float64(1.0 + x))); 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.4e-140)
tmp = y / (x * (1.0 + 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, 1.4e-140], N[(y / N[(x * N[(1.0 + x), $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 1.4 \cdot 10^{-140}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y + 1}\\
\end{array}
\end{array}
if y < 1.4000000000000001e-140Initial program 64.3%
associate-/l*78.2%
associate-+l+78.2%
Simplified78.2%
Taylor expanded in y around 0 59.1%
if 1.4000000000000001e-140 < y Initial program 64.4%
associate-/l*79.1%
associate-+l+79.1%
Simplified79.1%
Taylor expanded in x around 0 61.1%
associate-/r*61.1%
+-commutative61.1%
Simplified61.1%
associate-*r/67.2%
div-inv67.3%
Applied egg-rr67.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (if (<= y 1.55e-140) (/ y (* x (+ 1.0 x))) (/ x (* y (+ y 1.0)))))
assert(x < y);
double code(double x, double y) {
double tmp;
if (y <= 1.55e-140) {
tmp = y / (x * (1.0 + 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 <= 1.55d-140) then
tmp = y / (x * (1.0d0 + 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 <= 1.55e-140) {
tmp = y / (x * (1.0 + x));
} else {
tmp = x / (y * (y + 1.0));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y): tmp = 0 if y <= 1.55e-140: tmp = y / (x * (1.0 + x)) else: tmp = x / (y * (y + 1.0)) return tmp
x, y = sort([x, y]) function code(x, y) tmp = 0.0 if (y <= 1.55e-140) tmp = Float64(y / Float64(x * Float64(1.0 + 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 <= 1.55e-140)
tmp = y / (x * (1.0 + 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, 1.55e-140], N[(y / N[(x * N[(1.0 + x), $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 1.55 \cdot 10^{-140}:\\
\;\;\;\;\frac{y}{x \cdot \left(1 + x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \left(y + 1\right)}\\
\end{array}
\end{array}
if y < 1.55e-140Initial program 64.3%
associate-/l*78.2%
associate-+l+78.2%
Simplified78.2%
Taylor expanded in y around 0 59.1%
if 1.55e-140 < y Initial program 64.4%
associate-/l*79.1%
associate-+l+79.1%
Simplified79.1%
Taylor expanded in x around 0 61.0%
+-commutative61.0%
Simplified61.0%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ x (* y (+ y 1.0))))
assert(x < y);
double code(double x, double y) {
return x / (y * (y + 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 = x / (y * (y + 1.0d0))
end function
assert x < y;
public static double code(double x, double y) {
return x / (y * (y + 1.0));
}
[x, y] = sort([x, y]) def code(x, y): return x / (y * (y + 1.0))
x, y = sort([x, y]) function code(x, y) return Float64(x / Float64(y * Float64(y + 1.0))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = x / (y * (y + 1.0));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(x / N[(y * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{y \cdot \left(y + 1\right)}
\end{array}
Initial program 64.3%
associate-/l*78.5%
associate-+l+78.5%
Simplified78.5%
Taylor expanded in x around 0 49.4%
+-commutative49.4%
Simplified49.4%
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 64.3%
associate-/l*78.5%
associate-+l+78.5%
Simplified78.5%
Taylor expanded in x around 0 49.4%
+-commutative49.4%
Simplified49.4%
Taylor expanded in y around 0 24.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ 1.0 x))
assert(x < y);
double code(double x, double y) {
return 1.0 / x;
}
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 = 1.0d0 / x
end function
assert x < y;
public static double code(double x, double y) {
return 1.0 / x;
}
[x, y] = sort([x, y]) def code(x, y): return 1.0 / x
x, y = sort([x, y]) function code(x, y) return Float64(1.0 / x) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = 1.0 / x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(1.0 / x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{1}{x}
\end{array}
Initial program 64.3%
*-un-lft-identity64.3%
associate-*l*64.3%
times-frac68.6%
+-commutative68.6%
*-commutative68.6%
+-commutative68.6%
associate-+r+68.6%
+-commutative68.6%
associate-+l+68.6%
Applied egg-rr68.6%
Taylor expanded in x around inf 36.4%
Taylor expanded in y around inf 4.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 1.0)
assert(x < y);
double code(double x, double y) {
return 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 = 1.0d0
end function
assert x < y;
public static double code(double x, double y) {
return 1.0;
}
[x, y] = sort([x, y]) def code(x, y): return 1.0
x, y = sort([x, y]) function code(x, y) return 1.0 end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = 1.0;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := 1.0
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
1
\end{array}
Initial program 64.3%
associate-*l*64.3%
times-frac91.8%
+-commutative91.8%
+-commutative91.8%
associate-+r+91.8%
+-commutative91.8%
associate-+l+91.8%
Applied egg-rr91.8%
clear-num91.7%
associate-/r*99.7%
frac-times99.0%
*-un-lft-identity99.0%
+-commutative99.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 49.2%
+-commutative49.2%
Simplified49.2%
Taylor expanded in x around 0 3.5%
(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 2024119
(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))))