<s>[INST] How to calculate $\int_a^bx^2 dx$ using summation? So for this case, we divide it to $n$ partitions and so the width of each partition is $\frac{b-a}{n}$ and the height is $f(x)$.  
\begin{align}
x_0&=a\\
x_1&=a+\frac{b-a}{n}\\
&\ldots\\
x_{i-1}&=a+(i-1)\frac{b-a}{n}\\
x_i&=a+i\frac{b-a}{n}
\end{align} 
So I pick left point, which is $x_{i-1}$
I start with 
\begin{align}
\sum\limits_{i=1}^{n} \frac{b-a}{n}f\left(a+\frac{(i-1)(b-a)}{n}\right)
&=\frac{b-a}{n}\sum\limits_{i=1}^{n} \left(a+\frac{(i-1)(b-a)}{n}\right)^2\\ 
&=\frac{b-a}{n}\left(na^2+ \frac{2a(b-a)}{n}\sum\limits_{i=1}^{n}(i-1)+\frac{(b-a)^2}{n^2} \sum\limits_{i=1}^{n}(i-1)^2\right)
\end{align}
Here I am stuck because I don't know what$ \sum\limits_{i=1}^{n}(i-1)^2$is (feel like it diverges). Could someone help?
 [/INST] The sum that is of concern is multiplied by $\frac1{n^3}$ and the limit therefore converges.  Then, proceeding, we have
$$\sum_{i=1}^n(i-1)^2=\sum_{i=0}^{n-1} i^2$$
We can evaluate the sum on the right-hand side of $(1)$ using a number of approaches.  The approach we present here exploits telescoping series.  We note that
$$\sum_{n=0}^{n-1}\left((i+1)^3-i^3\right)=n^3 \tag 2$$
If we expand the terms in the sum in $(2)$, we find that
$$3\sum_{n=0}^{n-1}i^2+3\sum_{n=0}^{n-1}i+\sum_{n=0}^{n-1} 1=n^3 \tag 3$$
whereupon solving for the sum $\sum_{n=0}^{n-1}i^2$ and using $\sum_{n=0}^{n-1}i=\frac{n(n-1)}{2}$ reveals
$$\begin{align}
\sum_{n=0}^{n-1}i^2&=\frac{n^3-n-3\frac{n(n-1)}{2}}{3}\\\\
&\bbox[5px,border:2px solid #C0A000]{=\frac{n(n-1)(2n-1)}{6}}
\end{align}$$
Dividing by $\frac1{n^3}$ and lettgin $n\to \infty$ yields $\frac13$ as expected! 
Adding this to the other terms and letting $n \to \infty$ yields
$$\bbox[5px,border:2px solid #C0A000]{\lim_{n\to \infty}\left(\frac{n\,a^2(b-a)}{n}+\frac{2a(b-a)^2\,\frac{n(n-1)}{2}}{n^2}+\frac{(b-a)^3\,\frac{n(n-1)(2n-1)}{6}}{n^3}\right)=\frac{b^3-a^3}{3}}$$ 
</s>