<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.wikiwaves.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Slawrence</id>
	<title>WikiWaves - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.wikiwaves.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Slawrence"/>
	<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php/Special:Contributions/Slawrence"/>
	<updated>2026-04-17T23:30:22Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8535</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8535"/>
		<updated>2009-01-09T04:09:09Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Solution using Separation of Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
M_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\zeta \right) = -\kappa^{2}\zeta \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\zeta \mid_0 = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\zeta \mid_1 = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\zeta = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u |_0 = u |_1 = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u|_0=u|_1=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k|_0=u_k|_1=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; \zeta=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; \zeta |_0=a \quad \zeta |_1=b &amp;lt;/math&amp;gt; and, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt; explicitly differentiating &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; gives &amp;lt;math&amp;gt; \partial_x \zeta |_0 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \partial_x |zeta |_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim here is to construct a matrix &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; such that, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; S \begin{pmatrix} \zeta |_0 \\ \zeta |_1 \end{pmatrix}=\begin{pmatrix} \partial_x \zeta |_0 \\ \partial_x \zeta |_1 \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking &amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt;  to give &amp;lt;math&amp;gt; \zeta_1 &amp;lt;/math&amp;gt; shows that the first column of &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; must be &amp;lt;math&amp;gt; \begin{pmatrix} \partial_x \zeta_1 |_0 \\ \partial_x \zeta_1 |_1 \end{pmatrix} &amp;lt;/math&amp;gt; and likewise taking &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt; to give &amp;lt;math&amp;gt; \zeta_2 &amp;lt;/math&amp;gt; shows the second column must be &amp;lt;math&amp;gt; \begin{pmatrix} \partial_x \zeta_2 |_0 \\ \partial_x \zeta_2 |_1 \end{pmatrix} &amp;lt;/math&amp;gt;. So &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \begin{pmatrix}  \partial_x \zeta_1 |_0  \, \partial_x \zeta_2 |_0 \\ \partial_x \zeta_1 |_1 \, \partial_x \zeta_2 |_1 \end{pmatrix} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now for the areas of constant depth there is a potential of the form &amp;lt;math&amp;gt; e^{ikx} &amp;lt;/math&amp;gt; which, creates  reflected and transmitted potentials from the variable depth area  of the form &amp;lt;math&amp;gt; Re^{ikx} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; Te^{ikx} &amp;lt;/math&amp;gt; respectively where the magnitudes of &amp;lt;math&amp;gt; R &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; are unknown.  We can calculate that the boundary conditions for &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; must be&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \zeta |_0 = 1+R, \quad \zeta |_1 = Te^{ik}, \quad \partial_x \zeta |_0 = ik(1-R), \quad \partial_x \zeta |_1 = ikTe^{ik} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Knowing &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; these boundary conditions can be solved for &amp;lt;math&amp;gt; R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which in turn gives actual numerical boundary conditions  to the original problem. Taking a linear combination of the solutions already calculated (&amp;lt;math&amp;gt; \zeta_1 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \zeta_2 &amp;lt;/math&amp;gt;) will provide the solution for these new boundary conditions. This solution, along with the potentials outside this region gives a potential for the whole real axis.&lt;br /&gt;
&lt;br /&gt;
If a waveform &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt; is travelling in from &amp;lt;math&amp;gt; -\infty &amp;lt;/math&amp;gt; Taking the fourier transform gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \hat{f}(k)=\int_{-\infty}^{\infty}\,f(x)e^{2\pi i k} \,dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then inverting &amp;lt;math&amp;gt; \hat{f}(k) \zeta(x) &amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;  f(x,t) = \int_{-\infty}^{\infty}\,\hat{f}(k) \zeta(x) e^{-2\pi i k t} \,dk &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is the time dependent solution for the wave form.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8533</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8533"/>
		<updated>2009-01-09T03:45:47Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Solution using Separation of Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
M_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\zeta \right) = -\kappa^{2}\zeta \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\zeta (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\zeta (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\zeta = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; \zeta=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; \zeta (0)=a \quad \zeta (1)=b &amp;lt;/math&amp;gt; and, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt; explicitly differentiating &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; gives &amp;lt;math&amp;gt; \zeta&#039;(0) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \zeta&#039;(1) &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim here is to construct a matrix &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; such that, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; S \begin{pmatrix} \zeta(0) \\ \zeta(1) \end{pmatrix}=\begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking &amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; shows that the first column of &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=1,b=0)} &amp;lt;/math&amp;gt; and likewise taking &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt; shows the second column must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=0,b=1)} &amp;lt;/math&amp;gt;. So &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \begin{pmatrix}  \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=1,b=0)} \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=0,b=1)} \end{pmatrix} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now for the areas of constant depth there is a potential of the form &amp;lt;math&amp;gt; e^{ikx} &amp;lt;/math&amp;gt; which, creates  reflected and transmitted potentials from the variable depth area  of the form &amp;lt;math&amp;gt; Re^{ikx} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; Te^{ikx} &amp;lt;/math&amp;gt; respectively where the magnitudes of &amp;lt;math&amp;gt; R &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; are unknown.  We can calculate that the boundary conditions for &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; must be&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \zeta(0) = 1+R, \quad \zeta(1) = Te^{ik}, \quad \zeta&#039;(0) = ik(1-R), \quad \zeta&#039;(1) = ikTe^{ik} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Knowing &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; these boundary conditions can be solved for &amp;lt;math&amp;gt; R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which in turn gives actual numerical boundary conditions  to the original problem. Taking a linear combination of the solutions already calculated (&amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt;) will provide the solution for these new boundary conditions. This solution, along with the potentials outside this region gives a potential for the whole real axis.&lt;br /&gt;
&lt;br /&gt;
If a waveform &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt; is travelling in from &amp;lt;math&amp;gt; -\infty &amp;lt;/math&amp;gt; Taking the fourier transform gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \hat{f}(k)=\int_{-\infty}^{\infty}\,f(x)e^{2\pi i k} \,dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and then inverting &amp;lt;math&amp;gt; \hat{f}(k) \zeta(x) &amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;  f(x,t) = \int_{-\infty}^{\infty}\,\hat{f}(k) \zeta(x) e^{-2\pi i k t} \,dk &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is the time dependent solution for the wave form.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8532</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8532"/>
		<updated>2009-01-09T03:42:38Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Solution using Separation of Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
M_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\zeta \right) = -\kappa^{2}\zeta \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\zeta (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\zeta (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\zeta = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; \zeta=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; \zeta (0)=a \quad \zeta (1)=b &amp;lt;/math&amp;gt; and, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt; explicitly differentiating &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; gives &amp;lt;math&amp;gt; \zeta&#039;(0) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \zeta&#039;(1) &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim here is to construct a matrix &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; such that, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; S \begin{pmatrix} \zeta(0) \\ \zeta(1) \end{pmatrix}=\begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking &amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; shows that the first column of &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=1,b=0)} &amp;lt;/math&amp;gt; and likewise taking &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt; shows the second column must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=0,b=1)} &amp;lt;/math&amp;gt;. So &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \begin{pmatrix}  \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=1,b=0)} \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=0,b=1)} \end{pmatrix} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now for the areas of constant depth there is a potential of the form &amp;lt;math&amp;gt; e^{ikx} &amp;lt;/math&amp;gt; which, creates  reflected and transmitted potentials from the variable depth area  of the form &amp;lt;math&amp;gt; Re^{ikx} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; Te^{ikx} &amp;lt;/math&amp;gt; respectively where the magnitudes of &amp;lt;math&amp;gt; R &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; T &amp;lt;/math&amp;gt; are unknown.  We can calculate that the boundary conditions for &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; must be&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \zeta(0) = 1+R, \quad \zeta(1) = Te^{ik}, \quad \zeta&#039;(0) = ik(1-R), \quad \zeta&#039;(1) = ikTe^{ik} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Knowing &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; these boundary conditions can be solved for &amp;lt;math&amp;gt; R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which in turn gives actual numerical boundary conditions  to the original problem. Taking a linear combination of the solutions already calculated (&amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt;) will provide the solution for these new boundary conditions. This solution, along with the potentials outside this region gives a potential for the whole real axis.&lt;br /&gt;
&lt;br /&gt;
If a waveform &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt; is travelling in from &amp;lt;math&amp;gt; -\infty &amp;lt;/math&amp;gt; Taking the fourier transform gives a potential&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \hat{f}(k)=\int_{-\infty}^{\infty}\,f(x)e^{2\pi i k} \,dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then inverting &amp;lt;math&amp;gt; \hat{f}(k) \zeta(x) &amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;  f(x,t) = \int_{-\infty}^{\infty}\,\hat{f}(k) \zeta(x) e^{-2\pi i k t} \,dk &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is the time dependent solution for the wave form.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8514</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8514"/>
		<updated>2009-01-09T03:26:19Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
M_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\zeta \right) = -\kappa^{2}\zeta \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\zeta (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\zeta (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\zeta = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; \zeta=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; \zeta (0)=a \quad \zeta (1)=b &amp;lt;/math&amp;gt; and, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt; explicitly differentiating &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; gives &amp;lt;math&amp;gt; \zeta&#039;(0) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \zeta&#039;(1) &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim here is to construct a matrix &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; such that, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; S \begin{pmatrix} \zeta(0) \\ \zeta(1) \end{pmatrix}=\begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking &amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; shows that the first column of &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=1,b=0)} &amp;lt;/math&amp;gt; and likewise taking &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt; shows the second column must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=0,b=1)} &amp;lt;/math&amp;gt;. So &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \begin{pmatrix}  \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=1,b=0)} \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=0,b=1)} \end{pmatrix} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now with a potential of the form &amp;lt;math&amp;gt; e^{ikx} &amp;lt;/math&amp;gt; which, creates  reflected and transmitted potentials from the variable depth area  of the form &amp;lt;math&amp;gt; Re^{ikx} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; Te^{ikx} &amp;lt;/math&amp;gt; respectively where the magnitudes of R and T are unknown.  We can calculate that the boundary conditions for &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; must be&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \zeta(0) = 1+R, \quad \zeta(1) = Te^{ik}, \quad \zeta&#039;(0) = ik(1-R), \quad \zeta&#039;(1) = ikTe^{ik} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Knowing &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; these boundary conditions can be solved for &amp;lt;math&amp;gt; R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which in turn gives actual numerical boundary conditions  to the original problem. Taking a linear combination of the solutions already calculated (&amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt;) will provide the solution for these new boundary conditions. This solution, along with the potentials outside this region gives a potential for the whole real axis.&lt;br /&gt;
&lt;br /&gt;
If a waveform &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt; is travelling in from &amp;lt;math&amp;gt; -\infty &amp;lt;/math&amp;gt; Taking the fourier transform gives a potential&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \hat{f}(k)=\int_{-\infty}^{\infty}\,f(x)e^{2\pi i k} \,dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then inverting &amp;lt;math&amp;gt; \hat{f}(k) \zeta(x) &amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;  f(x,t) = \int_{-\infty}^{\infty}\,\hat{f}(k) \zeta(x) e^{-2\pi i k t} \,dk &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is the time dependent solution.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8513</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8513"/>
		<updated>2009-01-09T03:24:45Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Solution using Separation of Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
m_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\zeta \right) = -\kappa^{2}\zeta \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\zeta (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\zeta (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\zeta = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; \zeta=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; \zeta (0)=a \quad \zeta (1)=b &amp;lt;/math&amp;gt; and, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt; explicitly differentiating &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; gives &amp;lt;math&amp;gt; \zeta&#039;(0) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \zeta&#039;(1) &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim here is to construct a matrix &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; such that, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; S \begin{pmatrix} \zeta(0) \\ \zeta(1) \end{pmatrix}=\begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking &amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; shows that the first column of &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=1,b=0)} &amp;lt;/math&amp;gt; and likewise taking &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt; shows the second column must be &amp;lt;math&amp;gt; \begin{pmatrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{pmatrix} \bigg|_{(a=0,b=1)} &amp;lt;/math&amp;gt;. So &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \begin{pmatrix}  \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=1,b=0)} \begin{matrix} \zeta&#039;(0) \\ \zeta&#039;(1) \end{matrix} \bigg|_{(a=0,b=1)} \end{pmatrix} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now with a potential of the form &amp;lt;math&amp;gt; e^{ikx} &amp;lt;/math&amp;gt; which, creates  reflected and transmitted potentials from the variable depth area  of the form &amp;lt;math&amp;gt; Re^{ikx} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; Te^{ikx} &amp;lt;/math&amp;gt; respectively where the magnitudes of R and T are unknown.  We can calculate that the boundary conditions for &amp;lt;math&amp;gt; \zeta &amp;lt;/math&amp;gt; must be&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \zeta(0) = 1+R, \quad \zeta(1) = Te^{ik}, \quad \zeta&#039;(0) = ik(1-R), \quad \zeta&#039;(1) = ikTe^{ik} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Knowing &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; these boundary conditions can be solved for &amp;lt;math&amp;gt; R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which in turn gives actual numerical boundary conditions  to the original problem. Taking a linear combination of the solutions already calculated (&amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt;) will provide the solution for these new boundary conditions. This solution, along with the potentials outside this region gives a potential for the whole real axis.&lt;br /&gt;
&lt;br /&gt;
If a waveform &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt; is travelling in from &amp;lt;math&amp;gt; -\infty &amp;lt;/math&amp;gt; Taking the fourier transform gives a potential&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \hat{f}(k)=\int_{-\infty}^{\infty}\,f(x)e^{2\pi i k} \,dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then inverting &amp;lt;math&amp;gt; \hat{f}(k) \zeta(x) &amp;lt;/math&amp;gt; with respect to &amp;lt;math&amp;gt; t &amp;lt;/math&amp;gt; gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;  f(x,t) = \int_{-\infty}^{\infty}\,\hat{f}(k) \zeta(x) e^{-2\pi i k t} \,dk &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which is the time dependent solution.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8509</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8509"/>
		<updated>2009-01-09T01:50:56Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Solution using Separation of Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
m_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution &amp;lt;math&amp;gt;\ w (x,t) = \Tau (t) \hat{w} (x)&amp;lt;/math&amp;gt;  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\hat{w} \right) = -\kappa^{2}\hat{w} \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; w=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; w(0)=a \quad w(1)=b &amp;lt;/math&amp;gt; and, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt; explicitly differentiating &amp;lt;math&amp;gt; w &amp;lt;/math&amp;gt; gives &amp;lt;math&amp;gt; w&#039;(0) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; w&#039;(1) &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim here is to construct a matrix &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; such that, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; S \begin{pmatrix} w(0) \\ w(1) \end{pmatrix}=\begin{pmatrix} w&#039;(0) \\ w&#039;(1) \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking &amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; shows that the first column of &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; must be &amp;lt;math&amp;gt; \begin{pmatrix} w&#039;(0) \\ w&#039;(1) \end{pmatrix} \bigg|_{(a=1,b=0)} &amp;lt;/math&amp;gt; and likewise taking &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt; shows the second column must be &amp;lt;math&amp;gt; \begin{pmatrix} w&#039;(0) \\ w&#039;(1) \end{pmatrix} \bigg|_{(a=0,b=1)} &amp;lt;/math&amp;gt;. So &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \begin{pmatrix}  \begin{matrix} w&#039;(0) \\ w&#039;(1) \end{matrix} \bigg|_{(a=1,b=0)} \begin{matrix} w&#039;(0) \\ w&#039;(1) \end{matrix} \bigg|_{(a=0,b=1)} \end{pmatrix} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now with a potential of the form &amp;lt;math&amp;gt; e^{ikx} &amp;lt;/math&amp;gt; which, creates  reflected and transmitted potentials from the variable depth area  of the form &amp;lt;math&amp;gt; Re^{ikx} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; Te^{ikx} &amp;lt;/math&amp;gt; respectively where the magnitudes of R and T are unknown.  We can calculate that the boundary conditions for &amp;lt;math&amp;gt; w &amp;lt;/math&amp;gt; must be&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; w(0) = 1+R, \quad w(1) = Te^{ik}, \quad w&#039;(0) = ik(1-R), \quad w&#039;(1) = ikTe^{ik} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Knowing &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; these boundary conditions can be solved for &amp;lt;math&amp;gt; R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which in turn gives actual numerical boundary conditions  to the original problem. Taking a linear combination of the solutions already calculated (&amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt;) will provide the solution for these new boundary conditions. This solution, along with the potentials outside this region gives a potential for the whole real line&lt;br /&gt;
&lt;br /&gt;
If a waveform &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt; is travelling in from &amp;lt;math&amp;gt; -\infty &amp;lt;/math&amp;gt; Taking the fourier transform gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \hat{f}(k)=\int_{-\infty}^{\infty}\,f(x)e^{2\pi i k} \,dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And then&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;  f(x,t) = \int_{-\infty}^{\infty}\,\hat{f}(k) w(x) e^{-2\pi i k t} \,dk &amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8472</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8472"/>
		<updated>2009-01-08T02:36:45Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Solution using Separation of Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
m_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution &amp;lt;math&amp;gt;\ w (x,t) = \Tau (t) \hat{w} (x)&amp;lt;/math&amp;gt;  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\hat{w} \right) = -\kappa^{2}\hat{w} \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; w=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; w(0)=a \quad w(1)=b &amp;lt;/math&amp;gt; and, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt; explicitly differentiating &amp;lt;math&amp;gt; w &amp;lt;/math&amp;gt; gives &amp;lt;math&amp;gt; w&#039;(0) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; w&#039;(1) &amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The aim here is to construct a matrix &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; such that, given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; S \begin{pmatrix} w(0) \\ w(1) \end{pmatrix}=\begin{pmatrix} w&#039;(0) \\ w&#039;(1) \end{pmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking &amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; shows that the first column of &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; must be &amp;lt;math&amp;gt; \begin{pmatrix} w&#039;(0) \\ w&#039;(1) \end{pmatrix} \bigg|_{(a=1,b=0)} &amp;lt;/math&amp;gt; and likewise taking &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt; shows the second column must be &amp;lt;math&amp;gt; \begin{pmatrix} w&#039;(0) \\ w&#039;(1) \end{pmatrix} \bigg|_{(a=0,b=1)} &amp;lt;/math&amp;gt;. So &amp;lt;math&amp;gt;S&amp;lt;/math&amp;gt; is given by&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \begin{pmatrix}  \begin{matrix} w&#039;(0) \\ w&#039;(1) \end{matrix} \bigg|_{(a=1,b=0)} \begin{matrix} w&#039;(0) \\ w&#039;(1) \end{matrix} \bigg|_{(a=0,b=1)} \end{pmatrix} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now considering the case were there is an wave of the form &amp;lt;math&amp;gt; e^{ikx} &amp;lt;/math&amp;gt; which, creates  reflected and transmitted waves from the variable depth area  of the form &amp;lt;math&amp;gt; Re^{ikx} &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; Te^{ikx} &amp;lt;/math&amp;gt; respectively where the magnitudes of R and T are unknown.  We can calculate that the boundary conditions for &amp;lt;math&amp;gt; w &amp;lt;/math&amp;gt; must be&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; w(0) = 1+R, \quad w(1) = Te^{ik}, \quad w&#039;(0) = ik(1-R), \quad w&#039;(1) = ikTe^{ik} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, knowing &amp;lt;math&amp;gt; S &amp;lt;/math&amp;gt; these boundary conditions can be solved for &amp;lt;math&amp;gt; R&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt;, which in turn gives actual numerical boundary conditions ) to the original problem. Taking a linear combination of the solutions already calculated (&amp;lt;math&amp;gt; a=1,\,b=0 &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; a=0,\,b=1 &amp;lt;/math&amp;gt;) will provide the solution for these new boundary conditions.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8471</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8471"/>
		<updated>2009-01-08T01:08:12Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
m_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution &amp;lt;math&amp;gt;\ w (x,t) = \Tau (t) \hat{w} (x)&amp;lt;/math&amp;gt;  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\hat{w} \right) = -\kappa^{2}\hat{w} \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{k=1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{k=1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_n &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
So &amp;lt;math&amp;gt; w=(b-a)x+a+\sum_{n=1}^{\infty}c_{n} \sin(n\pi x) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Shallow Depth]]&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8470</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8470"/>
		<updated>2009-01-07T22:49:40Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: /* Solution using Separation of Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
We consider here the problem of waves reflected by a region of variable depth in&lt;br /&gt;
an otherwise uniform depth region assuming the equations of [[:Category:Shallow Depth|Shallow Depth]].&lt;br /&gt;
&lt;br /&gt;
== Equations ==&lt;br /&gt;
&lt;br /&gt;
We begin with the shallow depth equation&lt;br /&gt;
{{shallow depth one dimension}} &lt;br /&gt;
&lt;br /&gt;
== Waves in a finite basin ==&lt;br /&gt;
&lt;br /&gt;
We consider the problem of waves in a finite basin &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. At the edge of the basin the boundary conditions are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\left.\partial_x \zeta\right|_{x=0} = \left.\partial_x \zeta\right|_{x=1} =0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We solve the equations by expanding in the modes for the basin which satisfy&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\partial_x \left(h(x) \partial_x \zeta_n \right) = -\lambda_n,&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
normalised so that &lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\int_0^1 \zeta_n \zeta_m = \delta_{mn}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
The solution is then given by&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta(x,t) = \sum_{n=0}^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \cos(\sqrt{\lambda_n} t )&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&amp;lt;math&amp;gt;&lt;br /&gt;
+ \sum_{n=1} ^{\infty} \left(\int_0^1 \zeta_n(x^\prime) \partial_t\zeta_0 (x^\prime) dx^\prime \right) \zeta_n(x) \frac{\sin(\sqrt{\lambda_n} t )}{\sqrt{\lambda_n}}&lt;br /&gt;
&amp;lt;/math&amp;gt;&amp;lt;/center&amp;gt;&lt;br /&gt;
where we have assumed that &amp;lt;math&amp;gt;\lambda_0 = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Calculation of &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; ===&lt;br /&gt;
&lt;br /&gt;
We can calculate the eigenfunctions &amp;lt;math&amp;gt;\zeta_n&amp;lt;/math&amp;gt; by an expansion in the modes for the case of uniform depth.&lt;br /&gt;
We use the Rayleigh-Ritz method. The eigenfunctions are local minimums of &lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;J[\zeta] = \int_0^1 \frac{1}{2}\left\{ \left(h(x) \partial_x \zeta\right)^2 - \lambda \zeta^2 \right\}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
subject to the boundary conditions that the normal derivative vanishes (where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; is the eigenvalue).&lt;br /&gt;
&lt;br /&gt;
We expand the displacement in the eigenfunctions for constant depth &amp;lt;math&amp;gt;h=1&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\zeta = \sum_{n=1}^{N} a_n \psi_n(x)&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_n = \sqrt{2} \cos( (n-1) \pi x),\,\,n\ne 1&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\psi_0 = 1,\,&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
and substitute this expansion into the variational equation we obtain&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{M} \vec{a} = \lambda \vec{a}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
where the elements of the matrix &#039;&#039;&#039;M&#039;&#039;&#039; are&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
m_{mn} = \int_0^1 \left\{ \left(\partial_x \psi_m h(x) \partial_x \psi_n\right) \right\}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab code ===&lt;br /&gt;
&lt;br /&gt;
== Waves in an infinite basin ==&lt;br /&gt;
&lt;br /&gt;
We assume that the depth is constant and equal to one outside the region &amp;lt;math&amp;gt;0&amp;lt;x&amp;lt;1&amp;lt;/math&amp;gt;. &lt;br /&gt;
We can therefore write the wave as&lt;br /&gt;
&lt;br /&gt;
== Solution using Separation of Variables ==&lt;br /&gt;
&lt;br /&gt;
Taking a separable solution &amp;lt;math&amp;gt;\ w (x,t) = \Tau (t) \hat{w} (x)&amp;lt;/math&amp;gt;  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( h(x) \partial_x\hat{w} \right) = -\kappa^{2}\hat{w} \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we can take &amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + u &amp;lt;/math&amp;gt; With &amp;lt;math&amp;gt; u  &amp;lt;/math&amp;gt;  satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting this form into (1) gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; (b-a)\partial_xh(x)+\partial_x(h(x)\partial_xu) = -\kappa^{2}\left((b-a)x+a+u\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Or, on rearranging&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\kappa^{2}u = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Now consider the homogenous Sturm-Liouville problem for u&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_x(h(x)\partial_xu)+\lambda u = 0\quad u(0)=u(1)=0 \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By Sturm-Liouville theory this has an infinite set of eigenvalues &amp;lt;math&amp;gt; \lambda_k &amp;lt;/math&amp;gt; with corresponding eigenfunctions &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;.  Also since &amp;lt;math&amp;gt; u_k(0)=u_k(1)=0\quad \forall k &amp;lt;/math&amp;gt; Each &amp;lt;math&amp;gt; u_k&amp;lt;/math&amp;gt; can be expanded as a fourier series in terms of sine functions.&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; u_k = \sum_{n=1}^{\infty} a_{n,k}\sin(n\pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Transforming (3) into the equivalent variational problem gives&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J[u] = \int_{0}^{1}\,hu&#039;^{2}-\lambda u^{2} \, dx \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
Substituting the fourier expansion into (4) implies J must be stationary at &amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=0 \quad \forall n &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \frac{\partial J}{\partial a_{n}}=\int_{0}^{1}\,hn\pi \cos(n\pi x)\sum_{m=1}^{\infty} a_{m}\cos(m\pi x)\,dx-\frac{\lambda} {2}a_{n}=0&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
By defining a vector &amp;lt;math&amp;gt; \textbf{a} = \left(a_{n}\right)&amp;lt;/math&amp;gt; and a matrix &amp;lt;math&amp;gt;M_{(n,m)} = 2\int_{0}^{1}\,hnm\pi^{2} \cos(n\pi x)\cos(m\pi x)\,dx &amp;lt;/math&amp;gt; we have the linear system &amp;lt;math&amp;gt; M\textbf{a} = \lambda\textbf{a} &amp;lt;/math&amp;gt; which returns the eigenvalues and eigenvectors of equation (3), with eigenvectors &amp;lt;math&amp;gt; \textbf{a} &amp;lt;/math&amp;gt; representing coefficient vectors of the fourier expansions of eigenfunctions.&lt;br /&gt;
&lt;br /&gt;
If we now construct &amp;lt;math&amp;gt; u = \sum_{1}^{\infty} b_k u_k &amp;lt;/math&amp;gt; and substitute this into equation (2) we get&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{1}^{\infty} (\kappa^{2}-\lambda_k) b_k u_k = -(b-a)\partial_xh(x)-\kappa^{2}\left((b-a)x+a\right) \quad (5) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
And defining the RHS of equation (5) as &amp;lt;math&amp;gt; f(x) &amp;lt;/math&amp;gt;, a known function, we can retrieve the coefficients &amp;lt;math&amp;gt; b_k &amp;lt;/math&amp;gt; by integrating against &amp;lt;math&amp;gt; u_k &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; b_k = \frac{\int_{0}^{1}\,f u_k\,dx}{(\kappa^{2}-\lambda_k) \int_{0}^{1}\, u_{k}^{2}\,dx} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also to find the coefficients &amp;lt;math&amp;gt; c_k &amp;lt;/math&amp;gt; of the fourier expansion of u are just &amp;lt;math&amp;gt; \sum_{k=1}^{\infty}a_{n,k}b_{k} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; a_{n.k} &amp;lt;/math&amp;gt; being the &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt;th coefficient of the &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;th eigenfunction of the Sturm-Liouville problem.&lt;br /&gt;
&lt;br /&gt;
[[Category:Shallow Depth]]&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8345</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8345"/>
		<updated>2008-12-16T01:57:45Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The wave equation can be written as&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_t^2 w- \partial_x \left( c(x)^2 \partial_x w \right) \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking a seperable solution &amp;lt;math&amp;gt;\ w (x,t) = \Tau (t) \hat{w} (x)&amp;lt;/math&amp;gt;  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( c(x)^2 \partial_x\hat{w} \right) = \lambda\hat{w} \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we can take&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + u \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;math&amp;gt; u = \sum_{n=1}^{N} a_n \sin (n \pi x)&amp;lt;/math&amp;gt; a series solution satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We wish to solve for &amp;lt;math&amp;gt; a_n &amp;lt;/math&amp;gt; given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;. Equation (2) can be transformed into the Sturm-Liouville problem of minimizing the functional&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J [u] = \int_{0}^{1} c^2 \left(\frac{d \hat{w}}{d x}\right)^2 + \lambda \hat{w}^2 \,dx&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
which is minimal exactly when &amp;lt;math&amp;gt;\partial_{a_n} J = 0 \quad \forall a_n &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting in &amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + \sum_{n=1}^{N} a_n \sin (n \pi x)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\frac {d \hat{w}}{d x} = (b-a) + \sum_{n=1}^{N} a_n n \pi \cos (n \pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
gives&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_{a_n} J = \int_{0}^{1} c^2 \left( n \pi \cos (n \pi x) \left((b-a) + \sum_{m=1}^{N} a_m m \pi \cos (m \pi x) \right) \right) \, dx  + \int_{0}^{1} \lambda \left( \sin (n \pi x) \left((b-a)x + a + \sum_{m=1}^{N} a_m \sin (m \pi x) \right) \right) \, dx = 0 \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;math&amp;gt; \sin(n \pi x) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \sin(m \pi x) &amp;lt;/math&amp;gt; are orthogonal  the second integral in (4) can be calculated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; \int_{0}^{1} \lambda \left( \sin (n \pi x) \left((b-a)x + a + \sum_{m=1}^{N} a_m \sin (m \pi x) \right) \right) \, dx =\lambda \int_{0}^{1} \left( (b-a)x+a \right) \sin (n \pi x) \, dx + \frac{\lambda a_n}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; \int_{0}^{1} \lambda \left( \sin (n \pi x) \left((b-a)x + a + \sum_{m=1}^{N} a_m \sin (m \pi x) \right) \right) \, dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;= \lambda \left((b-a) \int_{0}^{1} x \sin(n \pi x) \, dx + a \int_{0}^{1} \sin(n \pi x) \, dx \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;= \frac{\lambda (b-a)}{(n \pi)^2} \Big[ \sin(n \pi x) -n \pi x \cos( n \pi x) \Big]_{0}^{1} - \frac{a \lambda}{n \pi} \Big[\cos(n \pi x) \Big]_{0}^{1} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; = \frac{\lambda (b-a)}{(n \pi)^2} \left(n \pi (-1)^{n+1} \right) + \frac{a \lambda}{n \pi} \left(1 - (-1)^n \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; = \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So equation (4) can be written as&lt;br /&gt;
&amp;lt;math&amp;gt;\int_{0}^{1} c^2 \left( n \pi \cos (n \pi x) \left((b-a) + \sum_{m=1}^{N} a_m m \pi \cos (m \pi x) \right) \right) \, dx + \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) + \frac{\lambda a_n}{2}= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The remaining integral can be split into two parts and with the sum taken outside the integral we obtain&lt;br /&gt;
&amp;lt;math&amp;gt;\int_{0}^{1} c^2 (b-a) n \pi \cos (n \pi x)  + \sum_{m=1}^{N} \left( \int_{0}^{1} c^2 n m \pi^2 \cos(n \pi x) \cos (m \pi x) \, dx \right) a_m + \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) + \frac{\lambda a_n}{2}= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, on rearranging&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{m=1}^{N} \left( \int_{0}^{1} c^2 n m \pi^2 \cos(n \pi x) \cos (m \pi x) \, dx \right) a_m+ \frac{\lambda a_n}{2}= -\int_{0}^{1} c^2 (b-a) n \pi \cos (n \pi x) - \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now if we form the vector &amp;lt;math&amp;gt; \mathbf{a} = \begin{pmatrix} a_1 \\ \vdots \\ a_N \end{pmatrix} &amp;lt;/math&amp;gt; and recalling that we have the above expression for all n, we can write the above as a matrix multiplication of &amp;lt;math&amp;gt; \mathbf{a} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \mathrm{M} \mathbf{a} = \mathbf{f} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with&lt;br /&gt;
&amp;lt;math&amp;gt; \mathrm{M}_{(n,m)} = \int_{0}^{1} c^2  n m \pi^2 \cos(n \pi x) \cos (m \pi x) \, dx + \delta_{nm} \frac{\lambda}{2} \quad \delta_{nm} = \left\{ \begin{matrix} 1 &amp;amp;  \mathrm{if} \quad n = m  \\ 0 &amp;amp; \mathrm{if} \quad n \neq m  \end{matrix} \right. &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt; \mathbf{f} = \begin{pmatrix} f_1 \\ \vdots \\ f_N \end{pmatrix} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; f_n =  -\int_{0}^{1} c^2 (b-a) n \pi \cos (n \pi x) + \frac{\lambda}{n \pi} \left( b (-1)^n-a \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, given a suitable &amp;lt;math&amp;gt; c(x) &amp;lt;/math&amp;gt; and boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we have a system of linear equations that can be solved to give the coefficients &amp;lt;math&amp;gt; a_n &amp;lt;/math&amp;gt; which in turn define the function &amp;lt;math&amp;gt;\hat{w} &amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
	<entry>
		<id>https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8344</id>
		<title>Variable Depth Shallow Water Wave Equation</title>
		<link rel="alternate" type="text/html" href="https://www.wikiwaves.org/index.php?title=Variable_Depth_Shallow_Water_Wave_Equation&amp;diff=8344"/>
		<updated>2008-12-16T01:42:04Z</updated>

		<summary type="html">&lt;p&gt;Slawrence: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The wave equation can be written as&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_t^2 w- \partial_x \left( c(x)^2 \partial_x w \right) \quad (1)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Taking a seperable solution &amp;lt;math&amp;gt;\ w (x,t) = \Tau (t) \hat{w} (x)&amp;lt;/math&amp;gt;  gives the eigenvalue problem&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\partial_x \left( c(x)^2 \partial_x\hat{w} \right) = \lambda\hat{w} \quad (2)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we can take&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + u \quad (3)&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;math&amp;gt; u = \sum_{n=1}^{N} a_n \sin (n \pi x)&amp;lt;/math&amp;gt; a series solution satisfying &amp;lt;math&amp;gt; u (0) = u (1) = 0&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We wish to solve for &amp;lt;math&amp;gt; a_n &amp;lt;/math&amp;gt; given &amp;lt;math&amp;gt; a &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; b &amp;lt;/math&amp;gt;. Equation (2) can be transformed into the Sturm-Liouville problem of minimizing the functional&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; J [u] = \int_{0}^{1} c^2 \left(\frac{d \hat{w}}{d x}\right)^2 + \lambda \hat{w}^2 \,dx&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
which is minimal exactly when &amp;lt;math&amp;gt;\partial_{a_n} J = 0 \quad \forall a_n &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Substituting in &amp;lt;math&amp;gt;\hat{w} = (b-a)x + a + \sum_{n=1}^{N} a_n \sin (n \pi x)&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\frac {d \hat{w}}{d x} = (b-a) + \sum_{n=1}^{N} a_n n \pi \cos (n \pi x)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
gives&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \partial_{a_n} J = \int_{0}^{1} c^2 \left( n \pi \cos (n \pi x) \left((b-a) + \sum_{m=1}^{N} a_m m \pi \cos (m \pi x) \right) \right) \, dx  + \int_{0}^{1} \lambda \left( \sin (n \pi x) \left((b-a)x + a + \sum_{m=1}^{N} a_m \sin (m \pi x) \right) \right) \, dx = 0 \quad (4) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since &amp;lt;math&amp;gt; \sin(n \pi x) &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt; \sin(m \pi x) &amp;lt;/math&amp;gt; are orthogonal  the second integral in (4) can be calculated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; \int_{0}^{1} \lambda \left( \sin (n \pi x) \left((b-a)x + a + \sum_{m=1}^{N} a_m \sin (m \pi x) \right) \right) \, dx =\lambda \int_{0}^{1} \left( (b-a)x+a \right) \sin (n \pi x) \, dx + \frac{\lambda a_n}{2}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt; \int_{0}^{1} \lambda \left( \sin (n \pi x) \left((b-a)x + a + \sum_{m=1}^{N} a_m \sin (m \pi x) \right) \right) \, dx &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;= \lambda \left((b-a) \int_{0}^{1} x \sin(n \pi x) \, dx + a \int_{0}^{1} \sin(n \pi x) \, dx \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;= \frac{\lambda (b-a)}{(n \pi)^2} \Big[ \sin(n \pi x) -n \pi x \cos( n \pi x) \Big]_{0}^{1} - \frac{a \lambda}{n \pi} \Big[\cos(n \pi x) \Big]_{0}^{1} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; = \frac{\lambda (b-a)}{(n \pi)^2} \left(n \pi (-1)^{n+1} \right) + \frac{a \lambda}{n \pi} \left(1 - (-1)^n \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; = \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So equation (4) can be written as&lt;br /&gt;
&amp;lt;math&amp;gt;\int_{0}^{1} c^2 \left( n \pi \cos (n \pi x) \left((b-a) + \sum_{m=1}^{N} a_m m \pi \cos (m \pi x) \right) \right) \, dx + \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) + \frac{\lambda a_n}{2}= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The remaining integral can be split into two parts and with the sum taken outside the integral we obtain&lt;br /&gt;
&amp;lt;math&amp;gt;\int_{0}^{1} c^2 (b-a) n \pi \cos (n \pi x)  + \sum_{m=1}^{N} \left( \int_{0}^{1} c^2 n m \pi^2 \cos(n \pi x) \cos (m \pi x) \, dx \right) a_m + \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) + \frac{\lambda a_n}{2}= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, on rearranging&lt;br /&gt;
&amp;lt;math&amp;gt; \sum_{m=1}^{N} \left( \int_{0}^{1} c^2 n m \pi^2 \cos(n \pi x) \cos (m \pi x) \, dx \right) a_m+ \frac{\lambda a_n}{2}= -\int_{0}^{1} c^2 (b-a) n \pi \cos (n \pi x) - \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now if we form the vector &amp;lt;math&amp;gt; \mathbf{a} = \begin{pmatrix} a_1 \\ \vdots \\ a_N \end{pmatrix} &amp;lt;/math&amp;gt; and recalling that we have the above expression for all n, we can write the above as a matrix multiplication of &amp;lt;math&amp;gt; \mathbf{a} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt; \mathrm{M} \mathbf{a} = \mathbf{f} &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with&lt;br /&gt;
&amp;lt;math&amp;gt; \mathrm{M}_{(n,m)} = \int_{0}^{1} c^2  n m \pi^2 \cos(n \pi x) \cos (m \pi x) \, dx + \delta_{nm} \frac{\lambda}{2} \quad \delta_{nm} = \left\{ \begin{matrix} 1 &amp;amp;  \mathrm{if} \quad n = m  \\ 0 &amp;amp; \mathrm{if} \quad n \neq m  \end{matrix} \right. &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;math&amp;gt; \mathbf{f} = \begin{pmatrix} f_1 \\ \vdots \\ f_N \end{pmatrix} &amp;lt;/math&amp;gt; with &amp;lt;math&amp;gt; f_n =  -\int_{0}^{1} c^2 (b-a) n \pi \cos (n \pi x) - \frac{\lambda}{n \pi} \left( b (-1)^{n+1}+a \right) &amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, given a suitable &amp;lt;math&amp;gt; c(x) &amp;lt;/math&amp;gt; and boundary conditions &amp;lt;math&amp;gt;\hat{w} (0) = a&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\hat{w} (1) = b&amp;lt;/math&amp;gt; we have a system of linear equations that can be solved to give the coefficients &amp;lt;math&amp;gt; a_n &amp;lt;/math&amp;gt; which in turn define the function &amp;lt;math&amp;gt;\hat{w} &amp;lt;/math&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Slawrence</name></author>
	</entry>
</feed>