Solution (source code)

= Solution

The necessary boundary identity for a <self-adjoint operator> is
$$
\boxed{\left[p(f'^*g-f^*g')\right]_a^b=0\quad\text{for every admissible }f,g.}
$$
At regular endpoints, a standard full family of separated self-adjoint conditions is
$$
\boxed{\alpha_a y(a)+\beta_a p(a)y'(a)=0,\qquad\alpha_b y(b)+\beta_b p(b)y'(b)=0,}
$$
with real coefficients and neither pair $(\alpha_a,\beta_a)$, $(\alpha_b,\beta_b)$ zero. For example, if $\beta_a\ne0$, both functions obey $pf'=-\alpha_a f/\beta_a$ at $a$, so $pf'^*g-pf^*g'=0$ there. The cases $\beta_a=0$ and the endpoint $b$ follow directly. These include <Dirichlet boundary conditions>, <Neumann boundary conditions> and <Robin boundary conditions>.

Separate vanishing at each endpoint is sufficient but not necessary. Coupled conditions such as $y(b)=e^{i\chi}y(a)$ and $p(b)y'(b)=e^{i\chi}p(a)y'(a)$, with real $\chi$, make the two endpoint forms equal and hence their difference zero. More generally the allowed endpoint data must be a maximal subspace on which the boundary form vanishes; this ensures that the adjoint has the same domain. Merely imposing extra endpoint restrictions until the boundary term vanishes proves symmetry, but can overrestrict the domain and fail to give self-adjointness.