I'm working on a course problem,
The position of a vibrating string evolves according to the partial differential equation $$u_{xx}=\frac{1}{c^2}u_{tt}.$$ The ends of the string at $x=0$ and $x=a$ are fixed at $u=0$, and initially the string is at rest. Show that this configuration has the general solution $$u(x,t)=\sum_{n=0}^\infty A_n\sin\left(\frac{n\pi}{a}x\right)\cos\left(\frac{n\pi}{a}ct\right).$$ If $a=\pi$ and initially $u=\epsilon\sin(3x)\cos(x)$, where $\epsilon$ is a constant, determine the $A_n$ for this case.
For the $A_n$, can I just say $$A_n=\begin{cases}\epsilon\cos(x)&&n=3\\ 0&&\text{otherwise}\end{cases}$$? If I try to treat it as a Fourier sine series, I get \begin{align} A_n & = \frac{2}{\pi}\int_0^\pi\epsilon\sin(3x)\cos(x)\sin(nx)\text{ d}x \\ & = \frac{2\epsilon}{\pi}\int_0^\pi \frac{1}{2}[\cos((3-n)x)-\cos((3+n)x)]\cos(x)\text{ d}x, \\ & \hspace{1.2em} \text{ by compound angle formula for } \sin(mx)\sin(nx) \\ & = \begin{aligned}[t] \frac{\epsilon}{\pi}\int_0^\pi & \frac{1}{2}[\cos((3-n-1)x)-\cos((3-n+1)x)] \\ - & \frac{1}{2}[\cos((3+n-1)x)-\cos((3+n+1)x)]\text{ d}x, \end{aligned} \\ & \hspace{1.2em} \text{ by compound angle formula for } \cos(mx)\cos(nx) \\ & = 0, \text{ since sin of integer multiples of } \pi, \end{align} which I presume is wrong. Could someone point out where I've gone wrong?
The correct product-to-sum identity is $$ \cos(A)\cos(B) = \frac{1}{2}\Big[\cos(A + B) + \cos(A - B)\Big]. $$
Edit: Oh, forgot to answer your question about $A_n$: No, your proposed $A_n$ is incorrect since they are supposed to be numbers, not functions of $x$. You really just need to compute $A_n$ which is the integral that you have, and I don't imagine you have any problem computing that (:
Now, \begin{align*} A_n & = \frac{\varepsilon}{\pi}\int_0^\pi \Big[\cos((3 - n)x)\cos x - \cos((3 + n)x)\cos x\Big]\, dx. \end{align*} Using orthogonality of the family of functions $\{\cos(mx)\}_{m = 0}^\infty$ over the interval $[0, \pi]$, the second integral vanishes for all $n\ge 0$. In particular, $A_n\neq 0$ when $3 - n = \pm 1$ or $n = 2, 4$: \begin{align*} A_2 = A_4 = \frac{\varepsilon}{\pi}\int_0^\pi \cos^2x\, dx = \frac{\varepsilon}{\pi}\cdot \frac{\pi}{2} = \frac{\varepsilon}{2}. \end{align*}