Solution (source code)

= Solution

For nonzero $y$ with $G[y]>0$, the <first variation> of the <Rayleigh quotient> under $y\mapsto y+\varepsilon h$ is
$$
\delta\Lambda=\frac2{G[y]}\left\{\int_a^b[-(py')'+qy-\Lambda wy]h\,dx+[py'h]_a^b\right\}.
$$
Choose fixed admissible homogeneous <boundary conditions> that make the variation boundary term vanish, such as zero endpoint values or zero endpoint derivatives. Compactly supported $h$ then show that a stationary function satisfies the <Sturm-Liouville equation> with $\lambda=\Lambda[y]$. Conversely an <eigenfunction> satisfying those admissible conditions makes the variation zero. Multiplying its differential equation by $y$ and integrating by parts gives
$$
F[y]-[pyy']_a^b=\lambda G[y],
$$
so the stipulated energy boundary term yields $\Lambda[y]=\lambda$. The displayed energy condition alone is not a full specification of the admissible variations; it must be paired with boundary conditions for this variational equivalence.

For the final Dirichlet problem take the trial function $y=\sin x$, with $p=1,q=0,w=x$. Then
$$
\int_0^\pi y'^2dx=\frac\pi2,\qquad \int_0^\pi xy^2dx=\frac{\pi^2}4,
\qquad\boxed{\lambda_e=\frac2\pi\approx0.63662.}
$$
The <Rayleigh-Ritz variational principle> makes this an upper bound for the lowest <eigenvalue>. It is strictly above the true value: equality would require $\sin x$ itself to be a lowest <eigenfunction>, but $y''+\lambda xy=(-1+\lambda x)\sin x$ cannot vanish throughout $(0,\pi)$ for a constant $\lambda$. Therefore
$$
\boxed{\lambda_e-\lambda_t>0.}
$$
Although the weight vanishes at the left endpoint, it is positive in the interior and its weighted quadratic norm is positive for every nonzero admissible continuous function; this does not obstruct the stated Dirichlet variational comparison.