proof verification for an integral inequality Problem: Let $f(x)$ be a continuous function on $[a,b]$, such that $|f(x)|\leq M$ and $\int_a^b f(x)dx = 0$. Prove that $$|\int_a^b xf(x)dx| \leq \frac{M}{4}(b-a)^2.$$
Can anyone help verify my proof? Here are my own attempts:
My attempt: Write $I_a(x) = \int_a^xf(t)dt$,$\,$ $I_b(x) = \int_b^xf(t)dt$,$\,$ and denote by $c$ the midpoint $\frac{a+b}{2}$ of the inteval $[a,b]$.
We can see that
$$\int_a^cxf(x)dx = \int_a^cxI_a^{'}(x)dx = cI_a(c) - aI_a(a) - \int_a^cI_a(x)dx = cI_a(c) - \int_a^cI_a(x)dx.$$
For the same reason
$$\int_b^cxf(x)dx = cI_b(c) - \int_b^cI_b(x)dx.$$
So the left hand side of the original inequality can be written as
$$|\int_a^bxf(x)dx| = |\int_a^cxf(x)dx - \int_b^cxf(x)dx|\\ = |c(I_a(c)-I_b(c))+\int_b^cI_b(x)dx-\int_a^cI_a(x)dx| \\= |\int_b^cI_b(x)dx-\int_a^cI_a(x)dx|$$
since
$I_a(c)-I_b(c) = \int_a^bf(x)dx = 0$.
$\int_b^yI_b(x)dx$ can be viewed as a function $\Phi_b(y)$ of $y$. By Taylor formula,
$$\Phi_b(y) = \Phi_b(b) + \Phi_b^{'}(b)(y-b)+\frac{1}{2}\Phi_b^{''}(\theta_2)(y-b)^2 \\ = 
\frac{1}{2}f(\theta_2)(y-b)^2$$ where $\theta_2 \in (y,b)$. Let $y = c$ we have $\int_b^cI_b(x)dx = \frac{1}{2}f(\theta_2)(\frac{b-a}{2})^2$ and $\theta_2 \in (c, b)$.
By a similar argument $\int_a^cI_a(x)dx = \frac{1}{2}f(\theta_1)(\frac{b-a}{2})^2$, where $\theta_1 \in (a,c)$. So $$|\int_a^bxf(x)dx| = |\int_b^cI_b(x)dx-\int_a^cI_a(x)dx| \\= \frac{1}{2}(\frac{b-a}{2})^2|f(\theta_1) - f(\theta_2)| \\ \leq \frac{1}{2}(\frac{b-a}{2})^2(|f(\theta_1)| + |f(\theta_2)|) \\ \leq \frac{1}{2}(\frac{b-a}{2})^2(2M)  = \frac{M}{4}({b-a})^2$$ because $|f(\theta_i)|\leq M$.
 A: Taylor's formula is not needed here.
$$
 \int_a^b xf(x) \, dx = \int_a^b (x-c)f(x) \, dx
$$
holds for any real $c$. Chosing $c=(a+b)/2$ – as you did – then gives
$$
\left|\int_a^b xf(x) \, dx\right| \le M \int_a^b |x-\frac{a+b}{2}| \, dx = M \frac{(b-a)^2}{4} \, .
$$

Remark: For continuous functions $f$ which are not identically zero the inequality is strict.  The reason is that equality would hold only if $(x-c)f(x)$ does not change its sign and $|f(x)|$ is constant on $[a, b]$, and that is not possible.
However, the upper bound is sharp, as can be seen by considering continuous functions which are equal to $-M$ on $[a, c-\epsilon]$ and equal to $+M$ on $[c+\epsilon, b]$.

Comparison with your proof: You estimate
$$
 \Phi_a(c) = \int_a^y I_a(x) \, dx = \int_a^c \int_a^x f(t) \, dt dx = \int_a^c (c-t) f(t) \, dt
$$
with Taylor's formula: $\Phi_a(a) = \Phi_a'(a) = 0$, $|\Phi_a''(y)| = |f(y)| \le M$, whereas the above approach estimates
$$
 |\Phi_a(c)| \le M \int_a^y (c-t)\, dt = M \frac{(c-a)}{2} \, ,
$$
Similarly for the other contribution $\Phi_b(c)$.
