Let $a,b>0$,$f\in C[-a,b]$,$f>0$,$$\int_{-a}^{b} xf(x)dx=0,$$then prove that $$\int_{-a}^{b} x^2f(x)dx\leq ab\int_{-a}^{b}f(x)dx,$$
I have tried with the $$\int_{-a}^{b} x^2f(x)dx=\varepsilon^2\int_{-a}^{b}f(x)dx,$$but it doesn't work because I can't compare the value of the ab with the $\varepsilon$,And I don't how to use the condition"f is continuous" by this method.
For any $x\in[-a,b]$, we have $$ab-x^2+(b-a)x=(x+a)(b-x)\geq 0\,.$$ For any continuous function $f:[-a,b]\to\mathbb{R}$ such that $f(x)\geq 0$ for all $x\in[-a,b]$, we then have $$\big(ab-x^2+(b-a)x\big)\,f(x)\geq 0$$ for every $x\in[-a,b]$. Therefore, $$\int_{-a}^b\,\big(ab-x^2+(b-a)x\big)\,f(x)\,\text{d}x\geq 0\,.$$ This means $$ab\,\int_{-a}^b\,f(x)\,\text{d}x-\int_{-a}^b\,x^2\,f(x)\,\text{d}x+(b-a)\,\int_{-a}^b\,x\,f(x)\,\text{d}x\geq 0\,.$$ If $\displaystyle\int_{-a}^b\,x\,f(x)\,\text{d}x=0$, then it follows that $$ab\,\int_{-a}^b\,f(x)\,\text{d}x-\int_{-a}^b\,x^2\,f(x)\,\text{d}x\geq 0\,,$$ which is equivalent to the inequality to be proven. (The equality holds if and only if $f\equiv 0$.)
Remark. The same claim holds if $f:[-a,b]\to\mathbb{R}_{\geq 0}$ is Riemann- or Lebesgue-integrable, and satisfies $\displaystyle\int_{-a}^b\,x\,f(x)\,\text{d}x=0$. The equality holds if and only if $f=0$ almost everywhere. If $f$ is a distribution, however, then the equality case is when $f(x)$ is a scalar multiple of $b\,\delta(x+a)+a\,\delta(x-b)$, where $\delta$ is the Dirac $\delta$-distribution.