Calculus question. Please complete and explain the following.

We're approximating the area under the graph of the function [tex]f(x)=x^3+8[/tex] over the interval [-2, 2] by
Splitting [-2, 2] into 4 intervals gives
[-2, -1], [-1, 0], [0, 1], [1, 2]
Each subinterval has length 1. The right endpoints of the [tex]i[/tex]-th subinterval, where [tex]1\le i\le4[/tex], are given by the (arithmetic) sequence
[tex]r_i=-1+1(i-1)=i-2[/tex]
The area of the rectangle over the [tex]i[/tex]-th subinterval is
[tex]A_i=f(i-2)=(i-2)^3+8=i^3-6i^2+6i[/tex]
and so the definite integral is approximately
[tex]\displaystyle\int_{-2}^2(x^3+8)\,\mathrm dx\approx\sum_{i=1}^4(i^3-6i^2+6i)[/tex]
There are well-known formulas for computing the sums of powers of consecutive (positive) integers. The ones we care about are
[tex]\displaystyle\sum_{i=1}^ni=\frac{n(n+1)}2[/tex]
[tex]\displaystyle\sum_{i=1}^ni^2=\frac{n(n+1)(2n+1)}6[/tex]
[tex]\displaystyle\sum_{i=1}^ni^3=\frac{n^2(n+1)^2}4[/tex]
So we get
[tex]\displaystyle\int_{-2}^2(x^3+8)\,\mathrm dx\approx40[/tex]