# Heat equation

##### New member
Hi!

I need to find out how to solve this type of heat equations:
$$\large \frac{du}{dt} - \frac{d^2u}{dx^2} = \sin \pi x$$
$$\large u|_{t=0} = \sin 2\pi x$$
$$\large \large u|_{x=0} = u|_{x=1} = 0$$

I know what the solution to this but I can't solve it myself.
The problem is that all over the net I stumble upon heat equations of only this form:
$$\large \frac{du}{dt} = k \frac{d^2u}{dx^2}$$

And I can't figure out what am I supposed to do with $\sin \pi x$
Thx!

Last edited by a moderator:

#### Jester

##### Well-known member
MHB Math Helper
The idea here is try and transform your PDE to another PDE without the source term ($\sin \pi x$) and yet retain the BC.s If you try a tranformation of the form

$u = v + a \sin \pi x$

you'll notice that $u(0,t) = 0$ and $u(1,t) = 0$ remain unchanged i.e. $v(0,t) = 0$ and $v(1,t) = 0$. Now find $a$ such that the source term cancels.

##### New member
Thanks for answering. Now I'm going to post the full solution; who knows, someone else might benefit from it.
Note that the procedure below might only work only if we're dealing with $sin$ or $cos$

The solution will be of this form (I do not know from where were you supposed to come up with this form)
$$u(x,t) = a(t) sin \pi x + b(t) sin 2 \pi x$$
Having this in mind we now only differentiate
$$a'(t) sin \pi x + a(t) \pi^2 sin \pi x + b'(t) sin 2 \pi x + b(t) 4 \pi ^2 sin 2 \pi x = sin \pi x$$
From this we come up with this:

$$\begin{cases} a'(t) + \pi^2a(t) = 1 \\ a(0) = 0 \end{cases}$$
and

$$\begin{cases} b'(t) + 4\pi^2b(t) = 0 \\ b(0) = 1 \end{cases}$$

Which are pretty easy to solve.

Last edited: