proving $\phi(x)$ is Riemann integrable I've tried to solve the following problem:
"If $f,g:[a,b] \rightarrow \mathbb R$ are both Riemann integrable, show that the function $\phi:[a,b] \rightarrow \mathbb R$, defined as $\phi(x)= \max \{f(x), g(x)\}$ is also Riemann integrable".
My solution:
If $f,g$ are Riemann integrable, given $\epsilon >0$, there are partitions $P, Q$ with respect to the interval [a,b] such that $U(f;P)-L(f;P) < \frac{\epsilon}{2}$ and $U(g;Q)-L(g;Q) < \frac{\epsilon}{2}$, where U = upper sum and L = lower sum.
Supose $P$ is more refined than $Q$. Then we can write that $U(f;P)-L(f;P)<\frac{\epsilon}{2}$ and $U(g;P)-L(g;P)<\frac{\epsilon}{2}$. It follows that $U(f;P)+U(g;P)-[L(f;P)+L(g;P)]<\epsilon$ (1).
If $P=\{t_0,\dots,t_n\}$, consider $\sum_{i=1}^m (t_i - t_{i-1})$ as the sum of all intervals of $P$ where $M_i=\sup\phi(x)=\sup f(x)$, and $\sum_{i=1}^r (t'_i - t'_{i-1})$ as the sum of all intervals of $P$ where $N_i=\sup\phi(x)=\sup g(x)$, with $n=m+r$.
Then we can write: $U(\phi;P)= \sum_{i=1}^m M_i(t_i-t_{i-1}) + \sum_{i=1}^r N_i(t'_i-t'_{i-1})$. It shows that $U(\phi;P)\ge U(f;P)$ and $U(\phi;P)\ge U(g;P)$, or $2U(\phi;P)\ge U(f;P)+U(g;P)$.
A similar argument proves that $2L(\phi;P)\ge L(f;P)+L(g;P)$.
I'd like to get $U(\phi;P)-L(\phi;P) \le U(f;P)+U(g;P)-[L(f;P)+L(g;P)]<\epsilon$ in order to prove that $\phi$ is Riemann intrgrable, but evidently it is not the case. I commited a mistake, but I don't know where. Please, help to know what is wrong.
 A: Recall that 
$$
\max \{ f,g\} = \frac{f+g + |f-g|}2.
$$
Then you can just use the fact that if $f,g$ are Riemann integrable, successively using the fact that a difference of Riemann integrable functions is Riemann integrable, composition of a Riemann integrable function with $| \cdot |$ is Riemann integrable, and linear combinations of linear integrable functions are linear integrable, then you can conclude that $\max \{f,g\}$ is Riemann integrable.
I admit I didn't manage to go through your proof to find the "mistake" (if there is a way to do it this way), but I see $2$'s appearing (see that $2$ in my denominator? I don't think it's a surprise..), so I'm guessing there is just a lot of decoration in your proof but the hard part is essentially to show that $| f |$ is Riemann integrable when $f$ is, which is a bit hard to see with all this decoration around.
Added : For those who are wondering why $|f|$ should be integrable if $f$ is, I can use this sledgehammer to do it : $f$ has a set of discontinuities of measure zero by integrability, hence $|f|$ has a set of discontinuities of measure less or equal than zero since it is continuous, i.e. a set of discontinuities of measure zero. Therefore it is integrable.
Equivalently, $||f(x)| - |f(y)|| \le |f(x) - f(y)|$, hence $U(|f|,P) - L(|f|,P) \le U(f,P) - L(f,P)$. 
Hope that helps,
A: Here is the intuitive explanation that avoids "doing the works":
For any two points $x$, $y\in[a,b]$ one has
$$\bigl|\phi(y)-\phi(x)\bigr|\leq\bigl|f(y)-f(x)\bigr|+\bigl|g(y)-g(x)\bigr|\ .$$
This immediately implies that for any partition $P$ of $[a,b]$ the following is true:
$$U(\phi,P)-L(\phi,P)\leq U(f,P)-L(f,P)+U(g,P)-L(g,P)\ .$$
A: I am afraid that the proof that follows is not what you are looking for:
If $f$ and $g$ are continuous at a point $x\in [a,b]$, then so is $\varphi=\frac{1}{2}(f+g+|f-g|)$. Thus set of points $D_\varphi$ were $\varphi$ is not continuous is a subset of the union of the sets $D_f$ and $D_g$ where $f$ and $g$ are discontinuous. But, as $f$ and $g$ are Riemann integrable then $D_f$ and $D_g$ are sets of measure zero, hence $D_\varphi\subset D_f\cup D_g$ is also a set of measure zero, which implies that $\varphi$ is Riemann integrable.
