[Math] Solving the wave equation with Neumann boundary conditions

partial differential equationswave equation

Solve the wave equation $u_{tt} = c^2 u_{xx}$ for $0 < x < \pi$, with the boundary conditions $u_x(0,t) = u_x(\pi,t) = 0$ and initial conditions $u(x,0) = \cos(x)$ and $u_t(x,0) = \cos^{2}(x)$.

Attempted solution – We know that the general solution for Neumann boundary conditions for the wave equation for $0 < x < l$ is
$$u(x,t) = \frac{1}{2}A_0 + \frac{1}{2}B_0 t + \sum_{n=1}^{\infty}\left(A_n\cos \frac{n\pi c t}{l} + B_n \sin\frac{n\pi c t}{l}\right)\cos\frac{n\pi x}{l}$$
Thus in our case we have
$$u(x,t) = \frac{1}{2}A_0 + \frac{1}{2}B_0 t + \sum_{n=1}^{\infty}\left(A_n\cos(nct) + B_n \sin(nct)\right)\cos(nx)$$
Note that
$$A_n = \frac{2}{\pi}\int_{0}^{\pi}\phi(x)\cos(nx)dx$$
and $$B_n = \frac{2}{\pi}\int_{0}^{\pi}\phi(x)\sin(nx)dx$$

Applying the initial conditions we have

$$u(x,0) = \frac{1}{2}A_0 + \sum_{n=1}^{\infty}A_n\cos(nx) = \cos(x)$$

Thus,

$$A_0 = \frac{2}{\pi}\int_{0}^{\pi}\cos(x)dx = 0$$
and
$$A_n = \frac{2}{\pi}\int_{0}^{\pi}\cos(x)\cos(nx)dx = … = -\frac{2n\sin(n\pi)}{\pi(n^2-1)} \ \ \text{according to Wolfram}$$

Next,

$$u_t(x,0) = \frac{1}{2}B_0 + \sum_{n=1}^{\infty}B_n\times n\times c \cos(nx) = \cos^{2}(x)$$

From here onward I am not sure how to proceed and I find the answer from wolfram rather odd, if anyone can provide details of what I did wrong or should revise please let me know.

The answer should be $$u(x,t) = \frac{1}{2}t + \cos(ct)\cos(x) + \frac{1}{4c}\sin(2ct) + \cos(2x)$$

Best Answer

Assuming $u(t,x)=T(t)X(x)$, the separated equations are $$ \frac{T''}{c^2 T} = \lambda, \;\; \lambda = \frac{X''}{X}, \; X'(0)=X'(\pi)=0. $$ The $X$ solutions dictate the values of $\lambda$ to be $-n^2$ for $n=1,2,3,\cdots$, and the corresponding eigenfunctions are unique up to multiplicative constants, and are given by $$ X_n(x) = \cos(n x),\;\;\; n=0,1,2,3,\cdots. $$ The general solution is $$ u(x,t) = (A_0+B_0t)+\sum_{n=1}^{\infty}\left(A_n\cos(nc t)+B_n\sin(nc t)\right)\cos(n x). $$ The constants $A_n,B_n$ are determined by the initial conditions: $$ \cos(x) = u(x,0) = A_0+\sum_{n=1}^{\infty}A_n\cos(n x), \\ \cos^2(x) = u_{t}(x,0) = B_0+\sum_{n=1}^{\infty}nc B_n\cos(n x). $$ The mutual orthogonality of the functions $\{ \cos(n\pi x) \}_{n=0}^{\infty}$ in $L^2[0,\pi]$ is used to determine the coefficients $A_n$ and $B_n$ in the usual manner of Fourier, which is simplified after applying the identity $$ \cos^2(x) = \frac{1+\cos(2x)}{2}. $$