# Question on 1D heat equation

##### New member
Have been trying for hours but simply no results. Hope that someone can help me out.

$\frac{\partial u}{\partial t}=4\frac{\partial^2 u}{\partial x^2}$

for $$t>0$$ and $$0\leq x\leq 2$$ subject to the boundary conditions

$u_x (0,t) = 0\mbox{ and }u(2,t) = 0$

and the initial condition

$u(x,0) = 2 \cos \left(\frac{7\pi x}{4}\right)$

By the use of separations of variables, solve the above equation for the temperature $$u(x,t)$$

Last edited by a moderator:

#### chisigma

##### Well-known member
Have been trying for hours but simply no results. Hope that someone can help me out.

∂u/∂t=4(∂^2 u)/(∂x^2 )

for t>0 and 0≤x≤2 subject to the boundary conditions

ux (0,t) = 0 and u(2,t) = 0

and the initial condition

u(x,0) = 2 cos (7πx)/4

By the use of separations of variables, solve the above equation for the temperature u(x,t)

Let suppose that any solution can be written as $\displaystyle u(x,t)= \alpha(x)\ \beta(t)$, so that the PDE is written as...

$\displaystyle \frac{\alpha^{\ ''}}{\alpha} = \frac{\beta^{\ '}}{4\ \beta}=c$ (1)

... where c is a constant that we suppose to be negative so that we set $\displaystyle c=- \frac{1}{\lambda^{2}}$, $u_{t}= \alpha\ \beta^{\ '}$ and $u_{xx}= \beta\ \alpha^{\ ''}$ and arrive to the pair of ODE...

$\displaystyle \alpha^{\ ''}= - \frac{\alpha}{\lambda^{2}}$ (2)

$\displaystyle \beta^{\ '}= - \frac{4\ \beta}{\lambda^{2}}$ (3)

The (3) has solution...

$\beta = A\ e^{- \frac{4\ t}{\lambda^{2}}}$ (4)

... and (2) has solution...

$\alpha = B\ \cos (\frac{x}{\lambda}) + C\ \sin (\frac{x}{\lambda})$ (5)

Now we to introduce the 'conditions on the contour' that are...

$\displaystyle u(0,t)=u(2,t)=0\ ,\ u(x,0)= 2\ \cos (\frac{7}{4}\ \pi\ x)$ (6)

It is easy to see that the (6) are not coherent because for x=0 is u=0 no matter which is t, so that we take into account only the conditions $\displaystyle u(0,t)=u(2,t)=0$. In this case the value of $\lambda$ is $\displaystyle \lambda= \frac{2}{n\ \pi}$ and the solution becomes...

$\displaystyle u(x,t)= \sum_{n=1}^{\infty} c_{n} \sin (\frac{\pi}{2}\ n\ x)\ e^{- n^{2}\ \pi^{2}\ t}$ (7) Marry Christmas from Serbia

Kind regards

$\chi$ $\sigma$

Last edited:

#### chisigma

##### Well-known member
Let suppose that any solution can be written as $\displaystyle u(x,t)= \alpha(x)\ \beta(t)$, so that the PDE is written as...

$\displaystyle \frac{\alpha^{\ ''}}{\alpha} = \frac{\beta^{\ '}}{4\ \beta}=c$ (1)

... where c is a constant that we suppose to be negative so that we set $\displaystyle c=- \frac{1}{\lambda^{2}}$, $u_{t}= \alpha\ \beta^{\ '}$ and $u_{xx}= \beta\ \alpha^{\ ''}$ and arrive to the pair of ODE...

$\displaystyle \alpha^{\ ''}= - \frac{\alpha}{\lambda^{2}}$ (2)

$\displaystyle \beta^{\ '}= - \frac{4\ \beta}{\lambda^{2}}$ (3)

The (3) has solution...

$\beta = A\ e^{- \frac{4\ t}{\lambda^{2}}}$ (4)

... and (2) has solution...

$\alpha = B\ \cos (\frac{x}{\lambda}) + C\ \sin (\frac{x}{\lambda})$ (5)

Now we to introduce the 'conditions on the contour' that are...

$\displaystyle u(0,t)=u(2,t)=0\ ,\ u(x,0)= 2\ \cos (\frac{7}{4}\ \pi\ x)$ (6)

It is easy to see that the (6) are not coherent because for x=0 is u=0 no matter which is t, so that we take into account only the conditions $\displaystyle u(0,t)=u(2,t)=0$. In this case the value of $\lambda$ is $\displaystyle \lambda= \frac{2}{n\ \pi}$ and the solution becomes...

$\displaystyle u(x,t)= \sum_{n=1}^{\infty} c_{n} \sin (\frac{\pi}{2}\ n\ x)\ e^{- n^{2}\ \pi^{2}\ t}$ (7)
The conditions on contour have been defined as 'non coherent' because the term $2\ \cos (\frac{7}{4}\ \pi\ x)$ for $x=0$ is $\ne 0$, but that isn't true if we set the last condition as...

$\displaystyle u(x,0)= g(x)= \begin{cases} 2\ \cos (\frac{7}{4}\ \pi\ x), & \text{if } 0< x <2\\ - 2\ \cos (\frac{7}{4}\ \pi\ x), & \text{if } -2 < x < 0\\ 0, & \text{if}\ x=-2,x=0, x=2\end{cases}$ (1)

Now g(x) can be written as a Fourier series on only sines with coefficients ...

$\displaystyle c_{n}= 2\ \int_{0}^{2} \cos (\frac{7}{4}\ \pi\ x)\ \sin (\frac{\pi}{2}\ n\ x)\ dx = \frac{16\ n}{4\ \pi\ n^{2} -49\ \pi}$ (2)

... so that the solution is...

$\displaystyle u(x,t) = \sum_{n=1}^{\infty} \frac{16\ n}{4\ \pi\ n^{2} -49\ \pi} \sin (\frac{\pi}{2}\ n\ x)\ e^{- n^{2}\ \pi^{2}\ t}$ (3) Marry Christmas from Serbia

$\chi$ $\sigma$

##### New member
The conditions on contour have been defined as 'non coherent' because the term $2\ \cos (\frac{7}{4}\ \pi\ x)$ for $x=0$ is $\ne 0$, but that isn't true if we set the last condition as...

$\displaystyle u(x,0)= g(x)= \begin{cases} 2\ \cos (\frac{7}{4}\ \pi\ x), & \text{if } 0< x <2\\ - 2\ \cos (\frac{7}{4}\ \pi\ x), & \text{if } -2 < x < 0\\ 0, & \text{if}\ x=-2,x=0, x=2\end{cases}$ (1)

Now g(x) can be written as a Fourier series on only sines with coefficients ...

$\displaystyle c_{n}= 2\ \int_{0}^{2} \cos (\frac{7}{4}\ \pi\ x)\ \sin (\frac{\pi}{2}\ n\ x)\ dx = \frac{16\ n}{4\ \pi\ n^{2} -49\ \pi}$ (2)

... so that the solution is...

$\displaystyle u(x,t) = \sum_{n=1}^{\infty} \frac{16\ n}{4\ \pi\ n^{2} -49\ \pi} \sin (\frac{\pi}{2}\ n\ x)\ e^{- n^{2}\ \pi^{2}\ t}$ (3) Marry Christmas from Serbia

$\chi$ $\sigma$
Thank you very much for your help Chisigma. I e-mail my professor with regards to this question and she only replied me her answer which is : I understood your working but my professor claim that the above is the correct answer and now I am really confused.

Sorry I tried my best to type this out using LaTeX but I simply don't know how to thus I insert a picture for illustration purpose.

#### Opalg

##### MHB Oldtimer
Staff member
Thank you very much for your help Chisigma. I e-mail my professor with regards to this question and she only replied me her answer which is :

View attachment 514

I understood your working but my professor claim that the above is the correct answer and now I am really confused.

Sorry I tried my best to type this out using LaTeX but I simply don't know how to thus I insert a picture for illustration purpose.
I think that you have a typo in the initial statement of the problem. You wrote

$\frac{\partial u}{\partial t}=4\frac{\partial^2 u}{\partial x^2}$

for $$t>0$$ and $$0\leq x\leq 2$$ subject to the boundary conditions

$\color{red}{u_x (0,t) = 0}\mbox{ and }\color{red}{u(2,t) = 0}$

and the initial condition

$u(x,0) = 2 \cos \left(\frac{7\pi x}{4}\right)$
with the boundary conditions given as $u_x (0,t) = 0$ and $u(2,t) = 0$. Chisigma interpreted this as $u (0,t) = 0$ and $u(2,t) = 0$ (with no partial derivative in either condition). It looks as though you should have written $u_x (0,t) = 0$ and $u_x(2,t) = 0$ (with a partial derivative in both conditions). Chisigma's solution can then quite easily be modified to give the professor's solution.