Skip to article frontmatterSkip to article content

The wave equation

Closely related to the advection equation is the wave equation,

uttc2uxx=0. u_{tt} - c^2 u_{xx} = 0.

This is our first PDE having a second derivative in time. As in the advection equation, u(x,t)=ϕ(xct)u(x,t)=\phi(x-ct) is a solution of (12.4.1), but now so is u(x,t)=ϕ(x+ct)u(x,t)=\phi(x+c t) for any twice-differentiable ϕ (see Exercise 2). Thus, the wave equation supports advection in both directions simultaneously.

We will use x[0,1]x \in [0,1] and t>0t>0 as the domain. Because uu has two derivatives in tt and in xx, we need two boundary conditions. We will use the Dirichlet conditions

u(0,t)=u(1,t)=0,t0,u(0,t) = u(1,t) = 0, \qquad t \ge 0,

and two initial conditions,

u(x,0)=f(x),0x1,ut(x,0)=g(x),0x1.\begin{split} u(x,0) &= f(x), \qquad 0 \le x \le 1, \\ u_t(x,0) &= g(x), \qquad 0 \le x \le 1. \end{split}

One approach is to discretize both the uttu_{tt} and uxxu_{xx} terms using finite differences:

1τ2(Ui,j+12Ui,j+Ui,j1)=c2h2(Ui+1,j2Ui,j+Ui1,j).\frac{1}{\tau^2}(U_{i,j+1} - 2U_{i,j} + U_{i,j-1}) = \frac{c^2}{h^2} (U_{i+1,j} - 2U_{i,j} + U_{i-1,j}).

This equation can be rearranged to solve for Ui,j+1U_{i,j+1} in terms of values at time levels jj and j1j-1. Rather than pursue this method, however, we will turn to the method of lines.

12.4.1First-order system

In order to be compatible with the standard IVP solvers that we have encountered, we must recast (12.4.1) as a first-order system in time. Using our typical methodology, we would define y=uty=u_t and derive

ut=y,yt=c2uxx.\begin{split} u_t &= y, \\ y_t &= c^2 u_{xx}. \end{split}

However, there is another, less obvious option for reducing to a first-order system:

ut=zx,zt=c2ux.\begin{split} u_t &= z_x, \\ z_t &= c^2 u_{x}. \end{split}

This second form is appealing in part because it’s equivalent to Maxwell’s equations for electromagnetism. In the Maxwell form we typically replace the velocity initial condition in (12.4.3) with a condition on zz, which may be physically more relevant in some applications:

u(x,0)=f(x),0x1,z(x,0)=g(x),0x1.\begin{split} u(x,0) &= f(x), \qquad 0 \le x \le 1, \\ z(x,0) &= g(x), \qquad 0 \le x \le 1. \end{split}

Because waves travel in both directions, there is no preferred upwind direction. This makes a centered finite difference in space appropriate. Before application of the boundary conditions, semidiscretization of (12.4.6) leads to

[u(t)z(t)]=[0Dxc2Dx0][u(t)z(t)]. \begin{bmatrix} \mathbf{u}'(t) \\[2mm] \mathbf{z}'(t) \end{bmatrix} = \begin{bmatrix} \boldsymbol{0} & \mathbf{D}_x \\[2mm] c^2 \mathbf{D}_x & \boldsymbol{0} \end{bmatrix} \begin{bmatrix} \mathbf{u}(t) \\[2mm] \mathbf{z}(t) \end{bmatrix}.

The boundary conditions (12.4.2) suggest that we should remove both of the end values of u\mathbf{u} from the discretization, but retain all of the z\mathbf{z} values. We use w(t)\mathbf{w}(t) to denote the vector of all the unknowns in the semidiscretization. When computing w(t)\mathbf{w}'(t), we extract the u\mathbf{u} and z\mathbf{z} components, and we use dedicated functions for padding with the zero end values or chopping off the zeros as necessary.

12.4.2Variable speed

An interesting situation is when the wave speed cc changes discontinuously, as when light passes from one material into another. For this we must replace the term c2c^2 in (12.4.8) with the matrix diag(c2(x0),,c2(xm))\operatorname{diag}\bigl(c^2(x_0),\ldots,c^2(x_m)\bigr).

12.4.3Exercises

  1. ✍ Consider the Maxwell equations (12.4.6) with smooth solution u(x,t)u(x,t) and z(x,t)z(x,t).

    (a) Show that utt=c2uxxu_{tt} = c^2 u_{xx}.

    (b) Show that ztt=c2zxxz_{tt} = c^2 z_{xx}.

  1. ✍ Suppose that ϕ(s)\phi(s) is any twice-differentiable function.

    (a) Show that u(x,t)=ϕ(xct)u(x,t) = \phi(x-c t) is a solution of utt=c2uxxu_{tt}=c^2u_{xx}. (As in the advection equation, this is a traveling wave of velocity cc.)

    (b) Show that u(x,t)=ϕ(x+ct)u(x,t) = \phi(x+c t) is another solution of utt=c2uxxu_{tt}=c^2u_{xx}. (This is a traveling wave of velocity c-c.)

  2. ✍ Show that the following is a solution to the wave equation utt=c2uxxu_{tt}=c^2u_{xx} with initial and boundary conditions (12.4.2) and (12.4.3):

    u(x,t)=12[f(xct)+f(x+ct)]+12cxctx+ctg(ξ)dξu(x,t) = \frac{1}{2} \left[ f(x-ct)+f(x+ct)\right] + \frac{1}{2c} \int_{x-ct}^{x+ct} g(\xi) \, d\xi

    This is known as D’Alembert’s solution.

  3. ⌨ Suppose the wave equation has homogeneous Neumann conditions on uu at each boundary instead of Dirichlet conditions. Using the Maxwell formulation (12.4.6), we have zt=c2uxz_t=c^2u_x, so zz is constant in time at each boundary. Therefore, the endpoint values of z\mathbf{z} can be taken from the initial condition and removed from the ODE, while the entire u\mathbf{u} vector is now part of the ODE.

    Modify Demo 12.4.1 to solve the PDE there with Neumann instead of Dirichlet conditions, and make an animation or space-time portrait of the solution. In what major way is it different from the Dirichlet case?

  4. ⌨ The equations ut=zxσuu_t=z_x-\sigma u, zt=c2uxxz_t=c^2u_{xx} model electromagnetism in an imperfect conductor. Repeat Demo 12.4.2 with σ(x)=2+2sign(x)\sigma(x)=2+2\operatorname{sign}(x). (This causes waves in the half-domain x>0x>0 to decay in time.)

  5. The nonlinear sine–Gordon equation uttuxx=sinuu_{tt}-u_{xx}=\sin u has interesting solutions.

    (a) ✍ Write the equation as a first-order system in the variables uu and v=utv=u_t.

    (b) ⌨ Assume periodic end conditions on [10,10][-10,10] and discretize at m=200m=200 points. Let u(x,0)=πex2u(x,0) = \pi e^{-x^2} and ut(x,0)=0u_t(x,0) = 0. Solve the system using RK4 between t=0t=0 and t=50t=50, and make a plot or animation of the solution.

  6. The deflections of a stiff beam, such as a ruler, are governed by the PDE utt=uxxxxu_{tt}=-u_{xxxx}.

    (a) ✍ Show that the beam PDE is equivalent to the first-order system

    ut=vxx,vt=uxx.\begin{align*} u_t &= v_{xx}, \\ v_t &= -u_{xx}. \end{align*}

    (b) ⌨ Assuming periodic end conditions on [1,1][-1,1], use m=100m=100, let u(x,0)=exp(24x2)u(x,0) =\exp(-24x^2), v(x,0)=0v(x,0) = 0, and simulate the solution of the beam equation for 0t10\le t \le 1 using Function 6.7.2 with n=100n=100 time steps. Make a plot or animation of the solution.