next up previous
Next: Exercise 5.9: Finite differences Up: Waves on a string Previous: Waves on a string

Numerical solution: finite differences

To solve the equation (55) as a function of position and time we need to discretize the $(x,t)$ space in a rectangular grid (see Fig 12). In the present case, the horizontal axis represents the position $x$ along the string, and the vertical axis represent time. We convert the equation to a finite difference equation expressing the second derivatives in terms of differences

\begin{eqnarray*}
\frac{\partial ^{2}u(x,t)}{\partial t^{2}} &\simeq &\frac{u(x,...
...&\frac{u(x+\Delta
x,t)+u(x-\Delta x,t)-2u(x,t)}{(\Delta t)^{2}}.
\end{eqnarray*}

After substituting into (55) we obtain the discrete equations:

\begin{displaymath}
u(x,t+\Delta t)=2u(x,t)-u(x,t-\Delta t)+\frac{v^{2}}{C^{2}}\left[ u(x+\Delta
x,t)+u(x-\Delta x,t)-2u(x,t)\right] ,
\end{displaymath}

with $C=\Delta t/\Delta x$ is a constant with the dimension of velocity.

Figure 12: Finite differences grid for the vibrating string
\begin{figure}\begin{center}
\epsfig{file=differences.eps,width=12cm}\end{center}\end{figure}

As shown in Fig. 12, this is a recurrence relation that propagates the wave from the two earlier times $t-\Delta t$ and $t$, and the three nearby positions $x-\Delta x$, $x$, and $x+\Delta x$, to a later time $%
t+\Delta t$, and a single position $x$. We can see right a way that this is not a self starting algorithm, in the sense that we need to know the position fro two earlier times to start the iteration. However, we can use a simple trick to overcome this difficulty. Rewriting the initial conditions (58) and (59) in the finite differences form, we obtain:

\begin{eqnarray*}
\frac{\partial u(x,t=0)}{\partial t} &=&0\Rightarrow \frac{u(x...
...)}{2\Delta t}=0, \\
&\Rightarrow &u(x,-\Delta t)=u(x,\Delta t).
\end{eqnarray*}

Using this condition for the first iteration we obtain

\begin{displaymath}
u(x,t+\Delta t)=u(x,0)+\frac{1}{2}\frac{v^2}{C^2}
\left[ u(x+\Delta x,t)+u(x-\Delta x,t)-2u(x,t)\right] .
\end{displaymath}

The success of this method depends on the relative sizes of the time and space steps. This stability criterion says that the finite difference algorithm is stable if
\begin{displaymath}
v\leq \frac{\Delta x}{\Delta t}=C.
\end{displaymath} (59)

This means that the solution gets better with smaller time steps, but worse with smaller space steps!


next up previous
Next: Exercise 5.9: Finite differences Up: Waves on a string Previous: Waves on a string
Adrian E. Feiguin 2004-06-01