Engineering Math

The 1D wave equation

The one-dimensional wave equation is the linear PDE \[\begin{aligned} \partial_{tt}^2 u(t,x) &= c^2 \partial_{xx}^2 u(t,x). \end{aligned}\] with real constant \(c\). This equation models such phenomena as strings, fluids, sound, and light. It is subject to initial and boundary conditions and can be extended to multiple spatial dimensions. For 2D and 3D examples in rectangular and polar coordinates, see Kreyszig (2011, secs. 12.9, 12.10) and Haberman (2018, secs. 4.5, 7.3).

Example 7.3

Consider the one-dimensional wave equation PDE with real constant c and with dirichlet boundary conditions on inverval x ∈ [0,L] and with initial conditions (we need two because of the second time-derivative) $$\begin{aligned} \label{eq:1D_heat_ex_ics} u(0,x) = f(x) \quad\text{and}\quad \partial_t u(0,x) = g(x), \end{aligned}$$ where f and g are some piecewise continuous functions on [0,L].

Assume a product solution

First, we assume a product solution of the form up(t,x) = T(t)X(x) where T and X are unknown functions on t > 0 and x ∈ [0,L].

Separate PDE

Second, we substitute the product solution into [@eq:1D_wave_ex_pde] and separate variables: $$\begin{aligned} T'' X &= c^2 T X'' \Rightarrow \\ \frac{T''} {c^2 T} &= \frac{X''} {X}. \end{aligned}$$ So it is separable! Note that we chose to group c with T, which was arbitrary but conventional.

Set equal to a constant

Since these two sides depend on different independent variables (t and x), they must equal the same constant we call  − λ, so we have two ODEs: $$\begin{aligned} \frac{T''} {c^2 T} &= -\lambda \quad \Rightarrow T'' + \lambda c^2 T = 0 \\ \frac{X''} {X} &= -\lambda \quad \Rightarrow X'' + \lambda X = 0. \end{aligned}$$

Solve the boundary value problem

The latter of these equations with the boundary conditions [@eq:1D_wave_ex_bcs] is precisely the same sturm-liouville boundary value problem from , which had eigenfunctions with corresponding (positive) eigenvalues $$\begin{aligned} \lambda_n &= \left(\frac{n \pi} {L}\right)^2. \end{aligned}$$

Solve the time variable ODE

The time variable ODE is homogeneous and, with λ restricted by the reals by the boundary value problem, has the familiar general solution $$\begin{aligned} T(t) = k_1 \cos(c\sqrt{\lambda} t) + k_2 \sin(c\sqrt{\lambda} t) \end{aligned}$$ with real constants k1 and k2. However, the boundary value problem restricted values of λ to λn, so $$\begin{aligned} T_n(t) = k_1 \cos\left(\frac{c n \pi} {L} t\right) + k_2 \sin\left(\frac{c n \pi} {L} t\right). \end{aligned}$$

Construct the product solution

The product solution is $$\begin{aligned} u_p(t,x) &= T_n(t) X_n(x) \nonumber \\ &= k_1 \sin\left(\frac{n \pi} {L} x\right) \cos\left(\frac{c n \pi} {L} t\right) + k_2 \sin\left(\frac{n \pi} {L} x\right) \sin\left(\frac{c n \pi} {L} t\right). \end{aligned}$$ This is a family of solutions that each satisfy only exotically specific initial conditions.

Apply the initial conditions

Recall that superposition tells us that any linear combination of the product solution is also a solution. Therefore, $$\begin{aligned} \label{ex:PDE_wave_eq_sol} u(t,x) &= \sum_{n=1}^\infty a_n \sin\left(\frac{n \pi} {L} x\right) \cos\left(\frac{c n \pi} {L} t\right) + b_n \sin\left(\frac{n \pi} {L} x\right) \sin\left(\frac{c n \pi} {L} t\right) \end{aligned}$$ is a solution. If an and bn are properly selected to satisfy the initial conditions, will be the solution to the entire problem. Substituting t = 0 into our potential solution gives Let us extend f and g to be periodic and odd over x; we call the extensions f* and g*. From [@eq:PDE_wave_eq_sol_t0], the intial conditions are satsified if We identify these as two odd fourier syntheses. The corresponding fourier analyses are So the complete solution is [@eq:pde_2_fstar;@eq:pde_2_gstar] with components given by [@eq:pde_2_an;@eq:pde_2_bn]. Notice this satisfies the PDE, the boundary conditions, and the initial condition!

Discussion

It can be shown that this series solution is equivalent to two traveling waves that are interfering (see @haberman2018 [§ 4.4] and @kreyszig2011 [§ 12.2]). This is convenient because computing the series solution exactly requires an infinite summation. We show in the following section that the approximation by partial summation is still quite good.

Choosing specific initial conditions

If we want to plot solutions, we need to specify initial conditions over [0,L]. Let’s model a string being suddenly struck from rest as $$\begin{aligned} f(x) &= 0 \\ g(x) &= \delta(x-\Delta L) \end{aligned}$$ where δ is the dirac delta distribution and Δ ∈ [0,L] is a fraction of L representing the location of the string being struck. The odd periodic extension is an odd pulse train. The integrals of [@eq:pde_2_an;@eq:pde_2_bn] give

Now we can write the solution as $$\begin{aligned} u(t,x) &= \sum_{n=1}^\infty \frac{2} {c n \pi} \sin(n \pi \Delta) \sin\left(\frac{n \pi} {L} x\right) \sin\left(\frac{c n \pi} {L} t\right). \end{aligned}$$

Plotting in Python

First, load some Python packages.

import numpy as np
import matplotlib.pyplot as plt

Set c = L = 1 and sum values for the first N terms of the solution for some striking location Δ.

Delta = 0.1 # 0 <= Delta <= L
L = 1
c = 1
N = 150
t = np.linspace(0,30*(L/np.pi)**2,100)
x = np.linspace(0,L,150)
t_b, x_b = np.meshgrid(t,x)
u_n = np.zeros([len(x),len(t)])
for n in range(N):
  n = n+1 # because index starts at 0
  u_n += 4/(c*n*np.pi)* \
    np.sin(n*np.pi*Delta)* \
    np.sin(c*n*np.pi/L*t_b)* \
    np.sin(n*np.pi/L*x_b)

Let’s first plot some early snapshots of the response.

import seaborn as sns
n_snaps = 7
sns.set_palette(
  sns.diverging_palette(
    240, 10, n=n_snaps, center="dark"
  )
)
fig, ax = plt.subplots()
it = np.linspace(2,77,n_snaps,dtype=int)
for i in range(len(it)):
  ax.plot(x,u_n[:,it[i]],label=f"t = {t[i]:.3f}");
lgd = ax.legend(
  bbox_to_anchor=(1.05, 1), 
  loc='upper left'
)
plt.xlabel('space $x$')
plt.ylabel('$u(t,x)$')
plt.draw()
 Figure 7.4
Figure 7.4: Early snapshots of u(t,x).

Now we plot the entire response.

fig, ax = plt.subplots()
p = ax.contourf(t,x,u_n)
c = fig.colorbar(p,ax=ax)
c.set_label('$u(t,x)$')
plt.xlabel('time $t$')
plt.ylabel('space $x$')
plt.show()
 Figure 7.5
Figure 7.5: Solution u(t,x).

We see a wave develop and travel, reflecting and inverting off each boundary.

Haberman, R. 2018. Applied Partial Differential Equations with Fourier Series and Boundary Value Problems (Classic Version). Pearson Modern Classics for Advanced Mathematics. Pearson Education Canada.
Kreyszig, Erwin. 2011. Advanced Engineering Mathematics. 10^\text{th} ed. John Wiley & Sons, Limited.

Online Resources for Section 7.4

No online resources.