Is there a contradiction in this definite integral computation? EDIT:
This question is wrong. You don't need to waste your time trying to answer it. :D

I need help showing that:
$$ \int_a^b x f(x) dx = \frac {a+b} 2\int_a^bf(x)dx$$
My attempt.
$$ I = \int_a^bxf(x)dx = \int_a^b(b+a -x)f(b+a-x)dx $$ 
$$ = \int_a^b (b+a)f(b+a-x)dx - \int_a^bxf(b+a-x)dx $$
I doubt that probably the 2nd term is $I$ itself (though not sure). Hints?
Btw, the reason I am asking this is, if the above stated theorem is true, then how come there be a contradiction between it and this question? You see, the question is of the same form. But in that case, the integral of $f(x) = \cfrac {\cos x} {1 + \sin^2x}$ from 0 to $\pi$ is 0.
Interestingly, the above stated theorem works for $$ \int \limits_0^\pi \cfrac {x \sin x} {1 + \cos^2x} dx $$
 A: A counterexample:  $a=0$, $b=1$ and $f(x)=x$. Then
$\int_0^1 x^2 dx = \frac{1}{2} \int_0^1 x dx$
iff $\frac{1}{3}=\frac{1}{4}$. 
A: My suspicion is that this integral is true only for certain $f$. Take $f(x) = \dfrac{1}{b-a}$. In Probability, we refer to this specific $f$ as the density function for the continuous uniform distribution and $\int\limits_{a}^{b}\dfrac{x}{b-a} \text{ dx} = \dfrac{a+b}{2}$ as the expected value of the continuous uniform distribution. Also, for any density function, $\int\limits_{a}^{b}f(x) \text{ dx} = 1$, so we get $\int\limits_{a}^{b}xf(x) \text{ dx} = \dfrac{a+b}{2} * 1$, which is assuming that $f(x) = \dfrac{1}{b-a}$.
EDIT: Of course, the expected value of other density functions will NOT always be $\dfrac{a+b}{2}$. 
A: If $f$ is non-negative and $\int_a^bf(x)\,dx\neq0$, then we can regard 
$$
\frac{f(x)}{\int_a^bf(x)\,dx}
$$
as a probability distribution on the interval $[a,b]$, and the equation in the question just says that the average of this distribution is the midpoint of the interval.  That's fine for symmetrical distributions (like those mentioned in answers and comments above) and for some others, but it's "usually" false.
