# Solving inhomogeneous PDEs with ODEs

I am trying to understand a general method of solving an inhomogeneous PDE. I have begun with the Heat equation but am stuck with the last step.

For instance, solving $$\begin{cases}u_t=u_{xx}+g(x)\\ u(0,t)=0=u(L,t)\\ u(x,0)=f(x) \end{cases}$$

So first of all I break the functions into two Fourier series: $$f(x)=\sum a_n\sin\left(\frac{n \pi x}{L}\right ) \qquad g(x)=\sum b_n\sin\left(\frac{n \pi x}{L}\right )$$ Then, letting the particular solution be $$u(x,t)=\sum U_n(t)\sin\left(\frac{n \pi x}{L}\right )$$ This can be reduced to an ODE $$\dot{U_n(t)}=-\left(\frac{n\pi}{L}\right)^2U_n(t)+b_n$$ with $U_n(0)=a_n.$

When this is solved, it should be able to give the function of $t$ in the Fourier series. This is where I am stuck. How do I solve an ODE like this? And is this the best method to solve the PDE?

• It's a first order ODE.. You could use separation of variables. Or an integrating factor. Or use method of undetermined coefficients. Either way, you will need conditions to solve for the explicit function. – mattos Apr 18 '15 at 13:41

Starting from

$$U_n'(t)+\left(\frac{n\pi}{L}\right)^2 U_n(t)=b_n$$

with $U_n(0)=a_n$, we can find a solution for $U_n(t)$ using a variety of methods. Here, we will use LaPlace Transforms.

Let $\hat U_n(s)$ be the Laplace transform of $U_n(t)$. Taking the Laplace transform of the ODE reveals

$$(s\hat U_n(s)-U_n(0))+\left(\frac{n\pi}{L}\right)^2 \hat U_n(s)=\frac{b_n}{s}$$

Now, solving for $\hat U_n(s)$, using $U_n(0)=a_n$, and expanding in partial fractions yields

$$\hat U_n(s)=\frac{a_n-\frac{b_n}{(n\pi/L)^2}}{s+(n\pi/L)^2}+\frac{b_n}{(n\pi/L)^2}\frac{1}{s}$$

whereby inverting the Laplace Transform $\hat U_n(s)$, we see that

$$U_n(t) = \frac{b_n}{(n\pi/L)^2}+\left(a_n-\frac{b_n}{(n\pi/L)^2}\right)e^{-(n\pi/L)^2t}$$

Finally, the solution for u(x,t) is given by \begin{align} u(x,t) &=\sum_{n=1}^{\infty} \left(\frac{b_n}{(n\pi/L)^2}+\left(a_n-\frac{b_n}{(n\pi/L)^2}\right)e^{-(n\pi/L)^2t}\right)\sin\left(\frac{n\pi x}{L}\right)\\\\ =&\sum_{n=1}^{\infty} a_ne^{-(n\pi/L)^2t}\sin\left(\frac{n\pi x}{L}\right)\\\\ &+\sum_{n=1}^{\infty} b_n\left(\frac{1-e^{-(n\pi/L)^2t}}{(n\pi/L)^2}\right) \sin\left(\frac{n\pi x}{L}\right) \end{align} • Could you explain how you foundU_n(t)? – AccioHogwarts Apr 18 '15 at 14:49 • Yes. I've added quite a bit more to provide a solution methodology. Please let me know if I can improve the answer further. – Mark Viola Apr 18 '15 at 15:14 • Thank you very much, this is very comprehensive. However, I have never covered Laplace transforms. Would it be too much to ask if you could perhaps solve it by way of separation of variables? I attempted using this method to get your answer initially but ended up with something different. – AccioHogwarts Apr 18 '15 at 18:43 Going on the question you asked MV in his comments, I'll do it for you by separation of variables (note that using the Laplace Transform method MV used is a much better choice for this problem). We have $$U' = b_{n} - \bigg( \frac{n \pi}{L} \bigg)^{2} U$$ We will call $$m = \frac{n \pi}{L}$$ Separating and integrating \begin{align} \implies \int \frac{1}{ b_{n} - m^{2} U} dU &= \int dt \\ \implies - \bigg( \frac{1}{m} \bigg)^{2} \ln ( b_{n} - m^{2} U ) &= t + K \\ \implies \ln ( b_{n} - m^{2} U ) &= - m^{2} (t + K) \\ \implies b_{n} - m^{2} U &= \exp (- m^{2} (t + K) ) \\ &= \exp (- m^{2} t) \exp (- m^{2} K) \\ \implies m^{2} U &= b_{n} - \exp (- m^{2} t) \exp (- m^{2} K) \\ \implies U &= \frac{b_{n}}{m^{2}} - \frac{\exp (- m^{2} t) \exp (- m^{2} K)}{m^{2}} \ \ (*) \\ \implies U(0) &= \frac{b_{n}}{m^{2}} - \frac{\exp ( - m^{2} K)}{m^{2}} \\ &= a_{n} \\ \implies \frac{b_{n}}{m^{2}} - a_{n} &= \frac{\exp (- m^{2} K)}{m^{2}} \ \ (**) \\ \end{align} Inserting(**)$into$(*), we get \begin{align} U (t) &= \frac{b_{n}}{m^{2}} - \exp (- m^{2} t) \bigg[ \frac{b_{n}}{m^{2}} - a_{n} \bigg] \\ &= \frac{b_{n}}{m^{2}} + \bigg[ a_{n} - \frac{b_{n}}{m^{2}} \bigg] \exp (- m^{2} t) \end{align} which is the same as MV when you replacem$with$\frac{n \pi}{L}\$. As you can see though, some methods are easier to implement.