The trapezoid rule on an interval $[a,b]$ is
$$\frac{b-a}{2}(f(a)+f(b))=\int_a^bf(x) \ dx +\frac{f''(\xi)}{12}(b-a)^3, \quad \xi\in[a,b]. \tag i$$
The trapezoid formula is
$$T(h)=h\left[\frac{f(x_0)}{2}+f(x_1)+...+f(x_{n-1})+\frac{f(x_n)}{2}\right],\tag{ii} $$
where $x_i=a+ih$ and $h=(b-a)/n.$
Derive the error boundary
$$|T(h)-I|\le\frac{h^2}{3},$$
where $I=\int_{-1}^1f(x) \ dx$ and $f(x)=e^{-x^2}.$
The solution is the following:
Let $x_0=-1,...,x_i=-1+ih,...,x_n=1,$ where $h=2/n.$ Now we have that
$$ \begin{align} T(h) &=\sum_{i=0}^{n-1}\frac{h}{2}(f(x_i)+f(x_{i+1}))\tag1\\ &=\sum_{i=0}^{n-1}\frac{x_{i+1}-x_i}{2}(f(x_i)+f(x_{i+1}))\tag2\\ &=\sum_{i=0}^{n-1}\left[\int_{x_i}^{x_{i+1}}f(x) \ dx + \frac{f''(\xi)}{12}(x_{i+1}-x_i)^3\right]\tag3\\ &=\int_{-1}^1f(x) \ dx + \sum_{i=0}^{n-1}\frac{f''(\xi)}{12}h^3,\tag4 \end{align} $$
thus
$$ \begin{align} \left|T(h)-\int_{-1}^1f(x) \ dx\right| &=\left|\sum_{i=0}^{n-1}\frac{f''(\xi)}{12}h^3\right|\tag5\\ &\le\sum_{i=0}^{n-1}\left|\frac{f''(\xi)}{12}h^3\right|\tag6\\ &\le\sum_{i=0}^{n-1}\left|\frac{2}{12}h^3\right|= nh\frac{1}{6}h^2=\frac{h^2}{3}\tag7\\ \end{align} $$
Questions:
1) What is happening in the first line? how can $x_0=-1,...,x_i?$
2) I don't understand how they set upp equation $(1)$
3) Going from $(3)$ to $(4)$, how do the integral boundaries change to $-1$ and $1$?