Using Rayleigh-Ritz Method to approximate solutions to extremum problem. 
I know how to use the Rayleigh-Ritz method when given a sturm-Liouville problem. But I am not sure where to start when asked questions like the one above. I know i need to plug the trial functions in to the integral, and then determine c, but i feel like i am supposed to be doing something else first. Any help is much appreciated. 
 A: The Galerkin-Ritz method consists in using an approximation for $y$ as
$$
y\approx \phi_n(x) = \phi_0(x)+\sum_{k=1}^n c_k\omega_k(x)
$$
with $\phi_0(x)$ obeying the boundary conditions and $\omega_k(x)$ linearly independent functions such that $\omega_k(0) = \omega_k(1)= 0$. As the BC are $y(0) = 0, y(1) = 1$ we will choose 
$$
\phi_0(x) = \frac{(1-0)}{(1-0)}(x-0)+0 = x
$$
and
$$
\omega_k(x) = (x-0)(x-1)x^k
$$
then
$$
J[\phi_n]=\int_0^1\left((\phi_n'(x))^2+x\phi_n^2(x)+2x^2\phi_n(x)\right)dx=\Phi[c]
$$
Here $\Phi[c]$ is a quadratic in $c$ and it's minimum is associated with $c_k$'s such that
$$
\frac{\partial\Phi}{\partial c_k} =0\Rightarrow  \int_0^1\left(\phi_n''(x)-x\phi_n(x)-x^2\right)\omega_k(x) dx = \phi_n'(x)\omega_k(x)|_0^1
$$
now choosing $n=3$ we have
$$
\left\{
\begin{array}{rcl}
 \frac{39 c_1}{280}+\frac{131 c_2}{1260}+\frac{199 c_3}{2520}&=&\frac{1}{15} \\
 \frac{131 c_1}{1260}+\frac{223 c_2}{2520}+\frac{509c_3}{6930}&=&\frac{1}{21} \\
 \frac{199 c_1}{2520}+\frac{509 c_2}{6930}+\frac{901 c_3}{13860}& = & \frac{1}{28} \\
\end{array}
\right.
$$
and after solving
$$
c_1= \frac{25206}{25511},\ \ c_2= -\frac{33836}{25511},\ \ c_3=
   \frac{21626}{25511}
$$
Follows the plot showing in blue the solution for
$$
y''-xy-x^2=0,\ \ \{y(0) = 0,\ y(1)=1\}
$$
and in red $\phi_3(x)$

