# Solving Heat Equation by Separation of Variables Method

I am a student studying Engineering Mathematics, and the professor gave me below heat equation. $$\frac{\partial u}{\partial t}=\frac{\partial^2u}{\partial x^2}$$ where the initial condition is $$u(x,0)=100$$ and the boundary condition is $$\frac{\partial u(0,t)}{\partial x}=0, \ u(1,t)=0$$ The professor taught me only the separation of variables method, so I tried it. Assume that $$u(x,t)=F(x)G(t)$$. Substituting it, $$F(x)\frac{dG(t)}{dt} \ = \ G(t)\frac{d^2F(x)}{dx^2}$$ That is, for some constant $$k$$, $$\frac 1{G(t)}\frac{dG(t)}{dt} \ = \ \frac 1 {F(x)}\frac{d^2F(x)}{dx^2} \ = \ k$$ Let's check $$\frac1{F(x)}\frac{d^2F(x)}{dx^2}=k$$ first. The characteristic equation of this ODE is $$\lambda^2=k$$. if $$k>0$$, then $$F(x) \ = \ Ae^{\sqrt kx}+Be^{-\sqrt kx}$$ By the boundary condition, $$u(1,t) \ = \ (Ae^{\sqrt k}+Be^{-\sqrt k})G(t) \ = \ 0 \\ \frac{\partial u(0,t)}{\partial x} \ = \ (A\sqrt k-B\sqrt k)G(t) \ = \ 0$$ Because $$G(t)\neq 0$$, It should be that $$Ae^{\sqrt k}+Be^{-\sqrt k}=A\sqrt k-B\sqrt k=0$$, but this equality holds if and only if $$A=B=0$$.

Next, assume that $$k=0$$. Then $$F(x)=C+Dx$$ And by the boundary condition, $$u(1,t) \ = \ (C+D)G(t) \ = \ 0 \\ \frac{\partial u(0,t)}{\partial x} \ = \ DG(t) \ = 0$$ It follows that $$C=D=0$$, which is useless.

Finally, assume that $$k<0$$. Then we can write $$k=-P^2$$, and $$F(x)=E\cos Px+F\sin Px$$ By the boundary condition, $$u(1,t) \ = \ (E\cos P+F\sin P)G(t) \ = \ 0 \\ \frac{\partial u(0,t)}{\partial x} \ = \ FPG(t) \ = 0$$ Then $$F=0$$, and we conclude that $$E\cos P=0$$. If $$E=0$$ then it's trivial solution which is $$u(x,t)=0$$, so it must be that $$\cos P=0$$. Therefore, $$P \ = \ \frac{(2n-1)\pi}2, \ n=1,2,3,...$$ Next, Let's check $$\frac 1{G(t)}\frac{dG(t)}{dt} \ = \ k$$. The characteristic equation of this ODE is $$\lambda=k=-P^2$$, so $$G(t) \ = \ G_ne^{-P^2t} \ = \ G_ne^{-\frac{(2n-1)^2\pi^2}{4}t}$$ Therefore we can express $$u(x,t)$$ as follows. $$u(x,t) = \sum_{n=1}^\infty(E_n\cos\frac{(2n-1)\pi x}{2})G_ne^{-\frac{(2n-1)^2\pi^2}{4}t}$$ Or, $$u(x,t) = \sum_{n=1}^\infty H_n(\cos\frac{(2n-1)\pi x}{2})e^{-\frac{(2n-1)^2\pi^2}{4}t}$$ where $$H_n=E_nG_n$$.

By the initial condition, $$u(x,0) \ = \ \sum_{n=1}^\infty H_n\cos\frac{(2n-1)\pi x}{2} \ = \ 100$$ Then $$H_n$$ can be calculated using the Fourier series of $$f(x)=100$$. But $$f(x)=100$$ is a constant function, so its Fourier cosine coefficients are all zero, that is, $$H_n=0$$. This result is weird. Did I make some mistakes? Or it can't be solved by the separation of variables method?

• In your last paragraph ... a constant function, so its Fourier cosine coefficients are all zero. Are you so sure about this? Dec 10, 2021 at 10:11
• @LeeDavidChungLin, Although 'Fourier cosine coefficients of a constant function are all zero' is not true, at least in this case, $\cos\frac{(2n-1)πx}2$ in the infinite sum means that $H_n$ is Fourier cosine coefficient of $L=2$. (I thought $2n-1$ in the sum is because even terms are all zero) But $\int_0^2 \cos\frac{(2n-1)πx}2 dx=0$. Dec 10, 2021 at 12:44
• Why are your integration limits $0$ to $2$? If you're gonna plug in whatever formula as $L=2$ (which is not the only way), it should be from $-1$ to $1$. Dec 10, 2021 at 14:09
• @LeeDavidChungLin The formula of Fourier cosine coefficient is $\frac 1 L \int_{-L}^L \cos\frac{n\pi x}L f(x) dx$, so I thought that $L=2$ because the denominator of $\cos\frac{(2n-1)\pi x}2$ in the sum is $2$ and even terms may be all zero. Dec 10, 2021 at 14:28
• Like I said, you're plugging in things blindly. The domain is $x \in [0,1]$, and you got cosine by fitting the boundary conditions of $f=0$ on the right and $f$ being finite on the left at $x=0$. Think about how to calculate the inner-product within $x \in [0,1]$. One way is to reflect the whole thing on the $x<0$ side and integrate from $-1$ to $1$ (to get a doubled amount), by implicitly having a mirror boundary condition of $f=0$ at $x=-1$. How are you fitting the boundary conditions by extending from $x \in [0,1]$ to $x \in [0,2]$? It can be done, but it requires some modification. Dec 10, 2021 at 14:46