Solution (source code)

= Solution

Multiply
$$
\widehat w_{zz}+(l^2-k^2)\widehat w=0
$$
by $\widehat w$ and integrate from the rigid bottom to an upper endpoint $z$ at which $\widehat w\widehat w_z=0$. The bottom term also vanishes because $\widehat w(0)=0$. <Integration by parts> gives
$$
-\int_0^z\widehat w_{z'}^2\,dz'
+\int_0^z(l^2-k^2)\widehat w^2\,dz'=0.
$$
Therefore the horizontal <wavenumber> has the <Rayleigh quotient>
$$
\boxed{
k^2=
\frac{\displaystyle
\int_0^z
\left(l^2\widehat w^2-\widehat w_{z'}^2\right)dz'}
{\displaystyle\int_0^z\widehat w^2\,dz'}}.
$$
For a trapped wave the upper endpoint may be taken to infinity because the eigenfunction decays.