Help needed to understand proof to Darboux Sum Comparison Lemma I have some queries pertaining to the proof of the Darboux sum comparison lemma in the textbook, Advanced Calculus(Patrick Fitzpatrick):

Suppose $f:[a,b] \to \mathbb{R}$ and $-M \leq f(x)  \leq M, \forall x \in [a,b].$ Let $P$ be a partition of $[a,b]$ that has $k$ has partition points and $P^{*}$ be any partition of  $[a,b].$
Then, $U(f.P^{*}) \leq U(f,P)+kM\text{gap}P^{*} $ and $L(f,P)-kM\text{gap}P^{*} \leq L(f,P^{*})$

Note that $\text{gap}P^{*} = \text{max}_{i=1,...,n} [x_{i-1},x_i],$ where $P^{*}  =\{x_o,...,x_n\}$ and $U(f,P) \equiv$ upper Darboux sum of $f.$
Here is an excerpt of the proof:
Let $P=\{z_o,...,z_{k-1}\}.$ For $1\leq i \leq n, $ let $M_i = \text{sup} _{x\in [x_{i-1},x_i]}f(x)$ and call the index $i$ a crossing index if $(x_{i-1},x_{i})$ contains a partition point $z_j$ of the partition $P.$ Denote set $C$ the set of crossing indices among the indices $\{1,...,n\}.$
If $i$ is not crossing index, then $(x_{i-1},x_i)$ does not contain partition points of $P$ and therefore the interval $[x_{i-1},x_i]$ of the partition $P^{*}$ is contained in a partition interval of $P.$ Thus, $[x_{i-1},x_i]$is a partition interval of the common refinement $P'$ of $P$ and $P^{*}.$
Therefore, $\sum_{i \not\in C}M_i(x_i-x_{i-1}) \leq U(f,P^{\prime}).$ $< -\bf{May \ I \  know \ why \ this\ is \  true }$?
For eg, if $M_i>0 $ on $[xi−1,xi],i∉C$ and $\text{sup}f<0$ on the rest of the partition intervals of $P′$, then the claim that $\sum_{i \not\in C}M_i(x_i-x_{i-1}) \leq U(f,P^{\prime})$ is false. Please advise, thank you.
 A: Here I use a more conservative approach in order to maintain the distinction between upper and lower sums in the original statement.
(I don't use the symbol $E$ to avoid confusion)
If you only change $\,-M \le f(x) \le M$ with $\,0 \le f(x) \le M$, the original proof is right!
If you want a result for the case $\,-M \le f(x) \le M$, consider the auxiliary function $g(x)=f(x)+M$.
Note that $\,0 \le g(x) \le 2M$, so you can apply the edited theorem to $g\,$.
(attention: you use the edited statement directly, you don't have to repeat the proof for $g$ !)
Since now the upper bound is $2M$, you obtain $$U(g,P^*) \le U(g,P)+ k \cdot 2M \cdot \text {gap}\, P^*$$ or (translated in $f$) $$U(f,P^*)+ M(b-a) \le U(f,P)+ M(b-a)+ k \cdot 2M \cdot \text {gap}\, P^*$$ i.e. $$U(f,P^*) \le U(f,P)+ k \cdot 2M \cdot \text {gap}\, P^*$$ which is the right inequality in the case $\,-M \le f(x) \le M$.
Finally, if it is supposed $\,m \le f(x) \le M$, then the right inequality is$$U(f,P^*) \le U(f,P)+ k \cdot (M-m) \cdot \text {gap}\, P^*$$ that you obtain using the auxiliary function $g(x)=f(x)-m$.
The same for the lower sums.
A: @Tony Piccolo: Denote $C$ as the set of crossing indices, as defined earlier in Patrick's proof.  
It follows that,$\ \sum_{i \in C}M_i(x_i-x_{i-1}) \leq kM\text{gap}P^{*}=E$ and $\sum_{i \in C}m_i(x_i-x_{i-1}) \geq -kM\text{gap}P^{*} \ .$ 
On other hand, if $i$ is not crossing index, then $[x_{i-1},x_i] \subset [z_{j-1},z_j],$ for some $j.$ $\implies \sum_{i \not\in C}(M_i-m_i)(x_i-x_{i-1})\leq \sum_{j: \ {[x_{i-1},x_i] \subset [z_{j-1},z_j]}}(K_j -k_j)(z_{j}-z_{j-1}) $ $\leq U(f,P) -L(f,P),$  $ \text{where} \ K_j (\text{resp.} \ k_j) \ \text{is sup (resp. inf) of} \ f \ \text{in} \ [z_{j-1},z_j].$
Hence, $U(f,P^*)-L(f,P^*) =  \sum_{i \in C}(M_i-m_i)(x_{i}-x_{i-1})+\sum_{i \not\in C}(M_i-m_i)(x_{i}-x_{i-1})$ $ \leq 2E+ U(f,P)-L(f,P).$   
