TITLE: Evaluation of finite sum
QUESTION [7 upvotes]: How can one prove the following equality (for fixed positive integer $a$):
$$12\sum_{k=1}^{an^2-1}k\left\{\frac{k(an-1)}{an^2}\right\}=3a^2n^4-a^2n^2-2$$
where $\{x\}=x-\lfloor x\rfloor$ denotes the fractional part operator.

REPLY [5 votes]: The Dedekind sum $s(t,u)$ can be defined by $$s(t,u)=\sum_{k=1}^{u-1}{k\over u}\left(\left\{{kt\over u}\right\}-{1\over2}\right)$$ for relatively prime integers $t,u$, where $\{x\}$ denotes the fractional part of $x$. We have $$s(t,u)=-{1\over2u}\sum k+{1\over u}\sum k\left\{{kt\over u}\right\}$$ so if we can evaluate $s(an-1,an^2)$ then we can evaluate $\displaystyle\sum_1^{u-1}k\left\{{(an-1)k\over an^2}\right\}$ 
The Dedekind sum satisfies these formulas (and many more): 

$s(t,u)=s(t',u)$ if $t\equiv t'\pmod u$
$\displaystyle s(1,u)=-{1\over4}+{1\over6u}+{u\over12}$
$s(-t,u)=-s(t,u)$ 
$\displaystyle s(t,u)+s(u,t)=-{1\over4}+{1\over12}\left({t\over u}+{1\over tu}+{u\over t}\right)$ 

The last of these is called the reciprocity formula for the Dedekind sum, and is considerably harder to establish than the others. 
Reciprocity lets us express $s(an-1,an^2)$ in terms of $s(an^2,an-1)$. 
Then the first formula implies $s(an^2,an-1)=s(n,an-1)$. 
Then reciprocity gives us $s(n,an-1)$ in terms of $s(an-1,n)$. 
Then from the 1st and 3rd formulas we have $s(an-1,n)=s(-1,n)=-s(1,n)$, and the 2nd formula completes the evaluation.