# Evaluating $\int_0^n \{x^2\}\,\text{d}x$

I have problems with the series that appear evaluating this integral $$\int_0^n \{x^2\}\,\text{d}x$$ where $$\{\cdot\}$$ is the fractional part function. Now, I'm pretty sure that $$I=\sum_{k=0}^{n^2-1}\int_\sqrt k^\sqrt{k+1} (x^2-k)\,\text{d}x$$ since $$\{x^2\}=x^2-\lfloor x^2\rfloor=x^2-k$$ for $$x\in[\sqrt k,\sqrt{k+1})$$. Now, if that is correct, I proceed integrating and I obtain the series $$I=\frac13\sum_{k=0}^{n^2-1} ((k+1)^\frac32-k^\frac32)-\sum_{k=0}^{n^2-1} k(\sqrt{k+1}-\sqrt k)$$ The first telescopes to $$\frac{n^3}3$$ while for the second I thought to apply the formula of summation by parts, that is $$\sum_{n=k}^Na_nb_n=S_Nb_N-S_{k-1}b_k-\sum_{n=k}^{N-1}S_n(b_{n+1}-b_n)$$ where $$S_N=\sum_{n=1}^Na_n$$. Choosing $$a_n=\sqrt{k+1}-\sqrt k$$, since its $$(n^2-1)$$-th partial sum telescopes to $$n-1$$, the formula gives $$\sum_{k=0}^{n^2-1} k(\sqrt{k+1}-\sqrt k)=(n-1)(n^2-1)-\sum_{k=0}^{n^2-2} (k-1)$$ that seems to be false because $$\sum_{k=0}^{n^2-2} (k-1)>(n-1)(n^2-1)$$ while $$\sum_{k=0}^{n^2-1} k(\sqrt{k+1}-\sqrt k)>0$$. I sincerely think I have done something wrong but I don't understand what… Could someone explain or find another solution (the answer given by the book is $$-\frac{2n^3}3+\sum_{k=1}^{n^2} \sqrt k$$)?

• Do you intend to define $I$ to be the integral in your first display? – Eric Towers Apr 11 at 18:15
• Exactly, that is – bianco Apr 11 at 18:18
• Is $n$ a nonnegative integer? – Eric Towers Apr 11 at 18:30
• Yes, $n$ is defined as a natural number – bianco Apr 11 at 19:30

Ok, I just understood my mistake and it's very silly. We have that $$S_k=\sqrt{k+1}-1$$ and instead I used $$S_{k^2-1}$$ as $$S_k$$. Then the answer comes easily expanding, re-elaborating and re-indexing the sums. So stupid...