Evaluating $\int_{-2}^{2} 4-x^2 dx$ with a Riemann sum

I'm having problems with a Riemann sum ... I need to find the integral:$$\int_{-2}^2 (4-x^2)\;dx$$Clearly we have $$\int_{-2}^{2}(4-x^2)\;dx=4x-\frac{x^3}{3}\mid_{-2}^{2}=(4\cdot2-\frac{2^3}{3})-(4\cdot(-2)-\frac{(-2)^3}{3})=\frac{32}{3}$$OK.

On the other hand, we have $$\Delta x=\frac{b-a}{n}=\frac{4}{n}$$ and $$\xi_1=-2+\frac{4}{n};\;\;\xi_2=-2+2\frac{4}{n};\;\;\ldots\;\;;\xi_n=-2+n\frac{4}{n}$$ then $$\xi_i=-2+\frac{4i}{n}=\frac{4i-2n}{n},$$ so that \begin{align} \int_{-2}^2 {4-x^2}\;dx=&\lim_{n\to+\infty} \sum_{i=1}^n\left(4-\left( \frac{4i-2n}{n}\right)^2\right)\frac{4}{n}\\ =&\lim_{n\to+\infty} \sum_{i=1}^n\left(4-\left( \frac{4i-2n}{n}\right)^2\right)\cdot\frac{4}{n}\\ =&\lim_{n\to+\infty} \sum_{i=1}^n\left(4-\left( \frac{16i^2-16ni+4n^2}{n^2}\right)\right)\cdot\frac{4}{n}\\ =&\lim_{n\to+\infty} \sum_{i=1}^n \left(\frac{4n^2-16i^2+16ni-4n^2}{n^2} \right)\cdot\frac{4}{n}\\ =&\lim_{n\to+\infty} \sum_{i=1}^n \frac{-16i^2+16ni}{n^2}\cdot\frac{4}{n} \\ =&\lim_{n\to+\infty}\sum_{i=1}^{n} \frac{-64i^2+64ni}{n^3}\\ =&\lim_{n\to+\infty} \frac{64}{n^3}\left(-\sum_{i=1}^{n} i^2+n\sum_{i=1}^{n} i\right) \\ =&\lim_{n\to+\infty} \frac{64}{n^3} \left(-\frac{n(n+1)(2n+1)}{6}+n\cdot \frac{n(n+1)}{2} \right)\\ =&\lim_{n\to+\infty} \frac{64}{n^3} \left(-\frac{\color{#ff0000}{2}n^3+3n^2+n}{6}+\frac{n^3+n^2}{2} \right) \\ =&\lim_{n\to+\infty} \frac{64}{n^3} \left(\frac{-\color{#ff0000}{2}n^3-3n^2-n+3n^3+3n^2}{6}\right)\\ =&\lim_{n\to+\infty}\frac{32}{3} \left(\frac{\color{#ff0000}{1\times}n^3-n}{n^3}\right) \\ =&\lim_{n\to+\infty}\frac{64}{\color{#ff0000}{2\times}3}-\frac{32}{3n^2}=\frac{64}{\color{#ff0000}{2\times}3} \color{#ff0000}{=}\frac{32}{3}=\int_{-2}^{2} {4-x^2}\;dx \end{align}

Where is the mistake?

• $n(n+1)(2n+1)=2n^3+3n^2+n\neq n^3+3n^2+n$ Commented Oct 13, 2013 at 23:11

The problem is an accidental algebra mistake, as I pointed out in comments: $n(n+1)(2n+1)=2n^3+3n^2+n\neq n^3+3n^2+n$, and this should do it.
Check the step where you expand $n \left( n+1 \right) \left( 2\,n+1 \right)$. I believe the mistake is in that step.
We have $$\Delta x=\frac{b-a}{n}=\frac{4}{n}$$ and $$\xi_1=-2+\frac{4}{n};\;\;\xi_2=-2+2\frac{4}{n};\;\;...\;\;;\xi_n=-2+n\frac{4}{n}$$ then $$\xi_i=-2+\frac{4i}{n}=\frac{4i-2n}{n}$$ $$\int_{-2}^2 {4-x^2}\;dx=\lim_{n\to+\infty} \sum_{i=1}^n\left(4-\left( \frac{4i-2n}{n}\right)^2\right)\frac{4}{n}\\\lim_{n\to+\infty} \sum_{i=1}^n\left(4-\left( \frac{4i-2n}{n}\right)^2\right)\cdot\frac{4}{n}\\ \lim_{n\to+\infty} \sum_{i=1}^n\left(4-\left( \frac{16i^2-16ni+4n^2}{n^2}\right)\right)\cdot\frac{4}{n}\\ \lim_{n\to+\infty} \sum_{i=1}^n \left(\frac{4n^2-16i^2+16ni-4n^2}{n^2} \right)\cdot\frac{4}{n}\\ \lim_{n\to+\infty} \sum_{i=1}^n \frac{-16i^2+16ni}{n^2}\cdot\frac{4}{n}=\lim_{n\to+\infty}\sum_{i=1}^{n} \frac{-64i^2+64ni}{n^3}\\\lim_{n\to+\infty} \frac{64}{n^3}\left(-\sum_{i=1}^{n} i^2+n\sum_{i=1}^{n} i\right)=\lim_{n\to+\infty} \frac{64}{n^3} \left(-\frac{n(n+1)(2n+1)}{6}+n\cdot \frac{n(n+1)}{2} \right)=\\ \lim_{n\to+\infty} \frac{64}{n^3} \left(-\frac{2n^3+3n^2+n}{6}+\frac{n^3+n^2}{2} \right)=\lim_{n\to+\infty} \frac{64}{n^3} \left(\frac{-2n^3-3n^2-n+3n^3+3n^2}{6}\right)\\ \lim_{n\to+\infty}\frac{32}{3} \left(\frac{n^3-n}{n^3}\right)=\lim_{n\to+\infty}\frac{32}{3}-\frac{32}{3n^2}=\frac{32}{3}=\int_{-2}^{2} {4-x^2}\;dx$$