Solving the wave equation with Neumann conditions I have some difficulties solving this Wave Equation under Neumann BC. Here is what I have so far.
$u_{tt} = 4u_{xx}$ for $0<x<\pi, t>0$
$u_x(0,t) = u_x(\pi$, t) = 0 for t>0
$u(x,0) = 0, u_t(x,0) = \sin(x), 0 <= x <= \pi$
I used the separation of variables method to solve this problem.
$u(x,t) = X(x)T(t)$
$\frac{-X''(x)}{X(x)} = \frac{-1}{4}\frac{T''(t)}{T(t)} = \lambda$
BC: $X'(0) = 0$ and $X'(\pi) = 0$
IC: $T(0) = 0$ and $T'(0) = \sin (x)$
I get $u(x,t) = \frac{1}{2}A_0t + \frac{1}{2}B_0$ + $\sum_{n=1}^\infty(A_n \cos (4nt) + B_n \sin (4nt))\cos(nx)$
I think everything here so far is correct.
Here is where I am stuck:
I need $\psi(x) = \sin (x)$ = $\frac{1}{2}B_0$ + $\sum_{n=1}^\infty$$4n B_n \cos(nx)$
Do I calculate the coefficients $B_n$ using 
$4nB_n$ = $\frac{2}{\pi} \int_0^\pi \sin(x) \cos(nx) dx$ ?
or
$B_n$ = $\frac{2}{\pi} \int_0^\pi \sin(x) \cos(nx) dx$
Thanks for any help.
 A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$\ds{{\rm u}_{tt}\pars{x,t} = 4{\rm u}_{xx}\pars{x,t}\,,\quad x \in \pars{0,\pi}\,,
     \quad t > 0.\qquad
     \color{#00f}{{\rm u}_{x}\pars{0,t} = {\rm u}_{x}\pars{\pi,t} = 0}.\quad
     \color{#c00000}{{\rm u}\pars{x,0}=0\,,\ {\rm u}_{t}\pars{x,0} = \sin\pars{x}}}$

The general solution has the form
  $\ds{\color{#c00000}{%
{\rm u}\pars{x,t} \equiv \fermi\pars{x - 2t} + {\rm g}\pars{x + 2t}}}$ where $\ds{\fermi}$ and $\ds{\rm g}$ are functions to be determined. First, we'll find the solution for a general $\ds{{\rm u}_{t}\pars{x,0} \equiv \phi\pars{x}}$. Later on, $\ds{\phi\pars{x}}$ is chosen to agree with the original condition and in such way it satisfies the remaining boundary conditions.

$$
\begin{array}{rclcrcrcl}
{\rm u}\pars{x,0} & = & 0 & \imp & \fermi\pars{x} & + & {\rm g}\pars{x} & = & 0
\\
{\rm u}_{t}\pars{x,0} & = & 0 & \imp & -2\fermi'\pars{x} & + & 2{\rm g}'\pars{x}
& = & \phi\pars{x}
\end{array}
$$
$$
\mbox{which yields}\quad
{\rm g}\pars{x} = -\fermi\pars{x}\,,\quad
\fermi\pars{x} = \fermi\pars{0} - {1 \over 4}\int_{0}^{x}\phi\pars{\xi}\,\dd\xi
$$

Then
  \begin{align}
{\rm u}\pars{x,t}&=
\bracks{\fermi\pars{0} - {1 \over 4}\int_{0}^{x - 2t}\phi\pars{\xi}\,\dd\xi}
+\bracks{-\fermi\pars{0} + {1 \over 4}\int_{0}^{x + 2t}\phi\pars{\xi}\,\dd\xi}
\\[3mm]&={1 \over 4}\int_{x - 2t}^{x + 2t}\phi\pars{\xi}\,\dd\xi
\end{align}
  Whenever $\ds{\phi\pars{x}}$ is defined in $\pars{0,\pi}$, this solution becomes invalid whenever $\ds{x \pm 2t}$ 'leaves' $\pars{0,\pi}$. That's is the reason we extend the initial condition.
$$
\begin{array}{rclcrcl}
{\rm u}_{x}\pars{0,t} & = & 0 & \imp & \phi\pars{2t} - \phi\pars{-2t} & = & 0 
\\
{\rm u}_{x}\pars{\pi,t} & = & 0 & \imp & \phi\pars{\pi + 2t} - \phi\pars{\pi - 2t}
& = & 0 
\end{array}
$$
  Those conditions are equivalent to:
  $$
\phi\pars{-\xi} = \phi\pars{\xi}\,,\qquad\phi\pars{\xi + 2\pi} = \phi\pars{\xi}.
\quad\mbox{Also,}\ \left.\phi\pars{\xi}\right\vert_{\xi\ \in\ \pars{0,\pi}}\
=\sin\pars{\xi}
$$

which yields
\begin{align}
&\color{#00f}{\large{\rm u}\pars{x,t}=
{1 \over 4}\int_{x - 2t}^{x + 2t}\phi\pars{\xi}\,\dd\xi}
\\[3mm]&
\mbox{where}\quad\color{#c00000}{\large%
\phi\pars{\xi}
\equiv
\left\lbrace\begin{array}{ccrcccl}
\sin\pars{\xi} & \mbox{if} & 0 & \leq & \xi & \leq & \pi
\\[1mm]
\phi\pars{-\xi} & \mbox{if} & -\pi & \leq & \xi & < & 0
\\[1mm]
\phi\pars{\xi + 2\pi} & \mbox{if} & \xi & < & -\pi&&
\\[1mm]
\phi\pars{\xi - 2\pi} & \mbox{if} & \xi & > & \pi&&
\end{array}\right.}
\end{align}
A: Indeed, everything correct until you stuck. What about $A_n$? You don't mention that $A_n=0\,$. From your expansion
$$
\sin{(x)}=\frac{1}{2}B_0+\sum_{n=1}^{\infty}4nB_n\cos{(nx)},
$$
it is absolutely clear that Fouries coefficients of $\sin{(x)}$ are 
$$
\frac{1}{2}B_0\,,4B_1\,,8B_2\,,\dots, 4nB_n\,,\dots
$$
Hence you have
$$
\begin{align*}
\frac{1}{2}B_0=\frac{2}{\pi}\int\limits_0^{\pi}\sin{(x)}\,dx,\\
4B_n=\frac{2}{\pi}\int\limits_0^{\pi}\sin{(x)}\cos{(nx)}\,dx,\;n\geqslant 1.
\end{align*}
$$
