I am looking to evaluate the sum $$\sum_{1\leq k\leq mn}\left\{ \frac{k}{m}\right\} \left\{ \frac{k}{n}\right\} .$$
Using matlab, and experimenting around, it seems to be $\frac{(m-1)(n-1)}{4}$ when $m,n$ are relatively prime. How can we prove this, and what about the case where they are not relatively prime?
Conjecture: Numerically, it seems that for any $m,n$ we have $$\sum_{1\leq k\leq mn}\left\{ \frac{k}{m}\right\} \left\{ \frac{k}{n}\right\} =\frac{(m-1)(n-1)}{4}+C(\gcd(m,n))$$ where $C(\gcd(m,n))$ is some constant depending only on the $\gcd(m,n)$.
Additionally: Can we sum this even when it is not a complete interval? Suppose that $0<a<b<mn,$ do we have an exact form for $$\sum_{a\leq k\leq b}\left\{ \frac{k}{m}\right\} \left\{ \frac{k}{n}\right\}.$$
Remark: In the one variable case we have $$\sum_{1\leq k\leq n}\left\{ \frac{k}{n}\right\} =\frac{n-1}{2}$$ the sum over an interval $a,b$ has an explicit form.
Let's call your sum $f(m,n)$. The ordinary generating function of $f(\cdot,n)$ appears to be of the form $$g(z,n) = \frac{z^2 p_n(z)}{6 (1-z)(1-z^n)}$$ where $p_n$ is a polynomial of degree $n-1$ (except for $n=2$ where it has degree $0$): $$\eqalign{ p_{{2}}&=3\cr p_{{3}}&=-{z}^{2}+7\,z+3\cr p_{{4}}&=-3\,{z}^{3}+12\,{z}^{2}+3\,z+6\cr p_{{5}}&=-6\,{z}^{4}+18\,{z}^{3}+6\,{z}^{2}+6\,z+6\cr p_{{6}}&=-10\,{z}^{5}+25\,{z}^{4}+6\,{z}^{3}+5\,{z}^{2}+10\,z+9\cr p_{{7}}&=-15\,{z}^{6}+33\,{z}^{5}+9\,{z}^{4}+9\,{z}^{3}+9\,{z}^{2}+9\,z +9\cr p_{{8}}&=-21\,{z}^{7}+42\,{z}^{6}+9\,{z}^{5}+12\,{z}^{4}+3\,{z}^{3}+18 \,{z}^{2}+9\,z+12\cr p_{{9}}&=-28\,{z}^{8}+52\,{z}^{7}+12\,{z}^{6}+8\,{z}^{5}+16\,{z}^{4}+12 \,{z}^{3}+8\,{z}^{2}+16\,z+12\cr p_{{10}}&=-36\,{z}^{9}+63\,{z}^{8}+12\,{z}^{7}+15\,{z}^{6}+12\,{z}^{5}+ 3\,{z}^{4}+24\,{z}^{3}+15\,{z}^{2}+12\,z+15\cr p_{{11}}&=-45\,{z}^{10}+75\,{z}^{9}+15\,{z}^{8}+15\,{z}^{7}+15\,{z}^{6} +15\,{z}^{5}+15\,{z}^{4}+15\,{z}^{3}+15\,{z}^{2}+15\,z+15\cr p_{{12}}&=-55\,{z}^{11}+88\,{z}^{10}+15\,{z}^{9}+14\,{z}^{8}+13\,{z}^{7 }+24\,{z}^{6}-{z}^{5}+34\,{z}^{4}+9\,{z}^{3}+20\,{z}^{2}+19\,z+18\cr}$$
EDIT: This seems to come from the fact that $$f(m+n,n) - f(m,n) =\frac{n^2-n}{4}$$ for all $m$ and $n$.
EDIT: Let $g(m,n) = f(m,n) - \dfrac{(m-1)(n-1)}{4}$. From $f(m+n,n) - f(m,n) = \dfrac{n^2-n}{4}$ we get $g(m+n,n) = g(m,n)$. By following the Euclidean algorithm, we get $$g(m,n) = g(d,d) = \dfrac{(d-1)(2d-1)}{6} - \dfrac{(d-1)^2}{4} = \frac{d^2-1}{12}$$ where $d = \gcd(m,n)$. That is, $$ f(m,n) = \frac{\gcd(m,n)^2-1}{12} + \dfrac{(m-1)(n-1)}{4} $$