Solution (source code)

= Solution

Multiply the <eigenvalue equation> of the <Sturm-Liouville problem> by $y$ and integrate. <Integration by parts> gives
$$
\lambda\int_a^b\omega y^2\,dx=\int_a^byLy\,dx=-[pyy']_a^b+\int_a^b\big[p(y')^2+qy^2\big]dx.
$$
Since $y$ is a nonzero <eigenfunction> and $\omega>0$, the denominator is strictly positive. Thus the <Rayleigh quotient> is
$$
\boxed{\lambda=\frac{\displaystyle\int_a^b[p(y')^2+qy^2]dx-[pyy']_a^b}{\displaystyle\int_a^b\omega y^2\,dx}.}
$$
The endpoint term must be retained for a general <Robin boundary condition>; it vanishes for homogeneous <Dirichlet boundary conditions> but need not vanish in the present general problem.