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!