Finding all measurable functions maximizing an expression given integral conditions I'd like to know how to answer the question located in this comprehensive exam from the 1990s. The question is:

Find the maximum value of $\int_{-1}^{1} x^3 g(x) dx$ for measurable functions g(x) satisfying
$$ \int_{-1}^{1} g(x) dx = \int_{-1}^{1} x g(x) dx = \int_{-1}^{1} x^2 g(x) dx = 0 . $$
and $\int_{-1}^{1} |g(x)|^2 dx = 1$.

In principle I think I could reduce to the case where $g$ is continuous, and then even smooth/polynomial, and try to formulate things as some kind of optimization problem, but I suspect there's some sort of trick I'm not aware of.

We have four conditions. Define
$$
g(x) = a_0+a_1 x+ a_2 x^2+ a_3 x^3
$$
and then calculate
$$
\int_{-1}^1 g(x)dx = 2\left(a_0+\frac 13 a_2\right)=0\\
\int_{-1}^1 g(x)x dx = 2\left(\frac 13 a_1+\frac 15 a_3\right) = 0\\
\int_{-1}^1 g(x)x^2 dx =2\left(\frac 13 a_0 +\frac 15 a_2\right) = 0\\
\int_{-1}^1 |g(x)|^2 dx = 2 a_0^2+\frac{4 a_0 a_2}{3}+\frac{2 a_1^2}{3}+\frac{4 a_1a_3}{5}+\frac{2 a_2^2}{5}+\frac{2
   a_3^2}{7}=1
$$
and solving we have
$$
\left[
\begin{array}{cccc}
a_0 & a_1 & a_2 & a_3 \\
 0 & -\frac{3 \sqrt{\frac{7}{2}}}{2} & 0 & \frac{5 \sqrt{\frac{7}{2}}}{2} \\
 0 & \frac{3 \sqrt{\frac{7}{2}}}{2} & 0 & -\frac{5 \sqrt{\frac{7}{2}}}{2} \\
\end{array}
\right]
$$
and the maximum is $\frac{5}{\sqrt{14}}-\frac{3 \sqrt{\frac{7}{2}}}{5}$
