Condition for Self-Adjoint Sturm-Liouville Operator Consider the Sturm-Liouville operator $$L(u) = -(pu')' + qu$$ where, $p \in C^1[a,b]$ and $q \in C[a,b]$ with $p(t) \neq 0$ for $t \in [a,b]$ are complex valued functions, with boundary conditions: \begin{align*}\alpha u(a) + \beta u'(a) = 0 \\ \gamma u(b) + \delta u'(b) = 0\end{align*} where, $\alpha, \beta, \gamma, \delta \in \mathbb{C}$.

Prove that the operator is self-adjoint iff $p,q$ are real valued and $\alpha \overline{\beta} = \overline{\alpha} \beta$, $\gamma \overline{\delta} = \overline{\gamma} \delta$ (i.e., requiring $\alpha, \beta, \gamma, \delta$ to be real valued.)

If the boundary conditions and $p,q$ are real valued then clearly $L$ is self-adjoint, i.e., $\displaystyle \int_a^b L(u) \overline{v} = \int_a^b u\overline{L(v)}, \quad \forall u,v \in C^2[a,b]$ satisfying the boundary conditions, which can be verified by simply integration by parts. It's proving the converse that I'm having trouble with. (This is Exercise 1 of Chapter 7 in Coddington-Levinson).
 A: As a first step, we get rid of the boundary terms arising in the integration by parts by considering only $u,v$ vanishing at least of second order at $a$ and $b$. Then, assuming $L$ is self-adjoint, from the integration by parts we find that
$$\int_a^b (qu - (pu')')\overline{v}\,d\lambda = \int_a^b (\overline{q} u - (\overline{p} u')')\overline{v}\,d\lambda\tag{1}$$
for all eligible $u,v$, and hence
$$qu - (pu')' \equiv \overline{q}u - (\overline{p}u')'\tag{2}$$
on $[a,b]$. (If the two sides of $(2)$ were not identical for some eligible $u$, we could find a nonnegative $v\in C^2[a,b]$ with support in a subinterval of $(a,b)$ where e.g. the real part of the left hand side is strictly greater than the real part of the right hand side, and such a pair of functions would violate $(1)$, contradicting the self-adjointness of $L$.)
Considering only real-valued $u$ in $(2)$, it follows that
$$ru - (su')' \equiv 0\tag{3}$$
for such $u$, where $r = \operatorname{Im} q$ and $s = \operatorname{Im} p$. Since $s(a)u'(a) = 0 = s(b)u'(b)$ for all eligible $u$, integration of $(3)$ yields
$$\int_a^b r(t)u(t)\,dt = 0\tag{4}$$
for all such $u$, and hence $r \equiv 0$, that is the real-valuedness of $q$ (otherwise, similar to the above, we could find a nonnegative $u$ with support in a subinterval of $(a,b)$ where $r$ is strictly positive or strictly negative, violating $(4)$). Plugging that into $(3)$, we find that $s\cdot u'$ must be constant for all eligible $u$, and since $u'(a) = 0$ then, we further obtain $s\cdot u' \equiv 0$ for all eligible $u$. Since for every $t\in (a,b)$ we can find an eligible $u$ with $u'(t)\neq 0$, it follows that $s\equiv 0$ on $(a,b)$, and by continuity on $[a,b]$. Thus $p$ must also be real-valued.
Having established that $p$ and $q$ must be real-valued if $L$ is self-adjoint, we finally look at the boundary conditions. Two integrations by part yield
\begin{align}
\int_a^b u(p\overline{v}')'\,d\lambda &= u(p\overline{v}')\biggr\rvert_a^b - \int_a^b u'(p\overline{v}')\,d\lambda \\
&= u(p\overline{v}')\biggr\rvert_a^b - (pu')\overline{v}\biggr\rvert_a^b + \int_a^b (pu')'\overline{v}\,d\lambda,
\end{align}
and the self-adjointness of $L$ means the boundary terms cancel, i.e. we have
$$u(b)p(b)\overline{v'(b)} - u(a)p(a)\overline{v'(a)} = u'(b)p(b)\overline{v(b)} - u'(a)p(a)\overline{v(a)},$$
or, after rearranging,
$$p(b)\bigl(u(b)\overline{v'(b)} - u'(b)\overline{v(b)}\bigr) = p(a)\bigl(u(a)\overline{v'(a)} - u'(a)\overline{v(a)}\bigr)\tag{5}$$
for all $u,v\in C^2[a,b]$ satisfying the boundary conditions. Let $w \colon [a,b] \to [0,1]$ be a smooth function with $w(t) = 0$ for $t \leqslant \frac{2a+b}{3}$ and $w(t) = 1$ for $t \geqslant \frac{a+2b}{3}$. Then if $u\in C^2[a,b]$ satisfies the boundary conditions, so do $w\cdot u$ and $(1 - w)\cdot u$, and replacing $u$ with $w\cdot u$ resp. $(1-w)\cdot u$ we see that $(5)$ can only hold if
$$u(b)\overline{v'(b)} = u'(b)\overline{v(b)}\quad\text{and}\quad u(a)\overline{v'(a)} = u'(a)\overline{v(a)}$$
for all $u, v \in C^2[a,b]$ satisfying the boundary conditions. In particular, taking $v = u$, it follows that $u'(a)\overline{u(a)}, u'(b)\overline{u(b)} \in \mathbb{R}$ for all admissible $u$. If $\alpha = 0$ or $\beta = 0$, the condition $\alpha\overline{\beta} = \overline{\alpha}\beta$ trivially holds, and if $\alpha\beta \neq 0$, the boundary condition yields
$$\alpha\overline{\beta} \lvert u(a)\rvert^2 = - \lvert\beta\rvert^2 u'(a)\overline{u(a)}$$
after multiplication with $\overline{\beta u(a)}$. Choosing $u$ with $u(a) \neq 0$ then yields $\alpha\overline{\beta} \in \mathbb{R}$. The argument for $\gamma\overline{\delta} \in \mathbb{R}$ is the same.
