[Math] How to use this initial condition for the heat equation

heat equationordinary differential equationspartial differential equations

How can I use the following initial condition for a partial differential equation describing heat diffusion?

$$f(x) = \begin{cases}
0, & 0<x<0.45 \\
1, & 0.45<x<0.55 \\
0, & 0.55<x<1
\end{cases}$$

I have a heat equation $u_{t} = \beta u_{xx}$ with boundary conditions $u(0,t)=u(L,t)=0$, where $L$ denotes the right end of the space coordinates. The space coordinates range from $0$ to $L$. With separation of variables these conditions lead us to set $X(0)=X(L)=0$ in order to solve for $X(x)$. Putting together the solution for $T(t)$, the general solution for the heat equation is:

$$u(x,t) = e^{\lambda\beta t}c_2 sin\left(\dfrac{n \pi x}{L}\right) $$

where $\lambda=-(n\pi/L)^2$, where $n$ can be any positive integer.

Once again, my initial condition is the following:

$$f(x) = \begin{cases}
0, & 0<x<0.45 \\
1, & 0.45<x<0.55 \\
0, & 0.55<x<1
\end{cases}$$

The function $f(x)$ can be represented by the following Fourier series:

$$f(x) \simeq \dfrac{1}{20} + \sum_{n=1}^{\infty}\dfrac{1}{n\pi}a_n \text{cos}\left(\dfrac{n \pi x}{L}\right) + \sum_{n=1}^{\infty}\dfrac{1}{n\pi}b_n \text{sin}\left(\dfrac{n \pi x}{L}\right)$$

where $a_n = \dfrac{1}{n\pi}\left[\text{sin}\left(n\pi 0.55\right)-\text{sin}\left(n\pi 0.45\right) \right]$ and $b_n = \dfrac{1}{n\pi}\left[\text{cos}\left(n\pi 0.45\right)-\text{cos}\left(n\pi 0.55\right) \right]$ for all $n=1,2,3,…$. The constant is $a_0/2=1/20$. If I take this Fourier representation of $f(x)$ and plug it on the general solution I get the following expression.

$$u(x,t) = \dfrac{1}{20} + \sum_{n=1}^{\infty}\dfrac{e^{-(n\pi/L)^2\beta t}}{n\pi}a_n \text{cos}\left(\dfrac{n \pi x}{L}\right) + \sum_{n=1}^{\infty}\dfrac{e^{-(n\pi/L)^2\beta t}}{n\pi}b_n \text{sin}\left(\dfrac{n \pi x}{L}\right)$$

This is where I get confused. When $t=0$ the exponential vanishes and I get an approximation of my step function, which is my initial condition, so far everything is OK. However, as $t>0$ the temperature $u(x,t) \neq 0$ and as $\lim t \rightarrow \infty$ the temperature never reaches zero; it converges to the constant term $1/20$. Even more puzzling, although not noticeable in the picture here sometimes the temperature dips below zero at the ends. I am doubting if the equation representing the initial condition is meant to only be used at $t=0$ and not for $t>0$, thus using the general solution afterwards. I suspect this is wrong. So basically, how can I incorporate the initial condition $f(x)$ into the heat equation???

A bit of interactive graphs, where b represents time $t$ can be found here

Best Answer

Together with the general solution of the PDE, the conditions $u(0,t)=u(L,t)=0$ lead to : $$u(x,t)= \sum_{n=1}^{\infty}c_n \sin\left(\dfrac{n \pi x}{L}\right)\exp\left(-\left(\frac{n\pi}{L}\right)^2 \beta t \right) $$ The condition $u(x,0)=f(x)$ can be expressed in terms of Fourier series of various manner, depending on the chosen bounds. In the present case, in order to fit with the above form of $u(x,0)=\sum_{n=1}^{\infty}c_n \sin\left(\dfrac{n \pi x}{L}\right)$ which is an odd function, we extend the domain to $-L<x<L$

$$f(x) = \begin{cases} 0, & -1<x<-0.55 \\ 1, & -0.55<x<0.45 \\ 0, & -0.45<x<0.45 \\ 1, & 0.45<x<0.55 \\ 0, & 0.55<x<1 \end{cases}$$

This can be surprising because $f(x)\neq 0$ somewhere on $x<0$. It doesn't matter since latter, only the range $0<x<L$ is taken into account. This is the same when, instead of $-L<x<L$, we take the Fourier series on $0<x<L$ : also $f(x)\neq 0$ somewhere on $x<0$.

That way, we obtain : $$f(x)\simeq \sum_{n=1}^{\infty}c_n \sin\left(\dfrac{n \pi x}{L}\right)$$ $$c_n=\frac{1}{L}\int_{-0.55}^{-0.45}(-1)\sin\left(\frac{n\pi x}{L} \right)dx+\frac{1}{L}\int_{0.45}^{0.55}(+1)\sin\left(\frac{n\pi x}{L} \right)dx$$

$$c_n=\frac{2}{n\pi}\left(\cos\left(n\pi\frac{0.45}{L} \right)-\cos\left(n\pi\frac{0.55}{L} \right) \right)$$ You can draw $\sum_{n=1}\frac{2}{n\pi}\left(\cos\left(n\pi\frac{0.45}{L} \right)-\cos\left(n\pi\frac{0.55}{L} \right) \right) \sin\left(\dfrac{n \pi x}{L}\right)$ and verify that it fit to $f(x)$ on the range $0<x<L$. Doesn't matter outside this range.

Finally : $$u(x,t)= \sum_{n=1}^{\infty}\frac{2}{n\pi}\left(\cos\left(n\pi\frac{0.45}{L} \right)-\cos\left(n\pi\frac{0.55}{L} \right) \right) \sin\left(\dfrac{n \pi x}{L}\right)\exp\left(-\left(\frac{n\pi}{L}\right)^2 \beta t \right) $$ $u(x,t\to \infty)\to 0$

Related Question