Wave Equation Example

Consider the wave equation $$ u_{tt} = 4 u_{xx}, \ 0 \leq x \leq 2, t \geq 0 $$ with boundary conditions $u(0,t) = u(2,t) = 0$
and initial conditions
$u(x,0) = 1 - (x-1)^2$,
$u_t(x,0) = \sin \left( \frac{\pi}{2} x \right) - 3\sin \left( 7 \frac{\pi}{2} x \right).$

1) Solution for $t=0$

We begin by finding the fourier coefficients of $u(x,0)$, which are $$ F_n = \frac{2}{L} \int_0^2 (2x-x^2)\sin(\frac{n\pi}{2}x) \ dx = \frac{16}{\pi^3 n^3} \left( 1 - (-1)^n \right). $$ Note that this means $F_n = \frac{32}{\pi^3 n^3}$ when $n$ is odd and $0$ when $n$ is even.

We now have the Fourier (sine) series coefficients for our starting function.

Below is a graph of our string's initial position modeled by $f(x) = 1 - (x-1)^2$.

Click the blue box to see the $n$th Fourier term $\frac{16}{\pi^3 n^3} \left( 1 - (-1)^n \right) \sin(n \pi x).$ Then change your click to the golden box the a Fourier series accurate up to the $n$th term. It gets accurate surprisingly fast.





2) Accounting for Time

Let's take a moment to see why the Fourier coefficients for $u(x,0)$ gave us a solution for $t=0$ in the context of the general solution.

Recall that the general solution is given as $$ \sum_{n=1}^{\infty} \sin \left( \frac{n\pi}{L}x \right) \left( A_n \cos(\lambda_n t) + B_n \sin(\lambda_n t) \right) . $$ Now, when $t=0$ we get $$ \sum_{n=1}^{\infty} \sin \left( \frac{n\pi}{L}x \right) \left( A_n \cos(0) + B_n \sin(0) \right) = \sum_{n=1}^{\infty} \sin \left( \frac{n\pi}{L}x \right)(A_n) . $$ And there we go! Since $A_n$ is the $n$th Fourier coefficient of $u(x,0)$, the sum above is the Fourier series expression of $u(x,0)$.

To add a time element, we need to multiply our sine terms by $\left( A_n \cos(\lambda_n t) + B_n \sin(\lambda_n t) \right)$ instead of just $A_n$. And to do that, we need to compute the $B_n$s. Fortunately, that consists of just finding the $n$th Fourier sine coefficient of our other initial condition $u_t(x,0)$ and dividing by $\lambda_n$.

Fourier Coefficients for $u_t(x,0)$: Since $u_t(x,0) = \sin \left( \frac{\pi}{2} x \right) - 3\sin \left( 7 \frac{\pi}{2} x \right)$, the first coefficient is 1 and the seventh is -3. All the rest are 0. No integrals are necessary here. This was easy because the function is already a Fourier series to begin with. Imagine me asking you what the Taylor series of $f(x) = x^3 - 5$ is.
...Hopefully your answer would be "$x^3 - 5$."

Now divide each of these two coefficients by $\lambda_n = \frac{cn\pi}{L} = \frac{(2)n\pi}{(2)} = n\pi$. $B_1 = \frac{1}{(1)\pi}$ and $B_7 = -\frac{3}{(7)\pi}$.

With the rest of the coefficients found, we can model a pretty accurate version of a guitar string below with only $n=7$. Click on the $t$-slider and hold down your right arrow button to see what the wave does over time. How does it change if you move $n$ to 5? Why do you think that is?