The difference equation#

We are going to solve equation (22) numerically on discretized time and space. The discretizations are:

(26)#\[\begin{split} x_m &= m\Delta x, m=0,1,2,...,M \\ t^n &= n\Delta t, n=0,1,2,...,N, \end{split}\]

where \(\Delta t\) is the time step and \(\Delta x\) is the grid resolution. The discrete time-space domain is commonly represented as the t-x diagram in Fig. 3.

../_images/txDiagramCropped.png

Fig. 3 The discrete time-space domain represented as a t-x diagram. The numerical solution at time \(t^n\) and position \(x_m\) is \(u_m^n\) and is represented in the diagram in the position (\(x_m\),\(t^n\)).#

Using the 2nd order centered formula (14) to replace the exact derivatives in (22), we get:

(27)#\[ \frac{u_{m}^{n+1} - u_{m}^{n-1}}{2\Delta t } + c \frac{u_{m+1}^{n} - u_{m-1}^{n}}{2\Delta x} = 0. \]

We call (27) the difference equation resulting from the discretization of (22) by the 2nd order centred formulas for the first derivative. Rearranging the terms of (27) we obtain a time marching scheme:

(28)#\[ u_{m}^{n+1} = u_{m}^{n-1} - c\frac{\Delta t}{\Delta x}(u_{m+1}^{n}-u_{m-1}^{n}), \]

known as the leapfrog scheme, which is a three-level scheme, because it employs information at time levels \(n-1\), \(n\) and \(n+1\). Since the discretization of (22) was done with 2nd order formulas, the scheme (28) is of 2nd order.