Integral inequality $\frac{1}{2M}\le\int_0^1xf(x)dx\le1-\frac{1}{2M}$ Let $f:[0,1]\rightarrow[0,\infty)$ be a continuous function such that $\int_0^1f(x)dx=1$, and let $M=\max f(x)$. Show that:
$$\frac{1}{2M}\le\int_0^1xf(x)dx\le1-\frac{1}{2M}$$
We have $1=\int_0^1f(x)dx\le\int_0^1Mdx=M$, so $M\ge1$. I tried several inequalities, but none of them seem to be working in this case. I could use a hint. Thank you!
 A: Let $F(x) := \int_0^x f(s)\, ds$, $x\in [0,1]$.
Then $F$ is continuously differentiable, monotone non-decreasing function, satisfying
$$
F(0) = 0, \quad
F(1) = 1, \quad
0 \leq F'(x) \leq M, \ \forall x\in [0,1].
$$
As a consequence,
$$
\max\{0, 1- M(1-x)\} \leq F(x) \leq \min\{1, Mx\},
\qquad \forall x\in [0,1],
$$
so that
$$
\frac{1}{2M} \leq \int_0^1 F(x)\, dx \leq 1 - \frac{1}{2M}\,. \tag{1}
$$
On the other hand, integrating by parts
$$
\int_0^1 x\,f(x)\, dx = F(1) - \int_0^1 F(x)\, dx = 1 - \int_0^1 F(x)\, dx,
$$
so that the required inequality follows from (1).
A: The following may be harder to follow than the excellent accepted answer. My excuse for posting it anyway: I hate using integration by parts on something like this, because I never feel like I shows why the inequality is "really" true. If the inequality explicitly involves derivatives, or if it's true because of cancellation then fine, integration by parts is what there is. But when everything's positive I much prefer an argument that simply keeps track of how big things are and adds the pieces.
So for example I feel that A.F.'s comment above is more illuminating than the accepted answer, even though the comment is not quite an actual proof. I can't quite say that the following is a rigorous version of that comment, but it arose from thinking about the following heuristic, which seems more or less the same as the comment:


Heuristic: It seems clear that pushing the mass of $f$ to the left decreases the integral; given the constraint $f\le M$ the function with mass as far to the left as possible is $M\chi_{(0,1/M)}$,  so (a continuous approximation to) that should minimize the integral.


Actual solution starts here:
$$\begin{aligned}\int_0^1xf(x)\,dx&\ge\int_0^{1/M}xf(x)+\frac1M\int_{1/M}^1f
\\&=\int_0^{1/M}xf(x)+\frac1M\left(1-\int_0^{1/M}f\right)
\\&=\frac1M-\int_0^{1/M}\left(\frac1M-x\right)f(x)
\\&\ge\frac1M-M\int_0^{1/M}\left(\frac1M-x\right)
\\&=\frac1{2M}.\end{aligned}$$
(Note that the final inequality above is valid because $1/M-x\ge0$ on $(0,1/M)$.)
The other inequality follows similarly. (Or you can note that the lower bound for $g(x)=f(1-x)$ implies the upper bound for $f$.)
Edit: That's still not the proof I want. It doesn't bug me the way integration by parts does, but one might argue that once we do decide to integrate by parts the rest of that proof is completely transparent: Look at what the hypothesis says about $F$ and you're done.
Here's a proof where the whole thing seems perfectly transparent, to me. We prove a nominally stronger statement, the same inequality assuming that $f$ is just measurable instead of continuous.
Let $K$ be the set of $f\in L^\infty([0,1])$ such that $0\le f\le M$ and $\int_0^1f=1$. Then $K$ is a weak* compact convex subset of $L^\infty$, so Krein-Milman shows that $K$ is the weak* closed convex hull of its extreme points. It's clear that if $f$ is an extreme point then $f=0$ or $M$ almost everywhere, so $f=M\chi_E$ with $m(E)=1/M$.
Since $f\mapsto\int xf(x)$ is linear and weak*continuous we can assume that $f=M\chi_E$ with $m(E)=1/M$. And now a formal proof that the integral is minimized for $E=I:=(0,1/M)$ is clear:
Let $A=E\cap I$, $B=E\setminus I$ and $C=I\setminus E$. Note that $m(C)=m(B)$. Hence $$\begin{aligned}\int_E x&=\int_Ax + \int_B x
\\&\ge\int_A x+\frac1Mm(B)
\\&=\int_Ax+\frac1Mm(C)
\\&\ge\int_A x+\int_Cx
\\&=\int_Ix.\end{aligned}$$
Of course that's much less elementary that either of the other two proofs, but yes, since you asked, the application of Krein-Milman does seem more  "natural" to me than integration by parts. Draw whatever conclusions you wish from that.
