Solution (source code)

= Solution

Set
$$
r=\tan\theta=\frac{\omega}{\sqrt{N^2-\omega^2}},
\qquad
s=\frac{H_0}{L},
$$
where $r$ is the magnitude of the <internal-wave ray> slope and $s$ is the bottom slope. A rightward ray remains in the triangular basin precisely when its bottom reflection is <subcritical internal-wave reflection>, namely $r>s$. Therefore
$$
\boxed{\frac{NH_0}{\sqrt{L^2+H_0^2}}<\omega<N.}
$$

Conservation of frequency and of the component of the <wavevector> tangent to the slope gives the <focusing power of internal-wave reflection>
$$
\boxed{\gamma=\frac{k_{\rm r}}{k_{\rm i}}
=\frac{\sin(\theta+\alpha)}{\sin(\theta-\alpha)}
=\frac{r+s}{r-s}
=\frac{L\omega+H_0\sqrt{N^2-\omega^2}}
{L\omega-H_0\sqrt{N^2-\omega^2}},}
$$
where $\tan\alpha=s$. In this range $\gamma>1$, so the reflected <wavelength> is shorter by the factor $\gamma$. The reflected normal <group velocity> is smaller by $\gamma^2$; conservation of normal <energy flux> therefore increases the wavelength-averaged <energy density> by
$$
\boxed{\overline E_{\rm r}=\gamma^2\overline E_{\rm i}.}
$$