Is there any way to compute/express $\sum\limits^m\_{i=0}\{\frac{q\*i}{m}\}(\frac{i}{m})^n$ ? Here $q,m,n$ are natural numbers, one can assume $gcd(q,m)=1$. Furthermore, $n$ can be treated as a parameter, i.e. I will be quite happy to know the formula for each particular $n$. At least for say $0<n<5$.


Maybe in this general case no good answer is possible, but I hope that the following combination behaves better:  

$\sum\limits^{m\_1}\_{i=0}\{\frac{-m\_2\*i}{m\_1}\}(\frac{i}{m\_1})^n-\sum\limits^{m\_2}\_{i=0}\{\frac{m\_1\*i}{m\_2}\}(\frac{i}{m\_2})^n$. 


(with the convention $\{-x\}=\{1-x\}$)


In fact I'm interested in this later combination. By interpolation I've guessed the following answers:


for $n=1$ the sum is: $\frac{3+3(m\_1-m\_2)-\frac{1}{m\_1m\_2}-\frac{m\_1}{m\_2}-\frac{m\_2}{m\_1}}{12}$.


for $n=2$ the sum is: $\frac{3+2(m\_1-m\_2)-\frac{1}{m\_1m\_2}-\frac{m\_1}{m\_2}-\frac{m\_2}{m\_1}+\frac{1}{m\_1}-\frac{1}{m\_2}}{12}$.


(Here I assume $gcd(m\_1,m\_2)=1$, otherwise one has a simple correction term. I do not know any analytic proof, just that numerically these formulas give the correct answer.)


This looks quite promising, but already for $n=3$ I could not guess the answer. Though I hope that for every $n$ the expression can be written as a rational function of $m\_1,m\_2$ plus some $gcd(m\_1,m\_2)$ correction.


Any advice is welcome!



the sum of fractional parts times the ordinary powers
As Gerry already commented, your formulas are equivalent to a reciprocity theorem of Tom Apostol; see, e.g., the bibliography in [this paper](https://arxiv.org/abs/1008.0038) (Apostol's paper is too old to be on the arXiv): Your sums are of the form $s\_n(a,b) + s\_n(b,a)$ where
$$
 s\_n(a,b) = \sum\_{m=1}^b \left\{\frac{ma}b\right\} \left\{\frac m b\right\}^n
$$
where $\{x\}$ is the fractional part function. Note that $s\_n(a,b) = \sum\_{m=1}^b \{\frac mb\} \{\frac{ma^{-1}}b\}^n$ where $a^{-1}$ is the inverse of $a$ mod $b$, whence $s\_n(a,b)$ is a sum of Dedekind-Apostol sums, which are of the form
$$
 \sum\_{m=1}^b \left\{\frac mb\right\} B\_n\left(\left\{\frac{ma}b\right\}\right)
$$
where $B\_n(x)$ is the $n$th Bernoulli polynomial.


