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)$$


$$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}$$


$$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)$$

  • 1
    $\begingroup$ You find the coefficients by using the initial conditions: what's $\phi(x)$ in your case? $\endgroup$
    – NickD
    Commented Jun 24, 2017 at 23:39
  • $\begingroup$ @Nick I edited my post, I know we use the initial conditions to find the coefficients but I am not sure how to proceed from where I left off $\endgroup$
    – justanewb
    Commented Jun 24, 2017 at 23:46
  • $\begingroup$ @Nick I do believe that $A_0 = 0$ in this case $\endgroup$
    – justanewb
    Commented Jun 24, 2017 at 23:47
  • $\begingroup$ If you can identify what $\phi(x)$ is in your case, you can subtitute it into the integrals for $A_n$ and $B_n$ and find all the coefficients. $\endgroup$
    – NickD
    Commented Jun 24, 2017 at 23:49
  • $\begingroup$ $\phi(x) = \cos(x)$ correct? $\endgroup$
    – justanewb
    Commented Jun 24, 2017 at 23:50

1 Answer 1


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}. $$

  • $\begingroup$ Can you give more detail on how to find $A_0,A_n$ and $B_n$ with the identity you mention at the bottom. I am still stuck... $\endgroup$
    – justanewb
    Commented Jun 29, 2017 at 19:14
  • $\begingroup$ @Wolfgang : You can see from the equation $\cos(x)=u(x,0)=A_0+\sum_{n=1}^{\infty}A_n\cos(nx)$ that $A_0$ is the coefficient of $1$ in the orthogonal set $\{1,\cos(x),\cos(2x),\cdots\}$. That means $A_0=0$ and $A_1=1$ and $A_n=0$ for $n > 1$. Then $\frac{1+\cos(2x)}{2}=B_0+cB_1\cos(x)+2cB_2\cos(2x)+3cB_3\cos(3x)$ gives $B_0=1/2$, $B_1=0$, $B_2=1/4c$, and $B_n=0$ for $n \ge 3$. $\endgroup$ Commented Jun 29, 2017 at 19:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .