Error when approximating $\int_0^{1}(x^{2}+x)dx$ with midpoint rule. Task is to define the exact error when approximating $\int_0^{1}(x^{2}+x)dx$ with midpoint rule using n subintervals. I know the error term is $E(f)=\frac{1}{24}(b-a)f^{''}(\varepsilon)h^{2}$ but im not sure if this is the exact form and if it is how do you get it?
 A: Let $f(x)=x^2+x$. Then you have 
$$I=\int_0^1 f(x) dx= \frac{5}{6}$$
while the midpoint approximation $I_n$ for $n$ subintervals is according to Wiki and the well known formulas for $\sum_k k$ and  $\sum_k k^2$
$$I_n = \frac{1}{n}\sum_{k=0}^{n-1} f\left(\frac{k}{n}\right)=\\
=\frac{1}{n}\sum_{k=0}^{n-1}\left(\frac{k}{n}\right)^2 + \frac{1}{n}\sum_{k=0}^{n-1}\frac{k}{n}\\
=\frac{1}{n^3}\sum_{k=0}^{n-1}k^2 + \frac{1}{n^2}\sum_{k=0}^{n-1}k\\
=\frac{n^3/3-n^2/2+n/6}{n^3}
+\frac{n^2/2-n/2}{n^2}\\
=\frac{5}{6}-\frac{1}{n}+\frac{1}{6n^2}$$
Can you continue?
A: I believe i know the answer now if someone needs it. $M_n=h(f(\frac{1}{2n})+f(\frac{3}{2n})+f(\frac{5}{2n})+,..,+f(\frac{1-\frac{1}{n}+1}{2}))$
$M_n=\frac{1}{n}\sum_{k=0}^{n-1}f(\frac{2k+1}{2n})=\frac{1}{n}\sum_{k=0}^{n-1}(\frac{2k+1}{2n})+\frac{1}{n}\sum_{k=0}^{n-1}(\frac{2k+1}{2n})^{2}$
$M_n=\frac{1}{2n^{2}}\sum_{k=0}^{n-1}(2k+1)+\frac{1}{4n^{3}}\sum_{k=0}^{n-1}(2k+1)^{2}$
$=\frac{1}{2n^{2}}(2\sum_{k=0}^{n-1}k+\sum_{k=0}^{n-1}1)+\frac{1}{4n^{3}}(4\sum_{k=0}^{n-1}k^{2}+4\sum_{k=0}^{n-1}k+\sum_{k=0}^{n-1}1)$
Using sum formulas: $\sum_{i=m}^{n}1=n+1-m$, $\sum_{i=0}^{n}i=\frac{n(n+1)}{2}$, $\sum_{i=0}^{n}i^{2}=\frac{n(n+1)(2n+1)}{6}$
$\longrightarrow M_4=\frac{1}{2n^{2}}(2\frac{(n-1)n}{2}+n)+\frac{1}{4n^{3}}(4\frac{(n-1)n(2n-1)}{6}+2(n-1)n+n)$
$=\frac{n^{2}}{2n^{2}}+\frac{1}{4n^{3}}(\frac{4(2n^{3}-3n^{2}+n)}{6}+\frac{12n^{2}-6n}{6})$
$=\frac{1}{2}+\frac{8n^{3}-12n^{2}+4n+12n^{2}-6n}{24n^{3}}=\frac{1}{2}+\frac{8n^{3}-2n}{24n^{3}}=\frac{5}{6}-\frac{1}{12n^{2}}$  So the correct error is $\frac{1}{12n^{2}}$
