$ f(x)=x^2-1$ with an interval of $[0,1]$
i have this equation and made each step to solve this problem, but at the time of applying the special rule when $\sum_{k=1}^{n}k^2= \frac{n(n+1)(2n+1)}{6}$ but i think i messed up a value in my equations because i got a value that doesn't match with the one in my guidebook, here are my steps, please try to explain where i got wrong please, thank you.
here is my work since LATEX is pretty hard rn for me at the moment.
$$ \int_0^1 f(x)dx=\lim\limits_{n\rightarrow +\infty}\frac{1}{n}\sum_{k=1}^nf\left(\frac{k}{n}\right) $$ And $$ \begin{aligned} \frac{1}{n}\sum_{k=1}^nf\left(\frac{k}{n}\right)&=\frac{1}{n}\sum_{k=1}^n\left(\frac{k^2}{n^2}-1\right) \\ &=\frac{1}{n^3}\sum_{k=1}^n k^2-1 \\ &=\frac{n(n+1)(2n+1)}{6n^3}-1 \end{aligned}$$ Letting $n\rightarrow +\infty$ gives $$ \int_0^1 f(x)dx=\frac{2}{6}-1=-\frac{2}{3} $$