# Solving the wave equation with Neumann boundary conditions

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 solve by the separation of variables $$u(x,t) = X(x)T(t)$$ This PDE yields $$\frac{X^{\prime\prime}}{X} = \frac{T^{\prime\prime}}{c^2 T} = -\lambda$$ Again rearranging we have two ODE's, $$X^{\prime\prime} + \lambda X = 0, \ \ \ T^{\prime\prime} + c^2 \lambda T = 0$$ We now consider the boundary conditions to get the eigenvalue problem $$X^{\prime}(0) = X^{\prime}(\pi) = 0 \Rightarrow \lambda_n = \left(\frac{n\pi}{\pi} \right)^{2} = n^2, X_n = \cos\left(\frac{n\pi x}{\pi} \right) = \cos(nx) \ \ n = 0,1,2\ldots$$ So, \begin{align*} T_n(t) &= c_1 \cos\left(\frac{cn\pi t}{\pi} \right) + c_2 \sin\left(\frac{cn \pi t}{\pi} \right)\\ &= c_1 \cos(cnt) + c_2 \sin(cnt) \ \ n = 1,2,3,\ldots\\ T_0(t) &= c_1 + c_2 t \end{align*} So, $$u(x,t) = \frac{1}{2}A_0 + \frac{1}{2}B_0 + \sum_{n=1}^{\infty}\left(A_n \cos(cnt) + B_n\sin(cnt) \right)\cos(nx)$$

Before I continue and find the coefficients and apply the initial conditions I wanted to know if my approach to this problem is on the right track or not. Any comments are appreciated.

## 1 Answer

The general solution can be written as $$u(x,t) = \sum_{n=1}^{\infty}(A_n \cos(cnt) + B_n\sin(cnt))cos(nx) + A_0 + B_0 t$$ Note that

$$u(x,0) = \sum_{n=1}^{\infty} A_n\cos(nx) + A_0 = \cos(x) \Rightarrow A_1 = 1, A_n = 0 \ \text{for} \ n\neq 1$$ We see that $$A_0 = \frac{2}{\pi}\int_{01}^{\pi}\cos(x)dx = 0$$ Moreover we see, $$u_t(x,t) = \sum_{n=1}^{\infty}(-A_n(nc)\sin(cnt) + B_n(nc)\cos(cnt))\cos(nx) + B_0$$ Thus, $$u_t(x,0) = \sum_{n=1}^{\infty} nc B_n \cos(nx) + B_0 = \cos^{2}(x) = \frac{1}{2} + \frac{\cos(2x)}{2}$$ Then we see that $B_0 = \frac{1}{2}$. Further note that $$\cos(x) = u(x,0) = A_0 + \sum_{n=1}^{\infty}A_n \cos(nx)$$ That$A_0$ is the coefficient $1$ in the orthogonal set $\{1,\cos(x),\cos(2x),\ldots\}$ That means $A_0 = 0$ and $A_1 = 1$ and $A_n = 0$ for $n > 1$. Then $$\frac{1}{2} + \frac{cos(2x)}{2} = B_0 + c B_1 \cos(x) + 2c B_@ \cos(sx) + 3c B_3 \cos(3x) + \ldots$$ which gives $B_0 = 1/2, B_1 = 0, B_2 = 1/4c$ and $B_n = 0$ for $n\geq 3$. Finally we have the solution:

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