Is the set of the upper Riemann sums convex for an arbitrary bounded function $f(x)$? If $f$ is bounded on $[a,b]$ and $P= (x_0,x_1.\cdots,x_n)$ is a partition of $[a,b]$, let $M_j = \sup_{x_{j-1}\le x \le x_j}\text{$f(x)$}$. The upper Riemann sums of $f$ over $P$ is $S(P)= \sum_{j=1}^{n} M_j(x_j-x_{j-1}) $.
Now, let's consider the set of all $S(P)$:  $X_f$ = {$S(P)$| for all possible $P$}.
Is $X_f$ convex for arbitrary bounded functions? If not, what conditions $f$ should have so that $X_f$ can be convex?
By convex I mean: if $S(P_1) \in X_f$ and $S(P_2) \in X_f$, then $\lambda S(P_1)+(1-\lambda)S(P_2) \in X_f$ for all $\lambda \in [0,1]$.
 A: $\newcommand{\Part}{\mathscr{P}}\newcommand{\eps}{\varepsilon}$Added: For each integer $n \geq 1$, let $\Part_{n}$ denote the set of partitions of $[a, b]$ with precisely $n$ subintervals, viewed as the connected simplex
$$
\{(t_{k})_{k=0}^{n} : a = t_{0} < t_{1} < \cdots < t_{n-1} < t_{n} = b\}
\subset [a, b]^{n+1}
$$
in the $(n + 1)$-dimensional cube.
The real-valued functions $\Delta t_{k} = t_{k} - t_{k-1}$ are continuous on $\Part_{n}$. If $f:[a, b] \to \mathbf{R}$ is continuous, the function
$$
M(s_{1}, s_{2}) = \sup\{f(t) : s_{1} \leq t \leq s_{2}\}
$$
is continuous on $[a, b] \times [a, b]$. (A proof is deferred to avoid interrupting the argument.) Consequently, the upper-Darboux-sum function
$$
U((t_{k})_{k=0}^{n}) = \sum_{k=1}^{n} M(t_{k-1}, t_{k})\, \Delta t_{k}
$$
is continuous on $\Part_{n}$. Since $\Part_{n}$ is connected, the image $U(\Part_{n})$ is an interval of real numbers.
We may identify $\Part_{n}$ with part of the boundary of $\Part_{n+1}$ by "collapsing the last interval." In detail, let $P = (t_{k})_{k=0}^{n}$ be a partition in $\Part_{n}$, let $t'$ be a real number with $t_{n-1} < t' < t_{n} = b$, and let $P(t')$ denote the partition in $\Part_{n+1}$ obtained by splitting $[t_{n-1}, t_{n}] = [t_{n-1}, t'] \cup [t', t_{n}]$. Letting $t' \to t_{n}$ gives a path in $\Part_{n+1}$ converging to $P$ in $\Part_{n}$, and we have $\lim_{t' \to t_{n}} U(P(t')) = U(P)$: Write
$$
M_{1}(t') = \sup \{f(t) : t_{n-1} \leq t \leq t'\},\quad
M_{2}(t') = \sup \{f(t) : t' \leq t \leq t_{n}\}.
$$
In the limit as $t' \to t_{n}$, $M_{1}(t') \to M(t_{n-1}, t_{n})$, so
$$
M_{1}(t')(t' - t_{n-1}) + M_{2}(t')(t_{n} - t') \to M(t_{n-1}, t_{n})\, \Delta t_{n}.
$$
To summarize:

*

*For each $N \geq 1$ the set $\bigcup_{n=1}^{N} \Part_{n}$ is connected (the union contains the connected set $\Part_{N}$ and is contained in the closure);

*The image of each union under the (continuous) Darboux upper-sum function $U$ is connected, so the set of all upper Darboux sums, $\bigcup_{n=1}^{\infty} U(\Part_{n})$ is a union of nested intervals, and therefore an interval.


Proof that $M(s_{1}, s_{2}) = \sup \{f(t) : s_{1} \leq t \leq s_{2}\}$ is continuous on $[a, b] \times [a, b]$: By the extreme value theorem, the supremum of $f$ on a compact interval $[s_{1}, s_{2}] \subset [a, b]$ is a value $f(s')$ for some $s'$ in $[s_{1}, s_{2}]$.
If $f(s_{1}) < M(s_{1}, s_{2})$, continuity of $f$ at $s_{1}$ guarantees there is a $\delta$, with $0 < \delta < s_{2} - s_{1}$, such that if $|s - s_{1}| < \delta$, then $f(s) < M(s_{1}, s_{2})$. Consequently,
$$
M(s, s_{2}) = \sup\{f(t) : s \leq t \leq s_{2}\}
= \sup\{f(t) : s_{1} \leq t \leq s_{2}\}
= M(s_{1}, s_{2}),
$$
i.e., $M$ is locally constant.
Suppose instead that $f(s_{1}) = M(s_{1}, s_{2})$, and fix $\eps > 0$ arbitrarily. Since $f$ is continuous at $s_{1}$, there exists a $\delta$, with $0 < \delta < s_{2} - s_{1}$, such that if $|s - s_{1}| < \delta$, then $|f(s) - f(s_{1})| < \eps$, or $M(s_{1}, s_{2}) - \eps < f(s) < M(s_{1}, s_{2}) + \eps$. This implies $|M(s, s_{2}) - M(s_{1}, s_{2})| < \eps$.
Continuity at $s_{2}$ is similar.

Original post (retained in case it's of interest to posterity).
Suppose $f$ is real-valued and bounded on $[a, b]$. Write $m = \inf f$ and $M = \sup f$. The set of Riemann sums of $f$ over $[a, b]$ is clearly contained in $[m(b - a), M(b - a)]$. It suffices to show the set of Riemann sums contains $(m(b - a), M(b - a))$.
Pick sequences $(x_{k})$ and $(y_{k})$ in $[a, b]$ so that $f(x_{k}) \to m$ and $f(y_{k}) \to M$. Particularly, the one-interval Riemann sums $f(x_{k})(b - a)$ approach $m(b - a)$, and similarly the one-interval Riemann sums $f(y_{k})(b - a)$ approach $M(b - a)$.
Observation: The two-interval Riemann sums $f(a)(t - a) + f(b)(b - t)$ continuously interpolate the one-interval Riemann sums $f(a)(b - a)$ and $f(b)(b - a)$.
Fix $k$, split $[a, b] = [a, x_{k}] \cup [x_{k}, b]$, and consider the Riemann sums indexed by the points of evaluation
\begin{alignat*}{2}
  R_{a,b} &= f(a)(x_{k} - a) &&+ f(b)(b - x_{k}), \\
  R_{x_{k},b} &= f(x_{k})(x_{k} - a) &&+ f(b)(b - x_{k}), \\
  R_{x_{k}} &= f(x_{k})(x_{k} - a) &&+ f(x_{k})(b - x_{k}) \\
  &= f(x_{k})(b - a).
\end{alignat*}
By the observation applied to $[a, b]$, every real number between $f(a)(b - a)$ and $R_{a,b}$ is a Riemann sum of $f$ on $[a, b]$.
By the observation applied to $[a, x_{k}]$, every real number between $R_{a,b}$ and $R_{x_{k},b}$ is a Riemann sum of $f$ on $[a, b]$.
By the observation applied to $[x_{k}, b]$, every real number between $R_{x_{k},b}$ and $R_{x_{k}}$ is a Riemann sum of $f$ on $[a, b]$.
Consequently, every real number between $f(a)(b - a)$ and $f(x_{k})(b - a)$ is a Riemann sum of $f$ on $[a, b]$. Similarly, every real number between $f(a)(b - a)$ and $f(y_{k})(b - a)$ is a Riemann sum of $f$ on $[a, b]$.
This shows every real number between $f(x_{k})(b - a)$ and $f(y_{k})(b - a)$ inclusive is a Riemann sum of $f$ on $[a, b]$. Since the set of Riemann sums contains $[f(x_{k})(b - a), f(y_{k})(b - a)]$ for every $k$, the choice of $(x_{k})$ and $(y_{k})$ guarantees the set of Riemann sums contains $(m(b - a), M(b - a))$.
