Is there a function $g$ such that $\int_0^1 x^n g(x) \, \mathrm d x$ is $1$ if $n=0$ and $0$ for $n \in \mathbb N_{\ge 1}$? Is there a function $g:[0,1]\to \mathbb R$ such that $$\int_0^1 x^n g(x) \, \mathrm d x$$ is equal to $1$ if $n=0$ and equal to $0$ for $n=1,2,3, \ldots$ ?
If there is, what would be an example of such a function? What if we require that $g$ be continuous?
I know I am expected to state what I have tried but I am honestly stuck. I wanted to integrate by parts but given that $g$ is not differentiable, this is rather useless, I think. Hints would be appreciated too.
 A: Let $g$ be a Lebesgue-integrable function on $[0, 1]$. Assume that there exists $N \geq 0$ such that
$$ \forall n \geq N \ : \ \int_{0}^{1} x^n g(x) \, dx = 0. $$
Then we prove the following claim.

Claim. $g$ vanishes almost everywhere. Consequently, $\int_{0}^{1} x^n g(x) \, dx = 0$ for all $n \geq 0$.

Proof. For each $\varphi$ in the set $C([0, 1])$ of all continuous functions on $[0, 1]$, Stone-Weierstrass theorem allows to find a sequence $p_n$ of polynomials such that $p_n(x) \to \varphi(x)$ uniformly on $[0, 1]$. This implies
$$ \forall \varphi \in C([0, 1]) \ : \ \int_{0}^{1} x^N \varphi(x) g(x) \, dx = 0. $$
Now for any $0 < a < b < 1$, we may choose $0 \leq \varphi_n(x) \uparrow x^{-N} \mathbf{1}_{[a, b]}(x)$, thus by the dominated convergence theorem, we have
$$ \forall 0 < a < b < 1 \ : \ \int_{a}^{b} g(x) \, dx = 0. $$
This is enough to show that $g \equiv 0$ a.e. on $[0, 1]$ as required.
A: There is no continuous function with this property: $\int p(x) (xg(x))\, dx =0$ for all polynomials $p$ so Weierstrass theorem tells you that $\int  (xg(x))^{2}\, dx =0$  from which you get $g \equiv 0$ . So the integral is $0$ for $n=0$ also. Actually, continuity is not required. Using the fact that $xg(x)$ can be approximated in $L^{1}$ norm by continuous functions (hence by polynomials) you can show, by a similar argument, that $xg(x)=0$ almost everywhere which forces the integral to be $0$ for $n=0$. Hence there is no such function as long as the integrals in he question exist for all $n \geq 1$.
A: Assuming $g\in L^2(0,1)$ we are allowed to write
$$ g(x) \stackrel{L^2}{=} \sum_{n\geq 0} c_n P_n(2x-1),\qquad c_n=(2n+1)\int_{0}^{1}g(x)P_n(2x-1)\,dx.$$
Our constraints give $c_0=1$ and
$$ c_n = (2n+1)\int_{0}^{1}g(x)\left[(-1)^n+x q_n(x)\right]\,dx = (-1)^n (2n+1) $$
so, formally,
$$ g(x) \stackrel{L^2}{=}\sum_{n\geq 0}(-1)^n (2n+1) P_n(2x-1) $$
but the RHS of the last line is not a square-integrable function over $(0,1)$:
$$ \int_{0}^{1}\left[\sum_{n\geq 0}(-1)^n (2n+1) P_n(2x-1)\right]^2\,dx = \sum_{n\geq 0}\frac{1}{2n+1}=+\infty $$
so there are no solutions in $L^2(0,1)$. A fortiori, no continuous solutions.
