Real Mathematical Analysis Prelim problem 4.60

Presume such a function $f$ existed. Then the function $g(x)=x^2f(x)$ would be another continuous function on $[0,1]$ such that $\int_0^1 x^n g(x)dx=0$ for all $n=0,1,2\ldots$. Now, that would imply that $\int_0^1p(x)g(x)dx=0$ for every real polynomial $p$, and so, due to density of all polynomials, you would have $g(x)=0$. Thus, $f(x)=\frac{g(x)}{x^2}=0$ for $x\ne 0$. Continuity gives us $f(x)=0$ for all $x\in[0,1]$ - which is impossible, because $\int_0^1xf(x)dx=1\ne 0$.


Let $q_n\in\mathbb{R}[X]$ such that $\|f-q_n\|_{\infty}\rightarrow 0$ and let $p_n=q_n+\frac{(1-x)^{m_n}}{m_n}q_n'(0)$ where $m_n=\lfloor|q_n'(0)|+1\rfloor^2+n+1$, then $p_n'(0)=0$ for all $n$ so that $\int_0^1 p_n(x)f(x)dx=0$ for all $n$. Moreover, $\|f-p_n\|_{\infty}\leqslant\|f-q_n\|_{\infty}+\frac{|q_n'(0)|}{m_n}\rightarrow 0$ thus, $$ \int_0^1 f(x)p_n(x)dx\rightarrow\int_0^1 f(x)^2dx $$ and therefore $\int_0^1 f(x)^2dx=0$ which means that $f=0$, $f$ being continuous. This contradicts the fact that $\int_0^1 xf(x)dx=1$.