Prove that $f(x)=x^2$ is integrable using superior and inferior sums I need to prove that $f:[-1,2]\rightarrow\mathbb{R}$ given by $f(x)=x^2$ is integrable using this theorem:
Let $f:[a,b]\rightarrow\mathbb{R}$ be limited. The following afirmations are equivalent:
(1) $f$ is integrable;
(2) for all $\varepsilon>0$, exists partitions $P$ and $Q$ from $[a,b]$ such that $S(f;Q)-s(f;P)<\varepsilon$;
(3) for all $\varepsilon>0$, exists a partition $P=\{t_0,\dots,t_n\}$ from $[a,b]$ such that
$$S(f;P)-s(f;P)=\sum_{i=1}^{n}\omega_i(t_i-t_{i-1})<\varepsilon.$$
$$s(f;P)=\sum_{i=1}^{n}m_i(t_i-t_{i-1}); S(f;P)=\sum_{i=1}^{n}M_i(t_i-t_{i-1});$$
$$m_i=\inf\{f(x);x\in[t_{i-1},t_i]\};M_i=\sup\{f(x);x\in[t_{i-1},t_i]\};\omega_i=M_i-m_i.$$
I got stuck in a part of the demonstration I tried:
Given $\varepsilon>0$, exists $n\in\mathbb{N}$ such that
$$\dfrac{1}{n}<\varepsilon\quad\mbox{ and }\quad\dfrac{2}{n}<2\varepsilon.$$
Let's take partitions $P_1$ and $P_2$ that refine $P_0=\{-1,0,2\}$ such that
$$P_1=\left\{t_0=-1,t_1=-1+\dfrac{1}{n},t_2=-1+\dfrac{2}{n},\dots,t_n=-1+\dfrac{n}{n}=0\right\}\mbox{and}$$
$$P_2=\left\{t_0=0,t_1=0+\dfrac{2}{n},t_2=0+\dfrac{2(2)}{n},\dots,t_n=0+\dfrac{n(2)}{n}\right\}.$$
Note that for each interval $[t_{i-1},t_i]$ from $P_1$ we have that
$$m_i=f(t_i)=(t_i)^2\quad\mbox{and}\quad M_i=f(t_{i-1})=(t_{i-1})^2;$$
because $f$ strictly decreasing in $[-1,0]$.
Note, also, that for each interval $[t_{i-1},t_i]$ from $P_2$ we have that
$$m_i=f(t_{i-1})=(t_{i-1})^2\quad\mbox{and}\quad M_i=f(t_{i})=(t_{i})^2;$$
because $f$ is strictly increasing in $[0,2]$.
In this way,
$$S(f;P_2)-s(f;P_1)=$$
$$\left[\left(\dfrac{2}{n}\right)^2\left(\dfrac{2}{n}-0\right)+\left(\dfrac{4}{n}\right)^2\left(\dfrac{4}{n}-\dfrac{2}{n}\right)+\cdots+\left(2\right)^2\left(2-\dfrac{(n-1)(2)}{n}\right)\right]$$
$$-\left[\left(-1\right)^2\left(-1+\dfrac{1}{n}-(-1)\right)+\left(-1+\dfrac{1}{n}\right)^2\left(-1+\dfrac{2}{n}-\left(-1+\dfrac{1}{n}\right)\right)+\cdots+\left(-1+\dfrac{n-1}{n}\right)^2\left(0-\left(-1+\dfrac{n-1}{n}\right)\right)\right]$$
and that's it... I got stuck. What I was trying to do is simplify all of this to get that
$$S(f;P_2)-s(f;P_1)=\left(\dfrac{2}{n}\right)-\left(\dfrac{1}{n}\right)<2\varepsilon-\varepsilon=\varepsilon.$$
But I couldn't do it... anyone can help me?
 A: tl; dr: The key idea is, on an interval where $f$ is monotone, the difference between the upper and lower sums with respect to an equal-length partition telescopes to $\Delta f\, \Delta t$.

Suppose $f$ is real-valued on $[a, b]$, and without loss of generality assume $f$ is non-decreasing. For each positive integer $n$, consider the equal-length partition $t_{i} = a + i(b-a)/n$ for $0 \leq i \leq n$, whose subintervals all have length $\Delta t = (b-a)/n$.
On the $i$th subinterval $I_{i} = [t_{i-1}, t_{i}]$ we have
$$
m_{i} = f(t_{i-1}),\qquad
M_{i} = f(t_{i}).
$$
Since the subintervals all have the same length,
\begin{align*}
  S(f, P) - s(f, P)
  &= \sum_{i=1}^{n} f(t_{i})\, \Delta t - \sum_{i=1}^{n} f(t_{i-1})\, \Delta t \\
  &= \Delta t \sum_{i=1}^{n} \bigl[f(t_{i}) - f(t_{i-1})\bigr] \\
  &= \Delta t\, \bigl[f(b) - f(a)\bigr]
  = \bigl[f(b) - f(a)\bigr]\, \frac{b - a}{n}.
\end{align*}
This is essentially what you have with your lengthy sum, but the way the terms are expanded may be obscuring the cancellation.
A: Your $P_1$ is a partition on [-1,0] and your $P_2$ is a partition on [0,2]. So your partition P on [-1,2] should be $P=P_1+P_2$, aka:
$P=\{t_{-n}=-1, t_{-n+1}=-1+\frac{1}{n}, ..., t_{-1}=-\frac{1}{n}, t_0=0, t_1=\frac{2}{n}, ..., t_n=2\}$
You can then start from here to show $S(f, P)-s(f, P)<\epsilon$, or
$[S(f,p_1)+S(f,p_2)]-[s(f,p_1)+s(f,p_2)]<\epsilon$.
