After a lecture today, I just wanted to confirm that I understand the proof of the following:  

If $f: [a,b] \to \mathbb{R}$ is bounded and continuous and has finitely many discontinuities, $f \in \mathscr{R}$. 

Proof:  

Let $\{x\_1,\ldots x\_l\}$ be the set of discontinuities of $f$. Let $\epsilon > 0$. Let $M$ be such that $|f| \leq M$. Let $\delta > 0$ be such that $2(k+2)M\delta < \frac{\epsilon}{2}$. Now, consider the interval $$B= [a,b] \setminus \left( (x\_1-\delta, x\_1 + \delta) \cup (x\_2-\delta, x\_2+\delta) \cup \cdots \cup (x\_k-\delta, x\_k+\delta) \right),$$ clearly $B$ is compact by Heine-Borel. Thus, $f|B :B \to \mathbb{R}$ is uniformly continuous. Thus, there exists $\delta > 0$ so that, if $|x-y| < \delta$, $|f(x) - f(y)| < \frac{\epsilon}{2(b-a)}$. Now, let $n$ be a positive integer such that $\frac{b-a}{n} < \delta$. Consider the partition
$$P:= \left\{a=x\_0, a+\frac{x\_1-\delta-a}{n}, a+2\frac{x\_1-\delta}{n}, \ldots x\_1- \delta, x\_1+\delta, \ldots, x\_k+\delta , x\_k+\delta+\frac{b-(x\_k+\delta)}{n}, \ldots, b \right\}$$ That is, we have two types of intervals. One type is of the form $[x\_i - \delta, x\_i+\delta]$ while we chop what is between $x\_i+\delta$ and $x\_{i+1} - \delta$ into $n$ parts. Now here's where I get a bit confused. I suppose we chop this middle piece up even further, although I'm not sure why. Consider the intervals 

$$D\_i = \left[x\_i+\delta+m\left(\frac{x\_{i+1} - x\_i -2\delta}{n}\right), x\_i+\delta+(m+1)\left(\frac{x\_{i+1} - x\_i -2\delta}{n}\right)\right]$$ 

Call $\frac{x\_{i+1} - x\_i -2\delta}{n} =T$. Then, if $y\_1,y\_2 \in D\_k$, then $$|y\_1-y\_2| \leq T \leq \frac{b-a}{n} < \delta$$. 

so that if $y\_1,y\_2 \in D\_i$, the uniform continuity condition holds. 

Now, for any $y \in D\_i$, $f(y) = f(y) - f(y\_1) + f(y\_1)$ so that $f(y) \leq \frac{\epsilon}{2(b-a)} + f(y\_1)$ for all $y \in D\_i$. Thus, $$\sup\_{x \in D\_i} f(x) \leq \frac{\epsilon}{2(b-a)} + f(y\_1)$$ and $$\inf\_{x \in D\_k} f(x) \geq -\frac{\epsilon}{2(b-a)} + f(y\_1)$$. Thus, $$\sup\_{x \in D\_i} f(x)- \inf\_{x \in D\_k} f(x) \leq \frac{\epsilon}{(b-a)}.$$ Now, we need show that $U(f,P) - L(f,P) < \epsilon$. Let $M\_i = \sup\_{x \in \Delta\_i} f(x)$ and $m\_i$ similarly. We have that 

$$ \begin{align}
U(f,P) - L(f,P) &= \sum\_{P} (M\_i-m\_i)\Delta\_i \\
&= \sum\_{[x\_i-\delta,x\_i+\delta]} (M\_i-m\_i)\Delta\_i + \sum\_{D\_i} (M\_i-m\_i)\Delta\_i \\&\leq
\sum\_{[x\_i-\delta,x\_i+\delta]} 4M\delta + \sum\_{D\_i} \frac{\epsilon}{(b-a)}\frac{b-a}{n} \\&= 
4Mk\delta + (k+1)n\frac{\epsilon}{n} \\&< \epsilon
\end{align}$$ 

Thus, $f \in \mathscr{R}$. 

Now, this proof seems a bit *mathemagical* to me. I understand that it works, just not *why*. I see that we construct little intervals around the discontinuities in order to "ignore" them, but I don't see, for example, why we need to create the $D\_i$ intervals. Why do we need to chop the interval between the $x\_i+\delta$ and $x\_{i+1} -\delta$ into $n$ pieces. Why can't we just consider the middle and only the middle? Any insight to the intuition would be greatly appreciated.