Find the function $\hat{g}$ that maximizes $\int_0^1 x^2g(x)dx$ over the set of all functions that satisfy the following conditions:
$\int_0^1 |g(x)|^2dx =1$, $\int_0^1 g(x)dx=0$, and $\int_0^1xg(x)dx=0$.
Any solutions or hints are greatly appreciated. I've been stuck on this for a bit. I'm not sure how to find $\hat{g}$. I know the following, but I don't know if it's useful:
$||x\sqrt{g(x)}||^2$ =$<x\sqrt{g(x)}, x\sqrt{g(x)}>=\int_0^1x^2g(x)dx$.
Since $\int_0^1\,g(x)\,\text{d}x=0$ and $\int_0^1\,x\,g(x)\,\text{d}x=0$, we have $$\int_0^1\,x^2\,g(x)\,\text{d}x=\int_0^1\,\left(x^2-x+\frac{1}{6}\right)\,g(x)\,\text{d}x\leq\int_0^1\,\left|x^2-x+\frac{1}{6}\right|\,\big|g(x)\big|\,\text{d}x\,.$$ By the Cauchy-Schwarz Inequality, $$\int_0^1\,x^2\,g(x)\,\text{d}x\leq\int_0^1\,\left|x^2-x+\frac{1}{6}\right|\,\big|g(x)\big|\,\text{d}x \leq \sqrt{\int_0^1\,\left|x^2-x+\frac{1}{6}\right|^2\,\text{d}x}\sqrt{\int_0^1\,\big|g(x)\big|^2\,\text{d}x}\,.$$ From $\int_0^1\,\big|g(x)\big|^2\,\text{d}x=1$, we conclude that $$\int_0^1\,x^2\,g(x)\,\text{d}x\leq \sqrt{\int_0^1\,\left(x^2-x+\frac{1}{6}\right)^2\,\text{d}x}=+\frac{1}{6\sqrt{5}}\,.$$ The equality holds if and only if $g(x)=+6\sqrt{5}\left(x^2-x+\frac{1}{6}\right)=+\sqrt{5}\left(6x^2-6x+1\right)$ for almost every $x\in[0,1]$ (which coincidentally satisfies all three required conditions).
Similarly, $\int_0^1\,x^2\,g(x)\,\text{d}x\geq-\frac{1}{6\sqrt{5}}$. The inequality becomes an equality if and only if $g(x)=-6\left(x^2-x+\frac{1}{6}\right)=-\sqrt{5}\left(6x^2-6x+1\right)$ for almost every $x\in[0,1]$.
How did I find $f(x)=x^2-x+\frac{1}{6}$?
Well, I wanted a quadratic function $f(x)=x^2+ax+b$ for $x\in[0,1]$ such that $\int_0^1\,f(x)\,\text{d}x=0$ and $\int_0^1\,x\,f(x)\,\text{d}x=0$. Hence, I had to solve the simultaneous system of equations $\frac{1}{3}+\frac{1}{2}a+b=0$ and $\frac{1}{4}+\frac{1}{3}a+\frac{1}{2}b=0$, which would give $a=-1$ and $b=\frac{1}{6}$.