# Question About the Proof that the Composition of a Riemann Integrable Function and a Continuous Function is Riemann Integrable

I have a question about the proof of the following theorem from Little Rudin:

Theorem

Suppose $f \in \mathscr{R}(\alpha)$ on $[a,b]$, $m<f<M$, $\phi$ is continuous on $[m,M]$, and $h(x)=\phi(f(x))$ on $[a,b]$. Then $h \in \mathscr{R}(\alpha)$.

Proof

I will shorten the proof considerably in order to get to the question:

Since $f \in \mathscr{R}(\alpha)$, there is a partition $P=\{x_0,...,x_n\}$ of $[a,b]$ such that $$U(P,f,\alpha)-L(P,f,\alpha)<\delta^2,$$

where $U$ and $L$ are the upper and lower integrals, respectively. Let $M_i, m_i$ be the Sup and Inf, respectively, of $f$ on $[x_{i-1},x_i]$ and similarly define $M^*_i$ and $m^*_i$ for $h$. Divide the numbers $1,...,n$ into two classes: $i\in A$ if $M_i-m_i<\delta$, $i\in B$ if $M_i-m_i>\delta$. Since $\phi$ is uniformly continuous, we can now force $U(P,h,\alpha)-L(P,h,\alpha)<\epsilon$ which will be the desired result.

Question

Why do we need to divide the numbers into two classes? Why not demand that $$U(P,f,\alpha)-L(P,f,\alpha)<\delta$$ so that $M_i^*-m_i^*<\epsilon$ from uniform continuity?

Think of what happens if $f$ is the characteristic function of $[0,1]$ and $\phi(x)=x$. Then $M_i^*-m_i^*=1$ for any interval $[x_{i-1},x_i]$ such that $0\in(x_{i-1},x_i]$. Thus you can't make the difference arbitrarily small.