# Heat equation separation of variables with boundary conditions

The following Heat equation:

• $$u_t=4 u_{xx}$$, $$(t,x) \in (0, \infty)\times (0,1)$$

• $$u(0,x)=x(1-x), x \in (0,1)$$

• $$u(t,0)=0=u(t,1), t \in (0, \infty)$$

should have the following solution:

$$u(t,x)= \frac {8}{\pi^3} \sum_{n=1} ^{\infty} \frac {1}{(2n-1)^3} e^{-4(2n-1)^2 \pi^2 t} \sin((2n-1)\pi x)$$

So to get this answer I used seperation of variables:

$$u(t,x)=X(x)T(t)$$

$$\frac{X''}{X}=\frac{T'}{4T}=-\lambda$$

Now I set $${\lambda = \alpha^2}$$:

• $$(I): X''+\alpha^2 X=0$$
• $$(II): T'+\alpha^2 T=0$$

solving $$(I)$$:

$$X(x)=c_1 \cos(\alpha x)+ c_2 \sin(\alpha x)$$

Now using the boundary conditions $$u(t,0)=0=u(t,1)$$:

$$c_1=0$$ and $$\sin(\alpha)=0$$ so $$\alpha= n \pi$$

It follows that $$X(x)=a_n \sin(n \pi x)$$

Now I get the following solution, which is not identical to the given solution:

$$u(t,x)=\sum_{n=0} ^{\infty} c_n e^{-4n^2 \pi^2 t} \sin(n\pi x)$$

I know how to proceed from here on, but I don't understand how $$\alpha = (2n-1) \pi$$ in the given solution. We are asked to show that we get the given solution as a final solution for the equation.

• Can you use the other boundary condition that $u(0,x)=x(1-x), x \in (0,1)$ and express $x(1-x)$ as a Fourier series and compare coefficients?
– user1174498
Commented Jun 3, 2023 at 21:27
• Can you please explain? I know how to do the Fourier series for x(1-x), but how to compare coefficients? If you mean how to get $c_n$, I can do that. But I can't proceed, since in my case $\alpha \neq (2n-1) \pi$ not like the expected solution, where $\alpha= (2n-1) \pi$ Commented Jun 3, 2023 at 22:10
• Your $\alpha$ is totally correct, there is a different reason why in the solution there only appear the terms with $2n-1$. As @KevinPWalker suggested, if you express $x(1-x)$ in a Fourier series and compare coefficients, you probably get something like $c_k = \frac{8}{\pi^3} \frac{1}{(2n-1)^3}$, if $k=2n-1$ for some $n\in\mathbb{N}$, and $0$ otherwise. If you then plug these coefficients into your Fourier series $u(t,x)$, you get exactly the desired solution. Commented Jun 3, 2023 at 22:41
• Ok, thank you, I understand now. Commented Jun 4, 2023 at 11:57

We know that $$u(x, 0) =x(1-x)$$ and from the solution we Have that $$u(x, 0) =\sum c_k\sin(k\pi x)$$, so the unique posibility is that the coefficients $$c_n$$ are the same as the ones on the sine Fourier series of $$x(1-x)$$. If you compute that series you will get that $$x(1-x) = \frac{4}{\pi^3}\sum_{n=1}^{\infty}\frac{\left(1-\left(-1\right)^{n}\right)}{n^{3}}\sin\left(n\pi x\right),$$ since $$1-(-1) ^n$$ is zero for even $$n$$ and $$2$$ for odd $$n$$, we get that $$c_k=0$$ if $$k=2n$$ and $$c_k=\frac{8}{\pi^3}\frac{1}{(2n-1) ^3}$$ if $$k=2n-1$$.