Riemann integrals real analysis How would I do this question?
$$
\int_{-1}^{2}(4x - x^2)dx
$$
I am using a similar method that I did for a different question but I think my problem is I don't know how to tackle the $x^2$.
I am getting an answer of $15$, but $15$ is not the answer.
 A: When using the Riemann definition, we first have to define the partition and the interpolation points. In the region $[-1,0]$ we use $x_i=-\frac{i}{N}$, and every interval has length $\frac{1}{N}$. In the region $[0,2]$ we use $x_i=2\frac{i}{N}$ and every interval has length $\frac{2}{N}$. It follows that the integral is approximated by Riemann sums:
\begin{align}
\int_{-1}^2x^2dx&=\lim_{N\to\infty}\left[\sum_{i=1}^N\frac{1}{N}\left(-\frac{i}{N}\right)^2\right]+\lim_{N\to\infty}\left[\sum_{i=1}^N\frac{2}{N}\left(2\frac{i}{N}\right)^2\right]\\
&=\lim_{N\to\infty}\left[\frac{1}{N^3}\sum_{i=1}^Ni^2\right]+8\lim_{N\to\infty}\left[\frac{1}{N^3}\sum_{i=1}^Ni^2\right]\\
&=\lim_{N\to\infty}\left[\frac{1}{N^3}\frac{1}{6}N(N+1)(2N+1)\right]+8\lim_{N\to\infty}\left[\frac{1}{N^3}\frac{1}{6}N(N+1)(2N+1)\right]\\
&=\lim_{N\to\infty}\frac{N(N+1)(2N+1)}{6N^3}+\lim_{N\to\infty}\frac{4N(N+1)(2N+1)}{3N^3}\\
&=\frac{1}{3}+\frac{8}{3}=3
\end{align}
Here we used that $1^2+2^2+\cdots+N^2=\frac{1}{6}N(N+1)(2N+1)$ and that the limit of the ratio of two polynomials is determined by the ratio of the leading coefficients.
Do you understand which intervals are convenient to choose and how to do the summation?
