# PDE with series

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

-

I might do it this way, using Duhamel's principle. Start by looking for the solution $\phi(x,t,s)$ to the homogeneous partial differential equation (the ordinary wave equation $\dfrac{\partial^2 \phi}{\partial t^2} = \dfrac{\partial^2 \phi}{\partial x^2}$, depending on the parameter $s$, with boundary conditions $\phi(0,t,s)=\phi(\pi,t,s) = 0$ and initial conditions $\phi(x,0,s)=0$, $\dfrac{\partial \phi}{\partial t}(x,0,s) = x \sin(s)$. Then a solution of your nonhomogeneous wave equation is $u(x,t) = \int_0^t \phi(x,t-s,s)\ ds$.
EDIT: Here's another way, if you don't want to use Duhamel's principle. Let $u(x,t)$ be expanded in a Fourier series $u(x,t) = \sum_{n=1}^\infty u_n(t) \sin(n x)$ (we use sines rather than cosines here because of the boundary conditions $u(0,t) = u(\pi,t) = 0$). Correspondingly, the same type of Fourier series for the inhomogeneous term is $x \sin(t)= \sum_{n=1}^\infty a_n \sin(n x) \sin(n t)$ where $$a_n = \dfrac{2}{\pi} \int_0^\pi x \sin(n x)\ dx = \dfrac{2}{n} (-1)^{n+1}$$ Plugging these into the pde and the initial condition, for the coefficients of $\sin(n x)$ to balance we need $$u_n''(t) = -n^2 u_n(t) + a_n \sin(t), \ u_n(0) = 0, \ u_n'(0) = 0$$ For $n \ne 1$ the solution of this (which you can get using the method of Undetermined Coefficients) is $$u_n(t) = \dfrac{a_n}{n(n^2-1)}(n \sin(t) - \sin(nt)) = \dfrac{2 (-1)^{n+1}}{n^2 (n^2-1)} (n \sin(t) - \sin(nt))$$ For $n=1$ that solution doesn't work (it's the case of "resonance") and the solution is $$u_1(t) = \dfrac{a_1}{2} (\sin(t) - t \cos(t)) = 2 (\sin(t) - t \cos(t))$$ Thus putting it all together, $$u(x,t) = 2 \sin(x) (\sin(t) - t \cos(t)) + \sum_{n=2}^\infty \dfrac{2 (-1)^{n+1}}{n^2 (n^2-1)} \sin(nx) (n \sin(t) - \sin(nt))$$