Proving $\int_0^{n^2} \left\lfloor\sqrt t\right\rfloor \,dt=\frac{n(n-1)(4n+1)}{6}$

I want to prove

$$\int_{0}^{n^{2}} \left\lfloor \sqrt{t} \right\rfloor \,dt=\frac{n(n-1)(4n+1)}{6}$$

Is it correct to say that $$\left\lfloor \sqrt{t} \right\rfloor=\sqrt{(k-1)}$$ and $$(k-1)^{2} < t < k^{2}$$, where $$\int_{0}^{n^{2}} \left\lfloor \sqrt{t} \right\rfloor \,dt =\sum_{k=1}^{n} \sqrt{(k-1)} \cdot (k^2 - (k-1)^2)$$ I would know how to do the rest, but how did we know that $$\left\lfloor \sqrt{t} \right\rfloor=\sqrt{(k-1)}$$, is it something you assume depending on the function? Because for a previous function, there was $$\int_{0}^{n} \left\lfloor t^{2} \right\rfloor \,dt$$ and it was set $$\left\lfloor t^{2} \right\rfloor=(k-1)^2$$, I would really appreciate if someone would kindly explain this to me.

• The floor function $\lfloor\sqrt t\rfloor$ always gives an integer value; $\sqrt{k-1}$ is rarely an integer. What you actually have is $\lfloor\sqrt t\rfloor=k-1$ if $(k-1)^2\lt t\lt k^2$. – Barry Cipra Mar 21 at 19:44

You have $$\int_0^{n^2} \lfloor \sqrt{t} \rfloor \mathrm{dt} = \sum_{k=0}^{n-1} \int_{k^2}^{(k+1)^2} \lfloor \sqrt{t} \rfloor \mathrm{dt}$$
But if $$k^2 < t < (k+1)^2$$, then $$\lfloor \sqrt{t} \rfloor = k$$. So $$\int_0^{n^2} \lfloor \sqrt{t} \rfloor \mathrm{dt} = \sum_{k=0}^{n-1} k((k+1)^2-k^2) = \sum_{k=0}^{n-1} k(2k+1) = 2 \frac{n(n-1)(2n-1)}{6}+\frac{(n-1)n}{2}$$
i.e. $$\int_0^{n^2} \lfloor \sqrt{t} \rfloor \mathrm{dt} = \frac{n(n-1)(4n+1)}{6}$$
• $(k + 1)^2 - k^2 = 2k + 1$ so it should be the sum of $2k^2 + k$. – Trevor Gunn Mar 21 at 19:53