16.3 Wave Equation

INTRODUCTION

In this section we approximate a solution of the one-dimensional wave equation using the finite difference method used in the preceding two sections. The one-dimensional wave equation is the prototype hyperbolic partial differential equation.

Difference Equation Replacement

Suppose u(x, t) represents a solution of the one-dimensional wave equation

(1)

Using two central differences,

,

we replace equation (1) by

(2)

We solve (2) for u(x, t + k), which is ui, j + 1. If λ = ck/h, then (2) yields

(3)

for i = 1, 2, …, n − 1 and j = 1, 2, …, m − 1.

In the case when the wave equation (1) is a model for the vertical displacements u(x, t) of a vibrating string, typical boundary conditions are u(0, t) = 0, u(a, t) = 0, t > 0, and initial conditions are u(x, 0) = f(x), ∂u/∂t|t=0 = g(x), 0 < x < a. The functions f and g can be interpreted as the initial position and the initial velocity of the string. The numerical method based on equation (3), like the first method considered in Section 16.2, is an explicit finite difference method. As before, we use the difference equation (3) to approximate the solution u(x, t) of (1), using the boundary and initial conditions, over a rectangular region in the xt-plane defined by the inequalities 0 ≤ xa, 0 ≤ tT, where T is some specified value of time. If n and m are positive integers and

the vertical and horizontal grid lines on this region are defined by

xi = ih, i = 0, 1, 2, …, n     and     tj = jk,     j = 0, 1, 2, …, m.

As shown in FIGURE 16.3.1, (3) enables us to obtain the approximation ui, j+1 on the (j + 1)st time line from the values indicated on the jth and (j − 1)st time lines. Moreover, we use

and .

A mesh shows three parallel solid horizontal lines with a dashed vertical line intersecting them. The top horizontal line is labeled (j plus 1)st time line, the middle horizontal line is labeled jth time line, and the bottom horizontal line is labeled (j minus 1)st time line. The intersection point of the vertical line with the top horizontal line is labeled u subscript (i, j plus 1); with the middle horizontal line is labeled u subscript i j; and with the bottom horizontal line is labeled u subscript (i, j minus 1). The point on the left of u subscript i j is labeled u subscript (i minus 1, j) and the point on the right of u subscript i j is labeled u subscript (i plus 1, j). The gap between the middle and bottom horizontal line is labeled k. The gap between u subscript (i minus 1, j) and u subscript i j is labeled h.

FIGURE 16.3.1 u at t = j + 1 is determined from three values of u at t = j and one value at t = j − 1

There is one minor problem in getting started. You can see from (3) that for j = 1 we need to know the values of ui, 1 (that is, the estimates of u on the first time line) in order to find ui, 2. But from Figure 16.3.1, with j = 0, we see that the values of ui, 1 on the first time line depend on the values of ui, 0 on the zeroth time line and on the values of ui, −1. To compute these latter values we make use of the initial-velocity condition ut(x, 0) = g(x). At t = 0, it follows from (5) of Section 6.5 that

(4)

In order to make sense of the term u(xi, − k) = ui, −1 in (4), we have to imagine u(x, t) extended backward in time. It follows from (4) that

This last result suggests that we define

(5)

in the iteration of (3). By substituting (5) into (3) when j = 0, we get the special case

(6)

EXAMPLE 1 Using the Finite Difference Method

Approximate the solution of the boundary-value problem

using (3) with n = 5 and m = 20.

SOLUTION

We make the identifications c = 2, a = 1, and T = 1. With n = 5 and m = 20 we get h = = 0.2, k = = 0.05, and λ = 0.5. Thus, with g(x) = 0, equations (6) and (3) become, respectively,

(7)

(8)

For i = 1, 2, 3, 4, equation (7) yields the following values for the ui, 1 on the first time line:

(9)

Note that the results given in (9) were obtained from the initial condition u(x, 0) = sin πx. For example, u20 = sin(0.2π), and so on. Now j = 1 in (8) gives

ui, 2 = 0.25ui+1, 1 + 1.5ui, 1 + 0.25ui−1, 1ui, 0,

and so for i = 1, 2, 3, 4 we get

u12 = 0.25u21 + 1.5u11 + 0.25u01u10

u22 = 0.25u31 + 1.5u21 + 0.25u11u20

u32 = 0.25u41 + 1.5u31 + 0.25u21u30

u42 = 0.25u51 + 1.5u41 + 0.25u31u40.

Using the boundary conditions, the initial conditions, and the data obtained in (9), we get from these equations the approximations for u on the second time line. These last results and an abbreviation of the remaining calculations are summarized in Table 16.3.1 on page 827.

TABLE 16.3.1 Explicit Difference Equation Approximation with h = 0.2, k = 0.05, λ = 0.5
A table captioned Explicit Difference Equation Approximation with h = 0.2, k = 0.05, and lambda = 0.5 has five columns and eleven rows. The column headings are as follows: Column 1, Time. Column 2, x = 0.20. Column 3, x = 0.40. Column 4, x = 0.60. Column 5, x = 0.80. The row entries are as follows: Row 1. Time, 0.00. x = 0.20, 0.5878. x = 0.40, 0.9511. x = 0.60, 0.9511. x = 0.80, 0.5878. Row 2. Time, 0.10. x = 0.20, 0.4782. x = 0.40, 0.7738. x = 0.60, 0.7738. x = 0.80, 0.4782. Row 3. Time, 0.20. x = 0.20, 0.1903. x = 0.40, 0.3080. x = 0.60, 0.3080. x = 0.80, 0.1903. Row 4. Time, 0.30. x = 0.20, minus 0.1685. x = 0.40, minus 0.2727. x = 0.60, minus 0.2727. x = 0.80, minus 0.1685. Row 5. Time, 0.40. x = 0.20, minus 0.4645. x = 0.40, minus 0.7516. x = 0.60, minus 0.7516. x = 0.80, minus 0.4645. Row 6. Time, 0.50. x = 0.20, minus 0.5873. x = 0.40, minus 0.9503. x = 0.60, minus 0.9503. x = 0.80, minus 0.5873. Row 7. Time, 0.60. x = 0.20, minus 0.4912. x = 0.40, minus 0.7947. x = 0.60, minus 0.7947. x = 0.80, minus 0.4912. Row 8. Time, 0.70. x = 0.20, minus 0.2119. x = 0.40, minus 0.3428. x = 0.60, minus 0.3428. x = 0.80, minus 0.2119. Row 9. Time, 0.80. x = 0.20, 0.1464. x = 0.40, 0.2369. x = 0.60, 0.2369. x = 0.80, 0.1464. Row 10. Time, 0.90. x = 0.20, 0.4501. x = 0.40, 0.7283. x = 0.60, 0.7283. x = 0.80, 0.4501. Row 11. Time, 1.00. x = 0.20, 0.5860. x = 0.40, 0.9482. x = 0.60, 0.9482. x = 0.80, 0.5860.

It is readily verified that the exact solution of the BVP in Example 1 is u(x, t) = sin πx cos 2πt. With this function we can compare the exact results with the approximations. For example, some selected comparisons are given in Table 16.3.2. As you can see in the table, the approximations are in the same “ball park” as the exact values, but the accuracy is not particularly impressive. We can, however, obtain more accurate results. The accuracy of this algorithm varies with the choice of λ. Of course, λ is determined by the choice of the integers n and m, which in turn determine the values of the step sizes h and k. It can be proved that the best accuracy is always obtained from this method when the ratio λ = kc/h is equal to one—in other words, when the step in the time direction is k = h/c. For example, the choice n = 8 and m = 16 yields h = , k = , and λ = 1. The sample values listed in Table 16.3.3 clearly show the improved accuracy.

TABLE 16.3.2  
Exact Approx.
u(0.4, 0.25) = 0     u25 = 0.0185
u(0.6, 0.3) = −0.2939     u36 = −0.2727
u(0.2, 0.5) = −0.5878  u1, 10 = −0.5873
u(0.8, 0.7) = −0.1816  u4, 14 = −0.2119
TABLE 16.3.3  
Exact Approx.
u(0.25, 0.3125) = −0.2706 u25 = −0.6533
u(0.375, 0.375) = −0.6533 u36 = −0.6533
u(0.125, 0.625) = −0.2706 u1, 10 = −0.2706

Stability

We note in conclusion that this explicit finite difference method for the wave equation is stable when λ ≤ 1 and unstable when λ > 1.

16.3 Exercises Answers to selected odd-numbered problems begin on page ANS-43.

In Problems 1, 3, 5, and 6, use a computer as a computational aid.

  1. Use the difference equation (3) to approximate the solution of the boundary-value problem

    when
    (a) c = 1, a = 1, T = 1, f(x) = x(1 − x); n = 4 and m = 10
    (b) c = 1, a = 2, T = 1, f(x) = ; n = 5 and m = 10
    (c)

    n = 10 and m = 25.

  2. Consider the boundary-value problem
    1. Use the methods of Chapter 13 to verify that the solution of the problem is u(x, t) = sin πx cos πt.
    2. Use the method of this section to approximate the solution of the problem without the aid of a computer program. Use n = 4 and m = 5.
    3. Compute the absolute error at each interior grid point.
  3. Approximate the solution of the boundary-value problem in Problem 2 using a computer program with
    (a) n = 5, m = 10
    (b) n = 5, m = 20.
  4. Given the boundary-value problem

    use h = k = in equation (6) to compute the values of ui, 1 by hand.

  5. It was shown in Section 13.2 that the equation of a vibrating string is

    where T is the constant magnitude of the tension in the string and ρ is its mass per unit length. Suppose a string of length 60 centimeters is secured to the x-axis at its ends and is released from rest from the initial displacement

    Use the difference equation (3) in this section to approximate the solution of the boundary-value problem when h = 10, k = 5 and where ρ = 0.0225 g/cm, T = 1.4 × 107 dynes. Use m = 50.

  6. Repeat Problem 5 using

    and h = 10, k = 2.5. Use m = 50.