Double sum over $leftlfloor{ac+bdover k}rightrfloor$
$begingroup$
We have
$$leftlfloor{ac+bdover k}rightrfloor-leftlfloor{ac+bd-1over k}rightrfloor=1-leftlceil{ (ac+bd)mod{k}over k}rightrceil$$
for $a,b,c,d,k$ - integers, $ageqslant0$, $bgeqslant0$, $c>0$, $d>0$, $k>0$. Next we want to calculate
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlfloor{ac+bdover k}rightrfloor$$
or
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlceil{(ac+bd)mod{k}over k}rightrceil$$
Is there a nice closed form for it?
summation closed-form floor-function ceiling-function
$endgroup$
add a comment |
$begingroup$
We have
$$leftlfloor{ac+bdover k}rightrfloor-leftlfloor{ac+bd-1over k}rightrfloor=1-leftlceil{ (ac+bd)mod{k}over k}rightrceil$$
for $a,b,c,d,k$ - integers, $ageqslant0$, $bgeqslant0$, $c>0$, $d>0$, $k>0$. Next we want to calculate
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlfloor{ac+bdover k}rightrfloor$$
or
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlceil{(ac+bd)mod{k}over k}rightrceil$$
Is there a nice closed form for it?
summation closed-form floor-function ceiling-function
$endgroup$
add a comment |
$begingroup$
We have
$$leftlfloor{ac+bdover k}rightrfloor-leftlfloor{ac+bd-1over k}rightrfloor=1-leftlceil{ (ac+bd)mod{k}over k}rightrceil$$
for $a,b,c,d,k$ - integers, $ageqslant0$, $bgeqslant0$, $c>0$, $d>0$, $k>0$. Next we want to calculate
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlfloor{ac+bdover k}rightrfloor$$
or
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlceil{(ac+bd)mod{k}over k}rightrceil$$
Is there a nice closed form for it?
summation closed-form floor-function ceiling-function
$endgroup$
We have
$$leftlfloor{ac+bdover k}rightrfloor-leftlfloor{ac+bd-1over k}rightrfloor=1-leftlceil{ (ac+bd)mod{k}over k}rightrceil$$
for $a,b,c,d,k$ - integers, $ageqslant0$, $bgeqslant0$, $c>0$, $d>0$, $k>0$. Next we want to calculate
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlfloor{ac+bdover k}rightrfloor$$
or
$$sumlimits_{a=0}^{n}sumlimits_{b=0}^{m}leftlceil{(ac+bd)mod{k}over k}rightrceil$$
Is there a nice closed form for it?
summation closed-form floor-function ceiling-function
summation closed-form floor-function ceiling-function
edited Jan 3 at 17:00
Key Flex
8,35261233
8,35261233
asked Jan 3 at 16:05
user514787user514787
749310
749310
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Here we give a closed form expression for a special case of the double sum indicating that there is no nice formula in the general case.
Let $N, M, c$ be positive integer with
begin{align*}
N=&cleftlfloorfrac{N}{c}rightrfloor+nqquad 0leq n<c\
M=&cleftlfloorfrac{M}{c}rightrfloor+mqquad 0leq m<c
end{align*}
then the following is valid
begin{align*}
sum_{k=0}^N&sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloortag{1}\
&=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor\
&quad+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor\
&quad+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2\
&quad+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)\
&quad+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloortag{2}
end{align*}
We observe the special case $leftlfloorfrac{ak+bl}{c}rightrfloor$ in (1) with $a=b=1$ results in a rather complex formula (2) indicating the general case is also rather complex.
In order to prove (2) we need some preliminary results, namely three types of single sums with floor functions given below.
Let $n,a,c$ be integer $ngeq 0, c>0, 0leq a <c$.
The following is valid
begin{align*}
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor
&=left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2tag{3}\
sum_{k=0}^n kleftlfloor frac{k+a}{c}rightrfloor
&=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3tag{4}\
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor^2
&=frac{c}{6}leftlfloorfrac{n+a}{c}rightrfloor+left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{2c}{3}leftlfloorfrac{n+a}{c}rightrfloor^3tag{5}
end{align*}
Ad (3):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{leftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]tag{6}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}1
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n 1\
&=csum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&=frac{c}{2}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&,,color{blue}{=left(n+a+1-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2}
end{align*}
and (3) follows.
Comment:
- In (6) we use Iverson brackets to get rid of the floor function.
Ad (4):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{kleftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}k
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n k\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jleft(frac{1}{2}left(c(j+1)-a-1right)(c(j+1)-a)-frac{1}{2}left(cj-a-1right)(cj-a)right)\
&qquad+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{1}{2}sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j(-2ac+2c^2j+c^2-c)
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=c^2sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j^2+left(frac{c^2-c}{2}-acright)sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{c^2}{6}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloorleft(2leftlfloorfrac{n+a}{c}rightrfloor-1right)\
&qquad+frac{c}{4}(c-1-2a)left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{1}{2}left(n(n+1)-left(cleftlfloorfrac{n+a}{c}rightrfloor-aright)left(cleftlfloorfrac{n+a}{c}rightrfloor-a-1right)right)leftlfloorfrac{n+a}{c}rightrfloor\
&,,color{blue}{=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor}\
&qquadcolor{blue}{+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3}
end{align*}
and (4) follows.
Ad (5):
The proof of this case is similar to (3) and is omitted.
The main formula (2):
The proof of formula (2) is really cumbersome and somewhat lengthy. Here I will show the first steps and everything else follows by consequently applying (3) to (5).
We obtain
begin{align*}
color{blue}{sum_{k=0}^N}&color{blue}{sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloor}\
&=sum_{k=0}^{cleftlfloorfrac{N}{c}rightrfloor+n} sum_{l=0}^{cleftlfloorfrac{M}{c}rightrfloor+m}leftlfloorfrac{k+l}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{ck_1+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
leftlfloorfrac{ck_1+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+l_1right)\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+l_1right)\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+leftlfloorfrac{M}{c}rightrfloorright)\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleft(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+c^2leftlfloorfrac{M}{c}rightrfloorsum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1
+c^2leftlfloorfrac{N}{c}rightrfloorsum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor
+(n+1)csum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
end{align*}
begin{align*}
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)
+c^2leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor+(n+1)cleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)leftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)tag{7}\
\
&=cdotstag{8}\
\
&,,color{blue}{=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor}\
&quadcolor{blue}{+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2}\
&quadcolor{blue}{+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)}\
&quadcolor{blue}{+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloor}
end{align*}
Note: I've checked the formula programmatically for small values of $M,N$ and $c$.
There are in fact some steps which are needed to fill in (8), since we have double sums in (7) which have to be substituted iteratively by (3) to (5). So, the steps up to (7) are rather the beginning of the main calculation.
$endgroup$
$begingroup$
Thank you very for such detail answer! Formulas are really amazing!
$endgroup$
– user514787
Feb 16 at 8:02
$begingroup$
@user514787: You're welcome. Probably the results of the three single sums will be sometimes useful. As you may have already noticed, I've added this question as addendum to my answer. Regards,
$endgroup$
– Markus Scheuer
Feb 16 at 10:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3060721%2fdouble-sum-over-left-lflooracbd-over-k-right-rfloor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Here we give a closed form expression for a special case of the double sum indicating that there is no nice formula in the general case.
Let $N, M, c$ be positive integer with
begin{align*}
N=&cleftlfloorfrac{N}{c}rightrfloor+nqquad 0leq n<c\
M=&cleftlfloorfrac{M}{c}rightrfloor+mqquad 0leq m<c
end{align*}
then the following is valid
begin{align*}
sum_{k=0}^N&sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloortag{1}\
&=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor\
&quad+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor\
&quad+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2\
&quad+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)\
&quad+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloortag{2}
end{align*}
We observe the special case $leftlfloorfrac{ak+bl}{c}rightrfloor$ in (1) with $a=b=1$ results in a rather complex formula (2) indicating the general case is also rather complex.
In order to prove (2) we need some preliminary results, namely three types of single sums with floor functions given below.
Let $n,a,c$ be integer $ngeq 0, c>0, 0leq a <c$.
The following is valid
begin{align*}
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor
&=left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2tag{3}\
sum_{k=0}^n kleftlfloor frac{k+a}{c}rightrfloor
&=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3tag{4}\
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor^2
&=frac{c}{6}leftlfloorfrac{n+a}{c}rightrfloor+left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{2c}{3}leftlfloorfrac{n+a}{c}rightrfloor^3tag{5}
end{align*}
Ad (3):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{leftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]tag{6}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}1
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n 1\
&=csum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&=frac{c}{2}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&,,color{blue}{=left(n+a+1-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2}
end{align*}
and (3) follows.
Comment:
- In (6) we use Iverson brackets to get rid of the floor function.
Ad (4):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{kleftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}k
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n k\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jleft(frac{1}{2}left(c(j+1)-a-1right)(c(j+1)-a)-frac{1}{2}left(cj-a-1right)(cj-a)right)\
&qquad+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{1}{2}sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j(-2ac+2c^2j+c^2-c)
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=c^2sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j^2+left(frac{c^2-c}{2}-acright)sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{c^2}{6}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloorleft(2leftlfloorfrac{n+a}{c}rightrfloor-1right)\
&qquad+frac{c}{4}(c-1-2a)left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{1}{2}left(n(n+1)-left(cleftlfloorfrac{n+a}{c}rightrfloor-aright)left(cleftlfloorfrac{n+a}{c}rightrfloor-a-1right)right)leftlfloorfrac{n+a}{c}rightrfloor\
&,,color{blue}{=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor}\
&qquadcolor{blue}{+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3}
end{align*}
and (4) follows.
Ad (5):
The proof of this case is similar to (3) and is omitted.
The main formula (2):
The proof of formula (2) is really cumbersome and somewhat lengthy. Here I will show the first steps and everything else follows by consequently applying (3) to (5).
We obtain
begin{align*}
color{blue}{sum_{k=0}^N}&color{blue}{sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloor}\
&=sum_{k=0}^{cleftlfloorfrac{N}{c}rightrfloor+n} sum_{l=0}^{cleftlfloorfrac{M}{c}rightrfloor+m}leftlfloorfrac{k+l}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{ck_1+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
leftlfloorfrac{ck_1+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+l_1right)\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+l_1right)\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+leftlfloorfrac{M}{c}rightrfloorright)\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleft(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+c^2leftlfloorfrac{M}{c}rightrfloorsum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1
+c^2leftlfloorfrac{N}{c}rightrfloorsum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor
+(n+1)csum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
end{align*}
begin{align*}
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)
+c^2leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor+(n+1)cleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)leftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)tag{7}\
\
&=cdotstag{8}\
\
&,,color{blue}{=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor}\
&quadcolor{blue}{+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2}\
&quadcolor{blue}{+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)}\
&quadcolor{blue}{+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloor}
end{align*}
Note: I've checked the formula programmatically for small values of $M,N$ and $c$.
There are in fact some steps which are needed to fill in (8), since we have double sums in (7) which have to be substituted iteratively by (3) to (5). So, the steps up to (7) are rather the beginning of the main calculation.
$endgroup$
$begingroup$
Thank you very for such detail answer! Formulas are really amazing!
$endgroup$
– user514787
Feb 16 at 8:02
$begingroup$
@user514787: You're welcome. Probably the results of the three single sums will be sometimes useful. As you may have already noticed, I've added this question as addendum to my answer. Regards,
$endgroup$
– Markus Scheuer
Feb 16 at 10:12
add a comment |
$begingroup$
Here we give a closed form expression for a special case of the double sum indicating that there is no nice formula in the general case.
Let $N, M, c$ be positive integer with
begin{align*}
N=&cleftlfloorfrac{N}{c}rightrfloor+nqquad 0leq n<c\
M=&cleftlfloorfrac{M}{c}rightrfloor+mqquad 0leq m<c
end{align*}
then the following is valid
begin{align*}
sum_{k=0}^N&sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloortag{1}\
&=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor\
&quad+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor\
&quad+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2\
&quad+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)\
&quad+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloortag{2}
end{align*}
We observe the special case $leftlfloorfrac{ak+bl}{c}rightrfloor$ in (1) with $a=b=1$ results in a rather complex formula (2) indicating the general case is also rather complex.
In order to prove (2) we need some preliminary results, namely three types of single sums with floor functions given below.
Let $n,a,c$ be integer $ngeq 0, c>0, 0leq a <c$.
The following is valid
begin{align*}
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor
&=left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2tag{3}\
sum_{k=0}^n kleftlfloor frac{k+a}{c}rightrfloor
&=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3tag{4}\
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor^2
&=frac{c}{6}leftlfloorfrac{n+a}{c}rightrfloor+left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{2c}{3}leftlfloorfrac{n+a}{c}rightrfloor^3tag{5}
end{align*}
Ad (3):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{leftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]tag{6}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}1
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n 1\
&=csum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&=frac{c}{2}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&,,color{blue}{=left(n+a+1-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2}
end{align*}
and (3) follows.
Comment:
- In (6) we use Iverson brackets to get rid of the floor function.
Ad (4):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{kleftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}k
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n k\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jleft(frac{1}{2}left(c(j+1)-a-1right)(c(j+1)-a)-frac{1}{2}left(cj-a-1right)(cj-a)right)\
&qquad+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{1}{2}sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j(-2ac+2c^2j+c^2-c)
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=c^2sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j^2+left(frac{c^2-c}{2}-acright)sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{c^2}{6}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloorleft(2leftlfloorfrac{n+a}{c}rightrfloor-1right)\
&qquad+frac{c}{4}(c-1-2a)left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{1}{2}left(n(n+1)-left(cleftlfloorfrac{n+a}{c}rightrfloor-aright)left(cleftlfloorfrac{n+a}{c}rightrfloor-a-1right)right)leftlfloorfrac{n+a}{c}rightrfloor\
&,,color{blue}{=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor}\
&qquadcolor{blue}{+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3}
end{align*}
and (4) follows.
Ad (5):
The proof of this case is similar to (3) and is omitted.
The main formula (2):
The proof of formula (2) is really cumbersome and somewhat lengthy. Here I will show the first steps and everything else follows by consequently applying (3) to (5).
We obtain
begin{align*}
color{blue}{sum_{k=0}^N}&color{blue}{sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloor}\
&=sum_{k=0}^{cleftlfloorfrac{N}{c}rightrfloor+n} sum_{l=0}^{cleftlfloorfrac{M}{c}rightrfloor+m}leftlfloorfrac{k+l}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{ck_1+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
leftlfloorfrac{ck_1+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+l_1right)\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+l_1right)\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+leftlfloorfrac{M}{c}rightrfloorright)\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleft(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+c^2leftlfloorfrac{M}{c}rightrfloorsum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1
+c^2leftlfloorfrac{N}{c}rightrfloorsum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor
+(n+1)csum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
end{align*}
begin{align*}
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)
+c^2leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor+(n+1)cleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)leftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)tag{7}\
\
&=cdotstag{8}\
\
&,,color{blue}{=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor}\
&quadcolor{blue}{+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2}\
&quadcolor{blue}{+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)}\
&quadcolor{blue}{+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloor}
end{align*}
Note: I've checked the formula programmatically for small values of $M,N$ and $c$.
There are in fact some steps which are needed to fill in (8), since we have double sums in (7) which have to be substituted iteratively by (3) to (5). So, the steps up to (7) are rather the beginning of the main calculation.
$endgroup$
$begingroup$
Thank you very for such detail answer! Formulas are really amazing!
$endgroup$
– user514787
Feb 16 at 8:02
$begingroup$
@user514787: You're welcome. Probably the results of the three single sums will be sometimes useful. As you may have already noticed, I've added this question as addendum to my answer. Regards,
$endgroup$
– Markus Scheuer
Feb 16 at 10:12
add a comment |
$begingroup$
Here we give a closed form expression for a special case of the double sum indicating that there is no nice formula in the general case.
Let $N, M, c$ be positive integer with
begin{align*}
N=&cleftlfloorfrac{N}{c}rightrfloor+nqquad 0leq n<c\
M=&cleftlfloorfrac{M}{c}rightrfloor+mqquad 0leq m<c
end{align*}
then the following is valid
begin{align*}
sum_{k=0}^N&sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloortag{1}\
&=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor\
&quad+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor\
&quad+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2\
&quad+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)\
&quad+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloortag{2}
end{align*}
We observe the special case $leftlfloorfrac{ak+bl}{c}rightrfloor$ in (1) with $a=b=1$ results in a rather complex formula (2) indicating the general case is also rather complex.
In order to prove (2) we need some preliminary results, namely three types of single sums with floor functions given below.
Let $n,a,c$ be integer $ngeq 0, c>0, 0leq a <c$.
The following is valid
begin{align*}
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor
&=left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2tag{3}\
sum_{k=0}^n kleftlfloor frac{k+a}{c}rightrfloor
&=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3tag{4}\
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor^2
&=frac{c}{6}leftlfloorfrac{n+a}{c}rightrfloor+left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{2c}{3}leftlfloorfrac{n+a}{c}rightrfloor^3tag{5}
end{align*}
Ad (3):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{leftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]tag{6}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}1
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n 1\
&=csum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&=frac{c}{2}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&,,color{blue}{=left(n+a+1-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2}
end{align*}
and (3) follows.
Comment:
- In (6) we use Iverson brackets to get rid of the floor function.
Ad (4):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{kleftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}k
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n k\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jleft(frac{1}{2}left(c(j+1)-a-1right)(c(j+1)-a)-frac{1}{2}left(cj-a-1right)(cj-a)right)\
&qquad+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{1}{2}sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j(-2ac+2c^2j+c^2-c)
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=c^2sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j^2+left(frac{c^2-c}{2}-acright)sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{c^2}{6}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloorleft(2leftlfloorfrac{n+a}{c}rightrfloor-1right)\
&qquad+frac{c}{4}(c-1-2a)left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{1}{2}left(n(n+1)-left(cleftlfloorfrac{n+a}{c}rightrfloor-aright)left(cleftlfloorfrac{n+a}{c}rightrfloor-a-1right)right)leftlfloorfrac{n+a}{c}rightrfloor\
&,,color{blue}{=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor}\
&qquadcolor{blue}{+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3}
end{align*}
and (4) follows.
Ad (5):
The proof of this case is similar to (3) and is omitted.
The main formula (2):
The proof of formula (2) is really cumbersome and somewhat lengthy. Here I will show the first steps and everything else follows by consequently applying (3) to (5).
We obtain
begin{align*}
color{blue}{sum_{k=0}^N}&color{blue}{sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloor}\
&=sum_{k=0}^{cleftlfloorfrac{N}{c}rightrfloor+n} sum_{l=0}^{cleftlfloorfrac{M}{c}rightrfloor+m}leftlfloorfrac{k+l}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{ck_1+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
leftlfloorfrac{ck_1+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+l_1right)\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+l_1right)\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+leftlfloorfrac{M}{c}rightrfloorright)\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleft(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+c^2leftlfloorfrac{M}{c}rightrfloorsum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1
+c^2leftlfloorfrac{N}{c}rightrfloorsum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor
+(n+1)csum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
end{align*}
begin{align*}
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)
+c^2leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor+(n+1)cleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)leftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)tag{7}\
\
&=cdotstag{8}\
\
&,,color{blue}{=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor}\
&quadcolor{blue}{+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2}\
&quadcolor{blue}{+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)}\
&quadcolor{blue}{+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloor}
end{align*}
Note: I've checked the formula programmatically for small values of $M,N$ and $c$.
There are in fact some steps which are needed to fill in (8), since we have double sums in (7) which have to be substituted iteratively by (3) to (5). So, the steps up to (7) are rather the beginning of the main calculation.
$endgroup$
Here we give a closed form expression for a special case of the double sum indicating that there is no nice formula in the general case.
Let $N, M, c$ be positive integer with
begin{align*}
N=&cleftlfloorfrac{N}{c}rightrfloor+nqquad 0leq n<c\
M=&cleftlfloorfrac{M}{c}rightrfloor+mqquad 0leq m<c
end{align*}
then the following is valid
begin{align*}
sum_{k=0}^N&sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloortag{1}\
&=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor\
&quad+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor\
&quad+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2\
&quad+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor\
&quad+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)\
&quad+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloortag{2}
end{align*}
We observe the special case $leftlfloorfrac{ak+bl}{c}rightrfloor$ in (1) with $a=b=1$ results in a rather complex formula (2) indicating the general case is also rather complex.
In order to prove (2) we need some preliminary results, namely three types of single sums with floor functions given below.
Let $n,a,c$ be integer $ngeq 0, c>0, 0leq a <c$.
The following is valid
begin{align*}
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor
&=left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2tag{3}\
sum_{k=0}^n kleftlfloor frac{k+a}{c}rightrfloor
&=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3tag{4}\
sum_{k=0}^nleftlfloorfrac{k+a}{c}rightrfloor^2
&=frac{c}{6}leftlfloorfrac{n+a}{c}rightrfloor+left(n+1+a-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{2c}{3}leftlfloorfrac{n+a}{c}rightrfloor^3tag{5}
end{align*}
Ad (3):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{leftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]tag{6}\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nsum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}1
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n 1\
&=csum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&=frac{c}{2}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor+leftlfloorfrac{n+a}{c}rightrfloorleft(n-cleftlfloorfrac{n+a}{c}rightrfloor+a+1right)\
&,,color{blue}{=left(n+a+1-frac{c}{2}right)leftlfloorfrac{n+a}{c}rightrfloor-frac{c}{2}leftlfloorfrac{n+a}{c}rightrfloor^2}
end{align*}
and (3) follows.
Comment:
- In (6) we use Iverson brackets to get rid of the floor function.
Ad (4):
Let $n,a,c$ integer $ngeq 0, c>0, 0leq a <c$. We obtain
begin{align*}
color{blue}{sum_{k=0}^n}&color{blue}{kleftlfloorfrac{k+a}{c}rightrfloor}\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[j=leftlfloorfrac{k+a}{c}rightrfloorright]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ jleq frac{k+a}{c} < j+1right]\
&=sum_{k=0}^nksum_{j=1}^{leftlfloorfrac{k+a}{c}rightrfloor} jleft[ cj-aleq k < c(j+1)-aright]\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jsum_{k=cj-a}^{c(j+1)-a-1}k
+leftlfloorfrac{n+a}{c}rightrfloorsum_{k=cleftlfloorfrac{n+a}{c}rightrfloor-a}^n k\
&=sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}jleft(frac{1}{2}left(c(j+1)-a-1right)(c(j+1)-a)-frac{1}{2}left(cj-a-1right)(cj-a)right)\
&qquad+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{1}{2}sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j(-2ac+2c^2j+c^2-c)
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=c^2sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j^2+left(frac{c^2-c}{2}-acright)sum_{j=1}^{leftlfloorfrac{n+a}{c}rightrfloor-1}j
+leftlfloorfrac{n+a}{c}rightrfloorleft(binom{n+1}{2}-binom{cleftlfloorfrac{n+a}{c}rightrfloor-a}{2}right)\
&=frac{c^2}{6}left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloorleft(2leftlfloorfrac{n+a}{c}rightrfloor-1right)\
&qquad+frac{c}{4}(c-1-2a)left(leftlfloorfrac{n+a}{c}rightrfloor-1right)leftlfloorfrac{n+a}{c}rightrfloor\
&qquad+frac{1}{2}left(n(n+1)-left(cleftlfloorfrac{n+a}{c}rightrfloor-aright)left(cleftlfloorfrac{n+a}{c}rightrfloor-a-1right)right)leftlfloorfrac{n+a}{c}rightrfloor\
&,,color{blue}{=frac{1}{12}left(6n(n+1)-6a^2+6a(c-1)-c^2+3cright)leftlfloorfrac{n+a}{c}rightrfloor}\
&qquadcolor{blue}{+frac{c}{4}(2a-c+1)leftlfloorfrac{n+a}{c}rightrfloor^2-frac{c^2}{6}leftlfloorfrac{n+a}{c}rightrfloor^3}
end{align*}
and (4) follows.
Ad (5):
The proof of this case is similar to (3) and is omitted.
The main formula (2):
The proof of formula (2) is really cumbersome and somewhat lengthy. Here I will show the first steps and everything else follows by consequently applying (3) to (5).
We obtain
begin{align*}
color{blue}{sum_{k=0}^N}&color{blue}{sum_{l=0}^Mleftlfloorfrac{k+l}{c}rightrfloor}\
&=sum_{k=0}^{cleftlfloorfrac{N}{c}rightrfloor+n} sum_{l=0}^{cleftlfloorfrac{M}{c}rightrfloor+m}leftlfloorfrac{k+l}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{ck_1+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
leftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cl_1+l_2}{c}rightrfloor\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
leftlfloorfrac{ck_1+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleftlfloorfrac{cleftlfloorfrac{N}{c}rightrfloor+k_2+cleftlfloorfrac{M}{c}rightrfloor+l_2}{c}rightrfloor\
&=sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+l_1right)\
&qquad+sum_{k_2=0}^n sum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1} sum_{l_2=0}^{c-1}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+l_1right)\
&qquad+sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1} sum_{k_2=0}^{c-1} sum_{l_2=0}^{m}
left(leftlfloorfrac{k_2+l_2}{c}rightrfloor+k_1+leftlfloorfrac{M}{c}rightrfloorright)\
&qquad+sum_{k_2=0}^nsum_{l2=0}^nleft(leftlfloorfrac{k_2+l_2}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+c^2leftlfloorfrac{M}{c}rightrfloorsum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1
+c^2leftlfloorfrac{N}{c}rightrfloorsum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor
+(n+1)csum_{l_1=0}^{leftlfloorfrac{M}{c}rightrfloor-1}l_1\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor
+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)sum_{k_1=0}^{leftlfloorfrac{N}{c}rightrfloor-1}k_1\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)\
end{align*}
begin{align*}
&=leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)
+c^2leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{M}{c}rightrfloorsum_{k_2=0}^nsum_{l_2=0}^{c-1}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+(n+1)leftlfloorfrac{M}{c}rightrfloor cleftlfloorfrac{N}{c}rightrfloor+(n+1)cleftlfloorfrac{M}{c}rightrfloorleft(leftlfloorfrac{M}{c}rightrfloor-1right)\
&qquad+leftlfloorfrac{N}{c}rightrfloorsum_{k_2=0}^{c-1}sum_{l_2=0}^{m}leftlfloorfrac{k_2+l_2}{c}rightrfloor\
&qquadqquad+leftlfloorfrac{N}{c}rightrfloor c (m+1)leftlfloorfrac{M}{c}rightrfloor
+c(m+1)leftlfloorfrac{N}{c}rightrfloorleft(leftlfloorfrac{N}{c}rightrfloor-1right)\
&qquad+sum_{k_2=0}^{n}sum_{l_2=0}^mleftlfloorfrac{k_2+l_2}{c}rightrfloor+(n+1)(m+1)left(leftlfloorfrac{N}{c}rightrfloor+leftlfloorfrac{M}{c}rightrfloorright)tag{7}\
\
&=cdotstag{8}\
\
&,,color{blue}{=-frac{1}{2}c(1-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{2c-2}{2}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}m(m+1)leftlfloorfrac{N}{c}rightrfloorleftlfloorfrac{c+m-1}{c}rightrfloor
+frac{1}{2}n(n+1)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{c+n-1}{c}rightrfloor}\
&quadcolor{blue}{+left(m+1-frac{c}{2}right)(n+1)leftlfloorfrac{M}{c}rightrfloor+left(n+1-frac{c}{2}right)(m+1)leftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}(n+1)cleftlfloorfrac{M}{c}rightrfloor^2+frac{1}{2}(m+1)cleftlfloorfrac{N}{c}rightrfloor^2}\
&quadcolor{blue}{+c(m+n+2-c)leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{N}{c}rightrfloor}\
&quadcolor{blue}{+frac{1}{2}c^2leftlfloorfrac{M}{c}rightrfloorleftlfloorfrac{M}{c}rightrfloor
left(leftlfloorfrac{M}{c}rightrfloor+leftlfloorfrac{N}{c}rightrfloorright)}\
&quadcolor{blue}{+left(frac{1}{2}((m+n)^2+3(m+n)+2)-left(m+n+frac{3}{2}right)c+frac{1}{2}c^2right)leftlfloorfrac{m+n}{c}rightrfloor}
end{align*}
Note: I've checked the formula programmatically for small values of $M,N$ and $c$.
There are in fact some steps which are needed to fill in (8), since we have double sums in (7) which have to be substituted iteratively by (3) to (5). So, the steps up to (7) are rather the beginning of the main calculation.
edited Feb 16 at 10:14
answered Feb 15 at 16:01
Markus ScheuerMarkus Scheuer
62.6k459149
62.6k459149
$begingroup$
Thank you very for such detail answer! Formulas are really amazing!
$endgroup$
– user514787
Feb 16 at 8:02
$begingroup$
@user514787: You're welcome. Probably the results of the three single sums will be sometimes useful. As you may have already noticed, I've added this question as addendum to my answer. Regards,
$endgroup$
– Markus Scheuer
Feb 16 at 10:12
add a comment |
$begingroup$
Thank you very for such detail answer! Formulas are really amazing!
$endgroup$
– user514787
Feb 16 at 8:02
$begingroup$
@user514787: You're welcome. Probably the results of the three single sums will be sometimes useful. As you may have already noticed, I've added this question as addendum to my answer. Regards,
$endgroup$
– Markus Scheuer
Feb 16 at 10:12
$begingroup$
Thank you very for such detail answer! Formulas are really amazing!
$endgroup$
– user514787
Feb 16 at 8:02
$begingroup$
Thank you very for such detail answer! Formulas are really amazing!
$endgroup$
– user514787
Feb 16 at 8:02
$begingroup$
@user514787: You're welcome. Probably the results of the three single sums will be sometimes useful. As you may have already noticed, I've added this question as addendum to my answer. Regards,
$endgroup$
– Markus Scheuer
Feb 16 at 10:12
$begingroup$
@user514787: You're welcome. Probably the results of the three single sums will be sometimes useful. As you may have already noticed, I've added this question as addendum to my answer. Regards,
$endgroup$
– Markus Scheuer
Feb 16 at 10:12
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3060721%2fdouble-sum-over-left-lflooracbd-over-k-right-rfloor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown