Existence of a certain continuous function on the unit interval Here's a question from an old qualifying exam. Does there exist a continuous function $f : [0,1] \to \mathbb{R}$ such that $\int_0^1 xf(x) \ \mathrm{d}x = 1$ and $\int_0^1 x^nf(x) \ \mathrm{d}x = 0$ for all $n > 1$?
 A: Let $f$ be such a function. By Müntz-Sázsz theorem the identity function $\mathit{id}$ can be uniformly approximated in $[0,1]$ by polynomials $p_n$ not containing linear term. In particular $p_nf\to\mathit{id}\,\cdot f$ uniformly on $[0,1]$, and so $$\int_0^1p_n(x)f(x)\,dx=p_n(0)\int_0^1f(x)\,dx\xrightarrow{n\to\infty}\int_0^1xf(x)\,dx=1\,;$$ but $p_n(0)\xrightarrow{n\to\infty}\mathit{id}(0)=0$, which is a contradiction. Therefore no such function $f$ exists.
A: If there exists a sequence of even polynomials $(P_n)$ such that $P_n(0) = 0$ and $P_n$ converges uniformly to $i(x) = x$ on $[0,1]$ then we are done. 
Since each such non-zero $P_n$ is a linear combination of  $x^{2n}$ with $ n \geq 1$, $$\int_{0}^{1} f(x)P_n(x) dx = 0,\quad\quad\quad (1)$$ 
and since $ x - P_n(x) $ converges uniformly to $0,$
$$\int_{0}^{1} ( x - P_n(x) ) f(x) dx \to 0.\quad\quad\quad (2)$$
$(1)$ and $(2)$ imply $\int_{0}^{1} x f(x)dx = 0 ,$ a contradiction.
Such polynomials are constructed in exercise 23 of chapter 7 of Baby Rudin by the rule:
$P_0(x) = 0$ and $P_{n+1}(x) = P_n(x) + \dfrac{x^2 - P_n^2(x)}{2}.$ 
Clearly, $P_n(0) = 0$ and $P_n$ is even for all $n$ by construction. 
The rest of the proof consists of a solution of Rudin's exercise following his hints.
Consider the statement $0 \leq P_n(x) \leq x$ for all $x \in [0,1].$ This is obviously correct for $n=0$, and if this statement is valid for some $k \geq 0$, 
$$x - P_{k+1}(x) = \left( x- P_k(x) \right) \left( 1 - \frac{ x + P_k(x) }{2}\right),\quad\quad\quad(3)$$ 
and since $0\leq\dfrac{ x + P_k(x) }{2}\leq x \in [0,1]$ and the second term in the product in the RHS also lies in $[0,1]$. The statement is true for all $n$ by induction. 
From (3) it also follows for $x \in [0,1]$ 
$$0 \leq x - P_{k+1}(x) \leq \left( x- P_k(x) \right) \left( 1 - \frac{x}{2}\right),$$ hence for $n \geq 1$ and all $ x\in [0,1]$, $$0 \leq x - P_n(x) \leq x ( 1 - \frac{x}{2} )^{n}.$$ Let $g_n(x) = x ( 1 - \frac{x}{2} )^{n} $, the maximum of $g_n$ on $[0,1]$ cannot occur at $0$ for any $n$, also, $ \frac{n}{2}g_n(2/n) \to \text{e}^{-1} $ and $g_n(1) = \frac{1}{2^n}$, so $ g_n(1)/g_n(2/n) \to 0$ hence $g_n(1) < g_n(2/n)$ for sufficiently large $n$ and for such $n$ the maximum of $g_n$ cannot occur at $1$. Hence the maximum of $g_n$  for large $n$ occurs at a $m_n \in (0,1)$ with $g_n^{'}(m_n) = 0$, i.e, $m_n = \frac{2}{n+1}$. Since $g_n(x) \leq x$ for $x \in [0,1]$ we have
$$ 0 \leq x - P_n(x) \leq \frac{2}{n+1},$$ for all sufficiently large n. Hence the convergence of $P_n$ to the  identity is uniform. 
A: This answer was inspired by Justin's comment on Matemáticos's answer, looking for a way to use the Weierstrass approximation theorem and not one of its generalizations.  A direct consequence of the Weierstrass approximation theorem is that continuous functions on $[0,1]$ can be uniformly approximated by even polynomials.
To see this, let $g:[0,1]\to\mathbb R$ be continuous, and define $h:[-1,1]\to\mathbb R$ to be the even extension of $g$, so $h(x)=g(|x|)$.  By the Weierstrass approximation theorem, there is a sequence of polynomials $(p_n)_n$ converging uniformly to $h$ on $[-1,1]$.  Then the sequence of polynomials $q_n(x)=\frac{1}{2}(p_n(x)+p_n(-x))$ converges uniformly to $\frac{1}{2}(h(x)+h(-x))=h(x)$ on $[-1,1]$ and hence the sequence $(q_n)_n$ of even polynomial functions converges uniformly to $g$ on $[0,1]$.
If you have $g(0)=0$ (for example if $g(x)=x$), then you can also choose the polynomials to have $0$ constant term, e.g., by replacing $q_n$ with $q_n(x)-q_n(0)$ if needed and then reassigning notation to still call the result $q_n$. In that case, with $f$ as in the problem, $\int_0^1 q_n(x)f(x)dx=0$ for all $n$, which implies $\int_0^1g(x)f(x)dx =0$.
