Prove that there is a function $w > 0$ such that $\int_{0}^{1}w(x) dx \neq 0$ and $\frac{\int_{0}^{1}w(x)x^{2}dx}{\int_{0}^{1}w(x)dx} = \frac{1}{2}$? I can see that $w(x) := x$ on $]0, \infty[$ suffices, but I am after a systematic analysis to see this, which I am incapable to do.
 A: For a broad class of function, let 
$w(x)=\sum_{k=0}^\infty w_kx^k$ 
so that
$\int_0^1 w(x)\,x^m=\sum_{k=0}^\infty \frac{1}{k+m+1}w_k.$
Multiplying by the denominator integral of your condition equation, $\frac{1}{2}\frac{1}{k+1}$ is popping up on the left hand side. So you need to solve
$\sum_{k=0}^\infty \left(\frac{1}{k+m+1}-\frac{1}{k+(k+1)+1}\right)w_k=0$
for $w_k$'s.
The term with $k=m-1$ is zero for free, so $w_{m-1}$ is without condition. For your case of $m=2$, you might set all other $w_k\neq w_1$ zero and find your solution of $w(x)=w_1x$.

Answer to the comment: 
Here is another example solution obtained via the above formulation. 
Just set 
$w_k=\dfrac{(-1)^k}{\frac{1}{k+m+1}-\frac{1}{k+(k+1)+1}}$ 
and sum up an even number of terms. (Ensuring positivity will be more work.)
For example, the solution for 
$0+0+0+1-1+1-1=0$ 
obtained this way is $w(x)=-378 x^6+360 x^5-350 x^4+360 x^3$.
(I've multiplied by $-15$ to make all coefficients integers.)

A: Try $w(x)=x^2+a$. One adjustable parameter is enough.
$$\int_0^1(x^2+a)x^2\,dx=\frac15+\frac a3,$$
$$\int_0^1(x^2+a)\,dx=\frac13+a$$
then
$$\frac15+\frac a3=\frac16+\frac a2.$$
Solution:
$$w(x)=x^2+\frac15.$$
A: This is sort of a linear algebra problem.
Consider the vector space of square-integrable functions on $[0,1]$ with the inner product $\left<f,g\right> = \int_0^1 f(x)g(x)\,\mathrm dx$. You are basically looking for a function $w$ such that $$\frac {\left<w,a\right>}{\left<w,b\right>} = \frac 1 2$$
where $a(x)=x^2$ and $b(x)=1$. Note that $$\left<a,a\right> = \int_0^1x^4\,\mathrm dx=\frac 15\\\left<a,b\right> = \int_0^1 x^2\,\mathrm dx=\frac 1 3\\\left<b,b\right> = \int_0^11\,\mathrm dx =1$$
Let's guess that we can satisfy this with a linear combination of $a$ and $b$, that is, $w = \alpha a + \beta b$. Then we get$$\left<w,a\right> = \alpha\left<a,a\right> + \beta\left<a,b\right> = \frac 15 \alpha + \frac 1 3 \beta\\\left<w,b\right> = \alpha\left<a,b\right> + \beta\left<b,b\right> = \frac 1 3 \alpha + \beta$$
Okay, so you want $$\frac{\frac 1 5\alpha + \frac 1 3 \beta}{\frac 1 3 \alpha +  \beta} = \frac 1 2$$ i.e. $$\alpha = 5\beta$$ and that's it. Choose, for example, $\alpha = 1, \beta = 5$. Of course, other functions can be chosen.
A: We can use $w(x)=\alpha x^{\alpha-1}$ for $\alpha\gt0$. Then
$$
\int_0^1w(x)\,\mathrm{d}x=1
$$
and
$$
\int_0^1w(x)\,x^2\,\mathrm{d}x=\frac{\alpha}{\alpha+2}
$$
By adjusting $\alpha\gt0$, we can get
$$
\frac{\int_0^1w(x)\,x^2\,\mathrm{d}x}{\int_0^1w(x)\,\mathrm{d}x}=\frac{\alpha}{\alpha+2}
$$
to be anything in $(0,1)$.
A: Not a rigorous answer (without putting in extra work, at least), but IMO a good way to convince yourself that there must indeed be such a function. To my mind, this argument (when suitably formalized) is actually more satisfying than just an example of such a function:


*

*On the one hand ($w(x)=1$) we have ${\int_0^1x^2dx\over \int_0^1 1dx}={1\over 3}<{1\over 2}.$

*On the other hand ($w(x)=x^{100}$) we have ${\int_0^1x^{102}dx\over\int_0^1x^{100}dx}={{1\over 103}\over {1\over 101}}>{1\over 2}$. (How did we know to choose something like this for $w$? Well, first of all polynomials are easy to integrate; second, polynomials with high exponent are "very far" from constant functions, and we already did a constant function. This same reasoning could have also led us to try $w(x)=e^x$, but $x^2e^x$ is annoying to integrate.)

*So now we apply a kind of intermediate value theorem: if we imagine continuously deforming the function $x\mapsto 1$ into the function $x\mapsto x^{100}$, at some point we should get a $w$ satisfying the desired formula.
Of course, all the meat is hidden in this last step - how do we know that the function $w\mapsto {\int_0^1x^2w(x)dx\over \int_0^1 w(x)dx}$ is continuous on the relevant space of functions? and how do we know that space is connected? - so this isn't a proof at all. But it's a good plausibility argument.

OKAY FINE technically these don't really satisfy the demand "$w(x)>0$" since in all the examples above, $w(0)=0$; but this is easily dealt with.
A: How about


*

*$w(x)=\frac{b}{\sqrt{1-x^2}}$ for $b>0$

*$w(x)=\frac{6x-5x^3}{\sqrt{1-x^2}}$

*$w(x)=\frac{1+10x^2-10x^4}{\sqrt{1-x^2}}$


And also note that for $\displaystyle w_n(x)=\frac{(x+\sqrt{1-x^2})^n-(x-\sqrt{1-x^2})^n}{\sqrt{1-x^2}}$ we have that $$\int_0^1w_{2n}(x)(x^2-\frac12)dx=0 , n=1,2,3,...$$ and $$\int_0^1w_{2n-1}(x)(x^2-\frac12)dx=-\frac{1}{2n+3}, n=1,2,3,...$$
implying that 
$$\frac{\int_0^1x^2w_{2n}(x)dx}{\int_0^1w_{2n}(x)dx}=\frac12.$$
Note that $w_{2n}(x)$ is positive on the interval of integration.
