Consider this PDE
The solution to the PDE is
So what I am having trouble is solving it using this method.
I am going to say that my $u(x,t) = \sum_{n=1}^{\infty} u_n(t) \sin(nx)$ and $x \sin(t) = \sum_{n=1}^{\infty}h_n(t)\sin(nx)$
The reason I chose sine for my inhomogeneous term is because my book recommends it. But I think it is because if I use cosine, I would get a $\frac{a_0}{2}$ term and it would be difficult.
To solve for the coefficients of $h_n(t)$, I get $h_n(t) = \frac{2}{\pi}\int_{0}^{\pi} x\sin(t) \sin(nx) dx = \frac{2\sin(t)(-1)^n}{n}$
Substituting everything into $u_{tt} = u_{xx} + x\sin(t)$ gives me
$ \sum_{n=1}^{\infty}u''_n(t) \sin(nx) + \sum_{n=1}^{\infty}u_n(t)n^2\sin(nx) = \sum_{n=1}^{\infty}\frac{2\sin(t)(-1)^n}{n}\sin(nx)$
Dividing out that sine, I'll get
$ \sum_{n=1}^{\infty}u''_n(t) + \sum_{n=1}^{\infty}u_n(t)n^2 = \sum_{n=1}^{\infty}\frac{2\sin(t)(-1)^n}{n}$
Here is where I am stuck, can someone tell me what value of n to use?
Thank you very much