Let $0\leq aLet $0\leq a<b$ be real numbers. Prove that there is no continuous function $f:[a,b]\rightarrow\mathbb{R}$ such that $\int\limits_{a}^{b}f(x)x^{2n}dx>0$ and $\int\limits_{a}^{b}f(x)x^{2n+1}dx<0$ for all integer $n\geq0$.
I am trying to use weierstrss approximation theorem. But I am not getting. Please give some idea

We can give an elementary proof as follows: the change of variables $y=qx$ gives $\int\limits_{a}^{b}f(x)x^{n}dx=\frac{1}{q^{n+1}}\int\limits_{qa}^{qb}f(y/q)y^{n}dy$ so with $g(y)=f(y/q)$ one has that $\int\limits_{qa}^{qb}g(y)y^{n}dy$ has the same sign as $\int\limits_{a}^{b}f(x)x^{n}dx$ so if we choose $qb \le 1$ one can assume $b \le 1$
Let $0<c<1$ and consider the polynomial $P(x)=1+\eta-(x+\epsilon)(x-c)^2=(1+\eta-\epsilon c^2)-(c^2-2c\epsilon)x+(2c-\epsilon)x^2-x^3$ and note that for $\epsilon, \eta>0$ small enough we have that $P(c)=1+\eta,0<P(x)<1, 0<x<1, x \notin [c-\delta, c+\delta]$ for $\delta \to 0$ as $\eta, \epsilon \to 0$ and its coefficients alternate so $P(x)=a_0-a_1x+a_2x^2-a_3x^3, a_0,..a_3 >0$
Now it is easy to see by induction that $P(x)^k$ has the same properties as $P$ regarding its coefficients being alternating as the product of two polynomials with alternating coefficients has alternating coefficients
Now coming back to our problem, assume $f \ne 0$ so there is $0<c<1$ for which $f(c)=-d<0$; in particular there exists a small $\delta>0$ st $f(x)<-d/2, x \in (c-\delta, c+\delta)$ Choose $\eta, \epsilon>0$ st for the above polynomial one has  $P \ge 1$ on $[c-\delta/2, c+\delta/2]$ and $0<P<1$ outside $[c-\delta, c+\delta]$
However $\int_a^bf(x)P^k(x)>0$ is positive for all $k \ge 0$ since $P^k$ has alternating coefficients
But $|(\int_a^{c-\delta}+\int_{c+\delta}^b)f(x)P^k(x)dx| \to 0, k \to \infty$ while $\int_{c-\delta}^{c+\delta}f(x)P^k(x)<-\delta d /2$ so we get our contradiction for large $k$ and we are done!
