Integral of following fractional part How would I evaluate this integral, where $n\in R$ and $\{\,.\}$ is the fractional part?
$$\int_{-4}^4\{nx\}\,dx$$
I want to use it in one of problems of the ellipse. Thanks. I haven't shown any effort as I got no good step towards the solution. 
 A: Let's start. $$\begin{aligned}\int_{-4}^4\{nx\}\,dx&=\left[\begin{matrix}t=n x\\dx=\frac{dt}n\end{matrix}\right]=\int_{-4n}^{4n}\frac{\{t\}}n\,dt=\frac1n\int_{-4n}^{4n}\{t\}\,dt=\frac1n\int_{-4n}^{4n}\left(t-\lfloor t\rfloor\right)\,dt=\\
&=\frac1n\left(\int_{-4n}^{4n}t~dt-\int_{-4n}^{4n}\lfloor t\rfloor~dt\right)=-\frac1n\int_{-4n}^{4n}\lfloor t\rfloor~dt=I\end{aligned}$$
Denote $N=\lfloor 4n\rfloor$. Then $$\lfloor -4n\rfloor=\begin{cases}-N, & 4n\in\mathbb{Z} & (1)\\-N-1, & 4n\in\mathbb{R}\setminus\mathbb{Z} & (2)\end{cases}$$ 
When $4n\in\mathbb{Z}$ $$\begin{aligned}I^{(1)}&=-\frac1n\int_{-4n}^{4n}\lfloor t\rfloor~dt=-\frac1n\sum_{k=-N}^{N-1}\int_k^{k+1}\lfloor t\rfloor~dt=-\frac1n\sum_{k=-N}^{N-1}\int_k^{k+1}k~dt=-\frac1n\sum_{k=-N}^{N-1}k~dt=\\
&=-\frac1n(-N)=\frac{N}n=\frac{\lfloor 4n\rfloor}{n}=\left[4n\in\mathbb{Z},\lfloor 4n\rfloor=4n\right]=\frac{4n}n=4\end{aligned}$$
When $4n\in\mathbb{R}\setminus\mathbb{Z}$ $$\begin{aligned}I^{(2)}&=-\frac1n\int_{-4n}^{4n}\lfloor t\rfloor~dt=-\frac1n\left(\int_{-4n}^{-N}\lfloor t\rfloor~dt+\int_{-N}^{N}\lfloor t\rfloor~dt+\int_{N}^{4n}\lfloor t\rfloor~dt\right)=\\
&=-\frac1n\left(\int_{-4n}^{-N}(-N-1)~dt+\sum_{k=-N}^{N-1}\int_k^{k+1}\lfloor t\rfloor~dt+\int_{N}^{4n}N~dt\right)=\\
&=-\frac1n\left((-N-1)(-N+4n)+\sum_{k=-N}^{N-1}\int_k^{k+1}k~dt+N(4n-N)\right)=\\
&=-\frac1n\left((N+1)(N-4n)+\sum_{k=-N}^{N-1}k+4nN-N^2\right)=\\
&=-\frac1n\left(N^2+N-4nN-4n-N+4nN-N^2\right)=\\
&=-\frac1n(-4n)=4\end{aligned}$$
Thus $$I=I^{(1)}=I^{(2)}=4$$
