5 Heat PDE in bar (1D)

_______________________________________________________________________________________

5.1 left and right end temperature ﬁxed at zero. No source (Haberman 2.3.3 (a))

problem number 20

This is problem 2.3.3, part (a) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Consider the heat equation

$u_t = k u_{xx}$

Subject to boundary conditions $$u(0,t)=0$$ and $$u(L,t)=0$$ with the temperature initially $$u(x,0)=6 \sin \left ( \frac{9 \pi x}{L} \right )$$

Mathematica

$\left \{\left \{u(x,t)\to 6 e^{-\frac{81 \pi ^2 k t}{L^2}} \sin \left (\frac{9 \pi x}{L}\right )\right \}\right \}$

Maple

$u \left ( x,t \right ) =6\,\sin \left ( 9\,{\frac{\pi \,x}{L}} \right ){{\rm e}^{-81\,{\frac{k{\pi }^{2}t}{{L}^{2}}}}}$

Hand solution

Assuming solution is $$u\left ( x,t\right ) =X\left ( x\right ) T\left ( t\right )$$. The PDE becomes

$\frac{1}{k}T^{\prime }X=X^{\prime \prime }T$

Dividng both sides by $$XT$$ gives

$\frac{1}{k}\frac{T^{\prime }}{T}=\frac{X^{\prime \prime }}{X}=-\lambda$

The time ODE gives the solution $$T^{\prime }+k\lambda T=0$$ or $$T=e^{-k\lambda t}\tag{1}$$

The space ODE becomes $$X^{\prime \prime }+\lambda X=0$$.

case $$\lambda =0$$ then the solution is $$X=Ax+B$$. The boundary conditions $$X\left ( 0\right ) =0$$ gives $$B=0$$. Hence solution becomes $$X=Ax$$. Boundary conditions $$X\left ( L\right ) =0$$ gives $$A=0$$. Hence trivial solution. Therefore $$\lambda =0$$ is not eigenvalue.

case $$\lambda <0$$ then solution is $$X=A\cosh \left ( \sqrt{\left \vert \lambda \right \vert }x\right ) +B\sinh \left ( \sqrt{\left \vert \lambda \right \vert }x\right )$$. The boundary conditions $$X\left ( 0\right ) =0$$ gives $$A=0$$. Solution becomes $$X=B\sinh \left ( \sqrt{\left \vert \lambda \right \vert }x\right )$$. Boundary conditions $$X\left ( L\right ) =0$$ gives $$0=B\sinh \left ( \sqrt{\left \vert \lambda \right \vert }L\right )$$. But $$\sinh$$ is zero only when its argument is zero. Since $$L\neq 0$$ and since $$\lambda \neq 0$$, then only choice is $$B=0$$ and this results in trivial solution.

case $$\lambda >0$$ the solution becomes $$X\left ( x\right ) =A\cos \left ( \sqrt{\lambda }x\right ) +B\sin \left ( \sqrt{\lambda }x\right )$$. The boundary conditions $$X\left ( 0\right ) =0$$ gives $$A=0$$ and the solution becomes $$X\left ( x\right ) =B\sin \left ( \sqrt{\lambda }x\right )$$. Boundary conditions $$X\left ( L\right ) =0$$ gives $$0=B\sin \left ( \sqrt{\lambda }L\right )$$. For non-trivial solution we need $$\sqrt{\lambda }L=n\pi$$ for $$n=1,2,3,\cdots$$. Hence \begin{align*} \sqrt{\lambda _{n}} & =\frac{n\pi }{L}\qquad n=1,2,3,\cdots \\ \lambda _{n} & =\left ( \frac{n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end{align*}

Therefore the fundamental solution is \begin{align*} u_{n} & =X_{n}T_{n}\\ & =B_{n}\sin \left ( \sqrt{\lambda _{n}}x\right ) e^{-k\lambda _{n}t} \end{align*}

And the complete solution is

$u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \sqrt{\lambda _{n}}x\right ) e^{-k\lambda _{n}t}$

At $$t=0$$

$6\sin \left ( \frac{9\pi x}{L}\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right )$

For $$n=9$$

$6\sin \left ( \frac{9\pi x}{L}\right ) =B_{9}\sin \left ( \frac{9\pi }{L}x\right )$

Hence $$B_{9}=6$$ and all other terms are zero. Therefore the solution is

\begin{align*} u\left ( x,t\right ) & =B_{9}\sin \left ( \sqrt{\lambda _{9}}x\right ) e^{-k\lambda _{9}t}\\ & =6\sin \left ( \frac{9\pi }{L}x\right ) e^{-k\left ( \frac{9\pi }{L}\right ) ^{2}t}\\ & =6\sin \left ( \frac{9\pi }{L}x\right ) e^{-k\frac{81\pi ^{2}}{L^{2}}t} \end{align*}

_______________________________________________________________________________________

5.2 left and right end temperature ﬁxed at zero, No source (Haberman 2.3.3 (b))

problem number 21

This is problem 2.3.3, part (b) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Consider the heat equation

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

Subject to boundary conditions $$u(0,t)=0$$ and $$u(L,t)=0$$ with the temperature initially $$u(x,0)=3 \sin \frac{\pi x}{L} - \sin \frac{3 \pi x}{L}$$

Mathematica

$\left \{\left \{u(x,t)\to e^{-\frac{9 \pi ^2 k t}{L^2}} \sin \left (\frac{\pi x}{L}\right ) \left (3 e^{\frac{8 \pi ^2 k t}{L^2}}-2 \cos \left (\frac{2 \pi x}{L}\right )-1\right )\right \}\right \}$

Maple

$u \left ( x,t \right ) =3\,\sin \left ({\frac{\pi \,x}{L}} \right ){{\rm e}^{-{\frac{k{\pi }^{2}t}{{L}^{2}}}}}-\sin \left ( 3\,{\frac{\pi \,x}{L}} \right ){{\rm e}^{-9\,{\frac{k{\pi }^{2}t}{{L}^{2}}}}}$

Hand solution

Let $$u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right )$$, and the PDE becomes$\frac{1}{k}T^{\prime }X=X^{\prime \prime }T$ Following same steps as earlier problem the solution is $u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$ Where the eigenvalues are $$\lambda _{n}=\left ( \frac{n\pi }{L}\right ) ^{2}$$ for $$n=1,2,3,\cdots$$. Initial conditions are now applied. Setting $$t=0$$, the above becomes$u\left ( x,0\right ) =3\sin \frac{\pi x}{L}-\sin \frac{3\pi x}{L}=\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right )$ As the series is unique, the terms coeﬃcients must match for those shown only, and all other $$B_{n}$$ terms vanish. This means that by comparing terms$3\sin \left ( \frac{\pi x}{L}\right ) -\sin \left ( \frac{3\pi x}{L}\right ) =B_{1}\sin \left ( \frac{\pi x}{L}\right ) +B_{3}\sin \left ( \frac{3\pi }{L}x\right )$ Therefore \begin{align*} B_{1} & =3\\ B_{3} & =-1 \end{align*}

And all other $$B_{n}=0$$. The solution is$u\left ( x,t\right ) =3\sin \left ( \frac{\pi }{L}x\right ) e^{-k\left ( \frac{\pi }{L}\right ) ^{2}t}-\sin \left ( \frac{3\pi }{L}x\right ) e^{-k\left ( \frac{3\pi }{L}\right ) ^{2}t}$

_______________________________________________________________________________________

5.3 left and right end temperature ﬁxed at zero, No source (Haberman 2.3.3 (c))

problem number 22

This is problem 2.3.3, part (c) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Consider the heat equation

$u_t = k u_{xx}$

Subject to boundary conditions $$u(0,t)=0$$ and $$u(L,t)=0$$ with the temperature initially $$u(x,0)=2 \cos \frac{3 \pi x}{L}$$

Mathematica

$\left \{\left \{u(x,t)\to \underset{K[1]=1}{\overset{\infty }{\sum }}\frac{4 \left (1+(-1)^{K[1]}\right ) e^{-\frac{k \pi ^2 t K[1]^2}{L^2}} K[1] \sin \left (\frac{\pi x K[1]}{L}\right )}{\pi \left (K[1]^2-9\right )}\right \}\right \}$ but $$n=3$$ should be special case

Maple

$u \left ( x,t \right ) =1/5\,{\frac{1}{\pi } \left ( -16\,\sin \left ( 2\,{\frac{\pi \,x}{L}} \right ){{\rm e}^{-4\,{\frac{k{\pi }^{2}t}{{L}^{2}}}}}+5\,\sum _{n=4}^{\infty }4\,{\frac{n \left ( \left ( -1 \right ) ^{n}+1 \right ) }{\pi \, \left ({n}^{2}-9 \right ) }\sin \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}}\pi \right ) }$ handled $$n=3$$ case correctly.

Hand solution

Let $$u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right )$$, and the PDE becomes$\frac{1}{k}T^{\prime }X=X^{\prime \prime }T$ Following same steps as earlier problem the solution is $u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$ Where the eigenvalues are $$\lambda _{n}=\left ( \frac{n\pi }{L}\right ) ^{2}$$ for $$n=1,2,3,\cdots$$. Initial conditions are now applied. Setting $$t=0$$, the above becomes$u\left ( x,0\right ) =2\cos \left ( \frac{3\pi }{L}x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right )$ Multiplying both sides by $$\sin \left ( \frac{m\pi }{L}x\right )$$ and integrating\begin{align*} \int _{0}^{L}2\cos \left ( \frac{3\pi }{L}x\right ) \sin \left ( \frac{m\pi }{L}x\right ) dx & =\int _{0}^{L}\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) \sin \left ( \frac{m\pi }{L}x\right ) dx\\ & =\sum _{n=1}^{\infty }B_{n}\int _{0}^{L}\sin \left ( \frac{n\pi }{L}x\right ) \sin \left ( \frac{m\pi }{L}x\right ) dx \end{align*}

By orthogonality of $$\sin$$ functions the above simpliﬁes to\begin{align*} \int _{0}^{L}2\cos \left ( \frac{3\pi }{L}x\right ) \sin \left ( \frac{m\pi }{L}x\right ) dx & =B_{m}\int _{0}^{L}\sin ^{2}\left ( \frac{m\pi }{L}x\right ) dx\\ & =B_{m}\frac{L}{2}\\ B_{m} & =\frac{4}{L}\int _{0}^{L}\cos \left ( \frac{3\pi }{L}x\right ) \sin \left ( \frac{m\pi }{L}x\right ) dx \end{align*}

For $$m=3,B_{3}=0$$. For $$m\neq 3$$\begin{align*} B_{m} & =\frac{4}{L}\left ( \frac{1+\left ( -1\right ) ^{m}}{m^{2}-9}\frac{nL}{\pi }\right ) \\ & =\frac{4n}{\pi }\left ( \frac{1+\left ( -1\right ) ^{m}}{m^{2}-9}\right ) \end{align*}

Hence the solution becomes\begin{align*} u\left ( x,t\right ) & =\sum _{n=1,n\neq 3}^{\infty }\frac{4n}{\pi }\left ( \frac{1+\left ( -1\right ) ^{n}}{n^{2}-9}\right ) \sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\\ & =\frac{4}{\pi }\sum _{n=1,n\neq 3}^{\infty }n\left ( \frac{1+\left ( -1\right ) ^{n}}{n^{2}-9}\right ) \sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}

When $$n$$ is odd, all terms become zero, hence the above can be also be written as$u\left ( x,t\right ) =\frac{8}{\pi }\sum _{n=2,4,6,\cdots }^{\infty }\left ( \frac{n}{n^{2}-9}\right ) \sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$

_______________________________________________________________________________________

5.4 left and right end temperature ﬁxed at zero, No source (Haberman 2.3.3 (d))

problem number 23

This is problem 2.3.3, part (d) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Consider the heat equation

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

Subject to boundary conditions $$u(0,t)=0$$ and $$u(L,t)=0$$ with the temperature initially $$u\left ( x,0\right ) =\left \{ \begin{array} [c]{ccc}1 & & 0<x\leq \frac{L}{2}\\ 2 & & \frac{L}{2}<x\leq L \end{array} \right .$$

Mathematica

$\left \{\left \{u(x,t)\to \underset{n=1}{\overset{\infty }{\sum }}\frac{4 e^{-\frac{k n^2 \pi ^2 t}{L^2}} \left (4 \cos \left (\frac{n \pi }{2}\right )+3\right ) \sin ^2\left (\frac{n \pi }{4}\right ) \sin \left (\frac{n \pi x}{L}\right )}{n \pi }\right \}\right \}$

Maple

$u \left ( x,t \right ) =\sum _{n=1}^{\infty }{\frac{2\,\cos \left ( 1/2\,n\pi \right ) +2+4\, \left ( -1 \right ) ^{1+n}}{n\pi }\sin \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}}$

Hand solution

$\frac{\partial u}{\partial t}=k\frac{\partial ^{2}u}{\partial x^{2}}$ Let $$u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right )$$, and the PDE becomes$\frac{1}{k}T^{\prime }X=X^{\prime \prime }T$ Dividing by $$XT\neq 0$$$\frac{1}{k}\frac{T^{\prime }}{T}=\frac{X^{\prime \prime }}{X}$ Since each side depends on diﬀerent independent variable and both are equal, they must be both equal to same constant, say $$-\lambda$$ where $$\lambda$$ is assumed to be real. $\frac{1}{k}\frac{T^{\prime }}{T}=\frac{X^{\prime \prime }}{X}=-\lambda$ The two ODE’s are\begin{align} T^{\prime }+k\lambda T & =0\tag{1}\\ X^{\prime \prime }+\lambda X & =0\tag{2} \end{align}

Starting with the space ODE equation (2), with corresponding boundary conditions $$X\left ( 0\right ) =0,X\left ( L\right ) =0$$. Assuming the solution is $$X\left ( x\right ) =e^{rx}$$, Then the characteristic equation is\begin{align*} r^{2}+\lambda & =0\\ r^{2} & =-\lambda \\ r & =\pm \sqrt{-\lambda } \end{align*}

The following cases are considered.

case $$\lambda <0$$ In this case, $$-\lambda$$ and also $$\sqrt{-\lambda }$$ are positive. Hence the roots $$\pm \sqrt{-\lambda }$$ are both real. Let $\sqrt{-\lambda }=s$ Where $$s>0$$. This gives the solution$X\left ( x\right ) =A\cosh \left ( sx\right ) +B\sinh \left ( sx\right )$ Applying the left B.C. $$X\left ( 0\right ) =0$$ gives\begin{align*} 0 & =A\cosh \left ( 0\right ) +B\sinh \left ( 0\right ) \\ & =A \end{align*}

The solution becomes $$X\left ( x\right ) =B\sinh \left ( sx\right )$$. Applying the right B.C. $$u\left ( L,t\right ) =0$$ gives$0=B\sinh \left ( sL\right )$ We want $$B\neq 0$$ (else trivial solution). This means $$\sinh \left ( sL\right )$$ must be zero. But $$\sinh \left ( sL\right )$$ is zero only when its argument is zero. This means either $$L=0$$ which is not possible or $$\lambda =0$$, but we assumed $$\lambda \neq 0$$ in this  case, therefore we run out of options to satisfy this case. Hence $$\lambda <0$$ is not an eigenvalue.

case $$\lambda =0$$

The ODE becomes$\frac{d^{2}X}{dx^{2}}=0$ The solution is$X\left ( x\right ) =c_{1}x+c_{2}$ Applying left boundary conditions $$X\left ( 0\right ) =0$$ gives\begin{align*} 0 & =X\left ( 0\right ) \\ & =c_{2} \end{align*}

Hence the solution becomes $$X\left ( x\right ) =c_{1}x$$. Applying the right B.C. gives\begin{align*} 0 & =X\left ( L\right ) \\ & =c_{1}L \end{align*}

Hence $$c_{1}=0$$. Hence trivial solution. $$\lambda =0$$ is not an eigenvalue.

case $$\lambda >0$$

Hence $$-\lambda$$ is negative, and the roots are both complex.$r=\pm i\sqrt{\lambda }$ The solution is$X\left ( x\right ) =A\cos \left ( \sqrt{\lambda }x\right ) +B\sin \left ( \sqrt{\lambda }x\right )$ The boundary conditions are now applied. The ﬁrst B.C. $$X\left ( 0\right ) =0$$ gives\begin{align*} 0 & =A\cos \left ( 0\right ) +B\sin \left ( 0\right ) \\ & =A \end{align*}

The ODE becomes $$X\left ( x\right ) =B\sin \left ( \sqrt{\lambda }x\right )$$. Applying the second B.C. gives$0=B\sin \left ( \sqrt{\lambda }L\right )$ $$B\neq 0\,$$ else the solution is trivial. Therefore taking\begin{align*} \sin \left ( \sqrt{\lambda }L\right ) & =0\\ \sqrt{\lambda _{n}}L & =n\pi \qquad n=1,2,3,\cdots \end{align*}

Hence eigenvalues are $\lambda _{n}=\frac{n^{2}\pi ^{2}}{L^{2}}\qquad n=1,2,3,\cdots$ The eigenfunctions associated with these eigenvalues are$X_{n}\left ( x\right ) =B_{n}\sin \left ( \frac{n\pi }{L}x\right )$ The time domain ODE is now solved. $$T^{\prime }+k\lambda _{n}T=0$$ has the solution$T_{n}\left ( t\right ) =e^{-k\lambda _{n}t}$ For the same set of eigenvalues. Notice that there is no need to add a new constant in the above as it will be absorbed in the $$B_{n}$$ when combined in the following step below. The solution to the PDE becomes$u_{n}\left ( x,t\right ) =T_{n}\left ( t\right ) X_{n}\left ( x\right )$ But for linear system the sum of eigenfunctions is also a solution, therefore\begin{align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }u_{n}\left ( x,t\right ) \\ & =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}

Initial conditions are now applied. Setting $$t=0$$, the above becomes$$f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) \tag{3}$$ Where $f\left ( x\right ) =\left \{ \begin{array} [c]{ccc}1 & & 0<x\leq L/2\\ 2 & & L/2<x<L \end{array} \right .$ Multiplying both sides of (3) by $$\sin \left ( \frac{m\pi }{L}x\right )$$ and integrating over the domain gives$\int _{0}^{L}\sin \left ( \frac{m\pi }{L}x\right ) f\left ( x\right ) dx=\int _{0}^{L}\left [ \sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{m\pi }{L}x\right ) \sin \left ( \frac{n\pi }{L}x\right ) \right ] dx$ Interchanging the order of integration and summation$\int _{0}^{L}\sin \left ( \frac{m\pi }{L}x\right ) f\left ( x\right ) dx=\sum _{n=1}^{\infty }\left [ B_{n}\left ( \int _{0}^{L}\sin \left ( \frac{m\pi }{L}x\right ) \sin \left ( \frac{n\pi }{L}x\right ) dx\right ) \right ]$ But $$\int _{0}^{L}\sin \left ( \frac{m\pi }{L}x\right ) \sin \left ( \frac{n\pi }{L}x\right ) dx=0$$ for $$n\neq m$$, hence only one term survives$\int _{0}^{L}\sin \left ( \frac{m\pi }{L}x\right ) f\left ( x\right ) dx=B_{m}\int _{0}^{L}\sin ^{2}\left ( \frac{m\pi }{L}x\right ) dx$ Renaming $$m$$ back to $$n$$ and since $$\int _{0}^{L}\sin ^{2}\left ( \frac{m\pi }{L}x\right ) dx=\frac{L}{2}$$ the above becomes\begin{align*} \int _{0}^{L}\sin \left ( \frac{n\pi }{L}x\right ) f\left ( x\right ) dx & =\frac{L}{2}B_{n}\\ B_{n} & =\frac{2}{L}\int _{0}^{L}\sin \left ( \frac{n\pi }{L}x\right ) f\left ( x\right ) dx\\ & =\frac{2}{L}\left ( \int _{0}^{\frac{L}{2}}\sin \left ( \frac{n\pi }{L}x\right ) f\left ( x\right ) dx+\int _{\frac{L}{2}}^{L}\sin \left ( \frac{n\pi }{L}x\right ) f\left ( x\right ) dx\right ) \\ & =\frac{2}{L}\left ( \int _{0}^{\frac{L}{2}}\sin \left ( \frac{n\pi }{L}x\right ) dx+2\int _{\frac{L}{2}}^{L}\sin \left ( \frac{n\pi }{L}x\right ) dx\right ) \\ & =\frac{2}{L}\left ( \left . \frac{-\cos \left ( \frac{n\pi }{L}x\right ) }{\frac{n\pi }{L}}\right \vert _{0}^{\frac{L}{2}}+2\left . \frac{-\cos \left ( \frac{n\pi }{L}x\right ) }{\frac{n\pi }{L}}\right \vert _{\frac{L}{2}}^{L}\right ) \\ & =\frac{2}{n\pi }\left ( \left ( -\cos \left ( \frac{n\pi }{L}x\right ) \right ) _{0}^{\frac{L}{2}}+2\left ( -\cos \left ( \frac{n\pi }{L}x\right ) \right ) _{\frac{L}{2}}^{L}\right ) \\ & =\frac{2}{n\pi }\left ( \left [ -\cos \left ( \frac{n\pi }{L}\frac{L}{2}\right ) +\cos \left ( 0\right ) \right ] +2\left [ -\cos \left ( n\pi \right ) +\cos \left ( \frac{n\pi }{2}\right ) \right ] \right ) \\ & =\frac{2}{n\pi }\left ( -\cos \left ( \frac{n\pi }{2}\right ) +1-2\cos \left ( n\pi \right ) +2\cos \left ( \frac{n\pi }{2}\right ) \right ) \\ & =\frac{2}{n\pi }\left ( \cos \left ( \frac{n\pi }{2}\right ) +1-2\cos \left ( n\pi \right ) \right ) \end{align*}

Hence the solution is$u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$ With \begin{align*} B_{n} & =\frac{2}{n\pi }\left ( \cos \left ( \frac{n\pi }{2}\right ) -2\cos \left ( n\pi \right ) +1\right ) \\ & =\frac{2}{n\pi }\left ( 1-2\left ( -1\right ) ^{n}+\cos \left ( \frac{n\pi }{2}\right ) \right ) \\ & =\frac{2}{n\pi }\left ( 1+2\left ( -1\right ) ^{n+1}+\cos \left ( \frac{n\pi }{2}\right ) \right ) \end{align*}

Therefore$u\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac{2}{n\pi }\left ( 1-2\left ( -1\right ) ^{n}+\cos \left ( \frac{n\pi }{2}\right ) \right ) \sin \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$

_______________________________________________________________________________________

5.5 left and right end insulated, No source (Haberman 2.3.7)

problem number 24

This is problem 2.3.7, from Richard Haberman applied partial diﬀerential equations, 5th edition.

Consider the heat equation

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

Subject to boundary conditions $$\frac{\partial u}{\partial x}(0,t)=0$$ $$\frac{\partial u}{\partial x}(L,t)=0$$ with the temperature initially $$u\left ( x,0\right ) =f(x)$$

Mathematica

$\left \{\left \{u(x,t)\to \frac{2 \underset{n=1}{\overset{\infty }{\sum }}e^{-\frac{k n^2 \pi ^2 t}{L^2}} \cos \left (\frac{n \pi x}{L}\right ) \int _0^L \cos \left (\frac{n \pi x}{L}\right ) f(x) \, dx}{L}+\frac{\int _0^L f(x) \, dx}{L}\right \}\right \}$

Maple

$u \left ( x,t \right ) ={\frac{1}{L} \left ( \sum _{n=1}^{\infty } \left ( 2\,{\frac{1}{L}\cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \cos \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x} \right ) L+\int _{0}^{L}\!f \left ( x \right ) \,{\rm d}x \right ) }$

Hand solution

$\frac{\partial u}{\partial t}=k\frac{\partial ^{2}u}{\partial x^{2}}$ Let $$u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right )$$, then the PDE becomes$\frac{1}{k}T^{\prime }X=X^{\prime \prime }T$ Dividing by $$XT\neq 0$$$\frac{1}{k}\frac{T^{\prime }}{T}=\frac{X^{\prime \prime }}{X}$ Since each side depends on diﬀerent independent variable and both are equal, they must be both equal to same constant, say $$-\lambda$$. Where $$\lambda$$ is assumed real. $\frac{1}{k}\frac{T^{\prime }}{T}=\frac{X^{\prime \prime }}{X}=-\lambda$ The two ODE’s generated are\begin{align} T^{\prime }+k\lambda T & =0\tag{1}\\ X^{\prime \prime }+\lambda X & =0\tag{2} \end{align}

Starting with the space ODE equation (2), with corresponding boundary conditions $$\frac{dX}{dx}\left ( 0\right ) =0,\frac{dX}{dx}\left ( L\right ) =0$$. Assuming the solution is $$X\left ( x\right ) =e^{rx}$$, Then the characteristic equation is\begin{align*} r^{2}+\lambda & =0\\ r^{2} & =-\lambda \\ r & =\pm \sqrt{-\lambda } \end{align*}

The following cases are considered.

case $$\lambda <0$$ In this case, $$-\lambda$$ and also $$\sqrt{-\lambda }$$ are positive. Hence the roots $$\pm \sqrt{-\lambda }$$ are both real. Let $\sqrt{-\lambda }=s$ Where $$s>0$$. This gives the solution\begin{align*} X\left ( x\right ) & =A\cosh \left ( sx\right ) +B\sinh \left ( sx\right ) \\ \frac{dX}{dx} & =A\sinh \left ( sx\right ) +B\cosh \left ( sx\right ) \end{align*}

Applying the left B.C. gives\begin{align*} 0 & =\frac{dX}{dx}\left ( 0\right ) \\ & =B\cosh \left ( 0\right ) \\ & =B \end{align*}

The solution becomes $$X\left ( x\right ) =A\cosh \left ( sx\right )$$ and hence$$\frac{dX}{dx}=A\sinh \left ( sx\right )$$. Applying the right B.C. gives\begin{align*} 0 & =\frac{dX}{dx}\left ( L\right ) \\ & =A\sinh \left ( sL\right ) \end{align*}

$$A=0$$ result in trivial solution. Therefore assuming $$\sinh \left ( sL\right ) =0$$ implies $$sL=0$$ which is not valid since $$s>0$$ and $$L\neq 0$$. Hence only trivial solution results from this case. $$\lambda <0$$ is not an eigenvalue.

case $$\lambda =0$$

The ODE becomes$\frac{d^{2}X}{dx^{2}}=0$ The solution is\begin{align*} X\left ( x\right ) & =c_{1}x+c_{2}\\ \frac{dX}{dx} & =c_{1} \end{align*}

Applying left boundary conditions gives\begin{align*} 0 & =\frac{dX}{dx}\left ( 0\right ) \\ & =c_{1} \end{align*}

Hence the solution becomes $$X\left ( x\right ) =c_{2}$$. Therefore $$\frac{dX}{dx}=0$$. Applying the right B.C. provides no information.

Therefore this case leads to the solution $$X\left ( x\right ) =c_{2}$$. Associated with this one eigenvalue, the time equation becomes $$\frac{dT_{0}}{dt}=0$$ hence $$T_{0}$$ is constant, say $$\alpha$$. Hence the solution $$u_{0}\left ( x,t\right )$$ associated with this $$\lambda =0$$ is\begin{align*} u_{0}\left ( x,t\right ) & =X_{0}T_{0}\\ & =c_{2}\alpha \\ & =A_{0} \end{align*}

where constant $$c_{2}\alpha$$ was renamed to $$A_{0}$$ to indicate it is associated with $$\lambda =0$$.  $$\lambda =0$$ is an eigenvalue.

case $$\lambda >0$$

Hence $$-\lambda$$ is negative, and the roots are both complex. $r=\pm i\sqrt{\lambda }$ The solution is\begin{align*} X\left ( x\right ) & =A\cos \left ( \sqrt{\lambda }x\right ) +B\sin \left ( \sqrt{\lambda }x\right ) \\ \frac{dX}{dx} & =-A\sqrt{\lambda }\sin \left ( \sqrt{\lambda }x\right ) +B\sqrt{\lambda }\cos \left ( \sqrt{\lambda }x\right ) \end{align*}

Applying the left B.C. gives\begin{align*} 0 & =\frac{dX}{dx}\left ( 0\right ) \\ & =B\sqrt{\lambda }\cos \left ( 0\right ) \\ & =B\sqrt{\lambda } \end{align*}

Therefore $$B=0$$ as $$\lambda >0$$. The solution becomes $$X\left ( x\right ) =A\cos \left ( \sqrt{\lambda }x\right )$$ and $$\frac{dX}{dx}=-A\sqrt{\lambda }\sin \left ( \sqrt{\lambda }x\right )$$. Applying the right B.C. gives\begin{align*} 0 & =\frac{dX}{dx}\left ( L\right ) \\ & =-A\sqrt{\lambda }\sin \left ( \sqrt{\lambda }L\right ) \end{align*}

$$A=0$$ gives a trivial solution. Selecting $$\sin \left ( \sqrt{\lambda }L\right ) =0$$ gives$\sqrt{\lambda }L=n\pi \qquad n=1,2,3,\cdots$ Or$\lambda _{n}=\left ( \frac{n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots$ Therefore the space solution is$X_{n}\left ( x\right ) =A_{n}\cos \left ( \frac{n\pi }{L}x\right ) \qquad n=1,2,3,\cdots$ The time solution is found by solving $\frac{dT_{n}}{dt}+k\lambda _{n}T_{n}=0$ This has the solution\begin{align*} T_{n}\left ( t\right ) & =e^{-k\lambda _{n}t}\\ & =e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\qquad n=1,2,3,\cdots \end{align*}

For the same set of eigenvalues. Notice that no need to add a constant here, since it will be absorbed in the $$A_{n}$$ when combined in the following step below. Since for $$\lambda =0$$ the time solution was found to be constant, and for $$\lambda >0$$ the time solution is $$e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$$, then no time solution will grow with time. Time solutions always decay with time as the exponent $$-k\left ( \frac{n\pi }{L}\right ) ^{2}t$$ is negative quantity. The solution to the PDE for $$\lambda >0$$ is $u_{n}\left ( x,t\right ) =T_{n}\left ( t\right ) X_{n}\left ( x\right ) \qquad n=0,1,2,3,\cdots$ But for linear system sum of eigenfunctions is also a solution. Hence\begin{align*} u\left ( x,t\right ) & =u_{\lambda =0}\left ( x,t\right ) +\sum _{n=1}^{\infty }u_{n}\left ( x,t\right ) \\ & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}

From the solution found above, setting $$t=0$$ gives$f\left ( x\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right )$ Multiplying both sides with $$\cos \left ( \frac{m\pi }{L}x\right )$$ where in this problem $$m=0,1,2,\cdots$$ (since there was an eigenvalue associated with $$\lambda =0$$), and integrating over the domain gives\begin{align*} \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx & =\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) \left ( A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) \right ) dx\\ & =\int _{0}^{L}A_{0}\cos \left ( \frac{m\pi }{L}x\right ) dx+\int \cos \left ( \frac{m\pi }{L}x\right ) \sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) dx\\ & =\int _{0}^{L}A_{0}\cos \left ( \frac{m\pi }{L}x\right ) dx+\int _{0}^{L}\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{m\pi }{L}x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx \end{align*}

Interchanging the order of summation and integration$$\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx=\int _{0}^{L}A_{0}\cos \left ( \frac{m\pi }{L}x\right ) dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\tag{1}$$ case $$m=0$$

When $$m=0$$ then $$\cos \left ( \frac{m\pi }{L}x\right ) =1$$ and the above simpliﬁes to$\int _{0}^{L}f\left ( x\right ) dx=\int _{0}^{L}A_{0}dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac{n\pi }{L}x\right ) dx$ But $$\int _{0}^{L}\cos \left ( \frac{n\pi }{L}x\right ) dx=0$$ and the above becomes\begin{align*} \int _{0}^{L}f\left ( x\right ) dx & =\int _{0}^{L}A_{0}dx\\ & =A_{0}L \end{align*}

Therefore$A_{0}=\frac{1}{L}\int _{0}^{L}f\left ( x\right ) dx$ case $$m>0$$

From (1), one term survives in the integration when only $$n=m$$, hence$\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx=A_{0}\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) dx+A_{m}\int _{0}^{L}\cos ^{2}\left ( \frac{m\pi }{L}x\right ) dx$ But $$\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) dx=0$$ and the above becomes$\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx=A_{m}\frac{L}{2}$ Therefore$A_{n}=\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx$ For $$n=1,2,3,\cdots$$

Therefore the solution is\begin{align*} u\left ( x,t\right ) & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\\ & =\frac{1}{L}\int _{0}^{L}f\left ( x\right ) dx+\frac{2}{L}\sum _{n=1}^{\infty }\left ( \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) \cos \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}

In the limit as $$t\rightarrow \infty$$ the term $$e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\rightarrow 0$$. What is left is $$A_{0}$$. But $$A_{0}=\frac{1}{L}\int _{0}^{L}f\left ( x\right ) dx$$ from above. This quantity is the average of the initial temperature.

_______________________________________________________________________________________

5.6 left and right end ﬁxed at zero, with heat sink (Haberman 2.3.8)

problem number 25

This is problem 2.3.8, from Richard Haberman applied partial diﬀerential equations, 5th edition.

Consider the heat equation

$\frac{ \partial u}{\partial t} = k \frac{ \partial ^2 u}{\partial x^2} - \alpha u$

This corresponds to a one-dimentional rod either with heat loss through the lateral sides with outside temperature zero degrees ($$\alpha >0$$) or with insulated sides with a heat sink propertional to the temperature.

Suppose the boundary conditions are $$u(0,t)=0,u(L,t)=0$$, solve with the temperature initially $$u\left ( x,0\right ) =f(x)$$ if $$\alpha >0$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t)-a u(x,t),\{u(0,t)=0,u(L,t)=0\},u(x,0)=f(x)\right \},u(x,t),\{x,t\}\right ]$

Maple

$u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac{1}{L}\sin \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{t \left ({\pi }^{2}k{n}^{2}+{L}^{2}\alpha \right ) }{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \sin \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x} \right )$

Hand solution

\begin{align*} \frac{\partial u}{\partial t} & =k\frac{\partial ^{2}u}{\partial x^{2}}-\alpha u\\ \frac{\partial u}{\partial t}+\alpha u & =k\frac{\partial ^{2}u}{\partial x^{2}} \end{align*}

Assuming $$u\left ( x,t\right ) =X\left ( x\right ) T\left ( t\right )$$ and substituting in the above gives$XT^{\prime }+\alpha XT=kTX^{\prime \prime }$ Dividing by $$kXT\neq 0$$$\frac{T^{\prime }}{kT}+\frac{\alpha }{k}=\frac{X^{\prime \prime }}{X}$ Since each side depends on diﬀerent independent variable and both are equal, they must be both equal to same constant, say $$-\lambda$$. Where $$\lambda$$ is assumed real. $\frac{1}{k}\frac{T^{\prime }}{T}+\frac{\alpha }{k}=\frac{X^{\prime \prime }}{X}=-\lambda$ The two ODE’s are\begin{align*} \frac{1}{k}\frac{T^{\prime }}{T}+\frac{\alpha }{k} & =-\lambda \\ \frac{X^{\prime \prime }}{X} & =-\lambda \end{align*}

Or\begin{align*} T^{\prime }+\left ( \alpha +\lambda k\right ) T & =0\\ X^{\prime \prime }+\lambda X & =0 \end{align*}

The solution to the space ODE is the familiar (where $$\lambda >0$$ is only possible case, As found in Haberman problem 2.3.3, part d. Since it has the same B.C.) $X_{n}=B_{n}\sin \left ( \frac{n\pi }{L}x\right ) \qquad n=1,2,3,\cdots$ Where $$\lambda _{n}=\left ( \frac{n\pi }{L}\right ) ^{2}$$. The time ODE is now solved.$\frac{dT_{n}}{dt}+\left ( \alpha +\lambda _{n}k\right ) T_{n}=0$ This has the solution\begin{align*} T_{n}\left ( t\right ) & =e^{-\left ( \alpha +\lambda _{n}k\right ) t}\\ & =e^{-\alpha t}e^{-\left ( \frac{n\pi }{L}\right ) ^{2}kt} \end{align*}

For the same eigenvalues. Notice that no need to add a constant here, since it will be absorbed in the $$B_{n}$$ when combined in the following step below. Therefore the solution to the PDE is$u_{n}\left ( x,t\right ) =T_{n}\left ( t\right ) X_{n}\left ( x\right )$ But for linear system sum of eigenfunctions is also a solution. Hence\begin{align*} u\left ( x,t\right ) & =\sum _{n=1}^{\infty }u_{n}\left ( x,t\right ) \\ & =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) e^{-\alpha t}e^{-\left ( \frac{n\pi }{L}\right ) ^{2}kt}\\ & =e^{-\alpha t}\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right ) e^{-\left ( \frac{n\pi }{L}\right ) ^{2}kt} \end{align*}

Where $$e^{-\alpha t}$$ was moved outside since it does not depend on $$n$$. From initial condition$u\left ( x,0\right ) =f\left ( x\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \frac{n\pi }{L}x\right )$ Applying orthogonality of $$\sin$$ as before to ﬁnd $$B_{n}$$ results in$B_{n}=\frac{2}{L}\int _{0}^{L}\sin \left ( \frac{n\pi }{L}x\right ) f\left ( x\right ) dx$ Hence the solution becomes\begin{align*} u\left ( x,t\right ) & =\frac{2}{L}e^{-\alpha t}\left ( \sum _{n=1}^{\infty }\left ( \int _{0}^{L}\sin \left ( \frac{n\pi }{L}x\right ) f\left ( x\right ) dx\right ) \sin \left ( \frac{n\pi }{L}x\right ) e^{-\left ( \frac{n\pi }{L}\right ) ^{2}kt}\right ) \\ & =\frac{2}{L}\sum _{n=1}^{\infty }\left ( \int _{0}^{L}\sin \left ( \frac{n\pi }{L}x\right ) f\left ( x\right ) dx\right ) \sin \left ( \frac{n\pi }{L}x\right ) e^{-t\left ( \frac{n^{2}\pi ^{2}k+\alpha L^{2}}{L^{2}}\right ) } \end{align*}

Hence it is clear that in the limit as $$t$$ becomes large $$u\left ( x,t\right ) \rightarrow 0$$ since $$\alpha >0$$ and$\lim _{t\rightarrow \infty }u\left ( x,t\right ) =0$

_______________________________________________________________________________________

5.7 left and right end insulated, No source (Haberman 2.4.1 (a))

problem number 26

This is problem 2.4.1 part(a) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Consider the heat equation

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

The boundary conditions are $$\frac{\partial u}{\partial x}(0,t)=0$$ $$\frac{\partial u}{\partial x}(L,t)=0$$ with the temperature initially $$u\left ( x,0\right ) =\left \{ \begin{array} [c]{ccc}0 & & x< \frac{L}{2}\\ 1 & & x> \frac{L}{2} \end{array} \right .$$

Mathematica

$\left \{\left \{u(x,t)\to \frac{2 \underset{n=1}{\overset{\infty }{\sum }}-\frac{e^{-\frac{k n^2 \pi ^2 t}{L^2}} L \cos \left (\frac{n \pi x}{L}\right ) \sin \left (\frac{n \pi }{2}\right )}{n \pi }}{L}+\frac{1}{2}\right \}\right \}$

Maple

$u \left ( x,t \right ) =1/2+\sum _{n=1}^{\infty }-2\,{\frac{\sin \left ( 1/2\,n\pi \right ) }{n\pi }\cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{{\pi }^{2}k{n}^{2}t}{{L}^{2}}}}}}$

_______________________________________________________________________________________

5.8 left and right end insulated, No source (Haberman 2.4.1 (b))

problem number 27

This is problem 2.4.1 part(b) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Solve the heat equation

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

The boundary conditions are $$\frac{\partial u}{\partial x}(0,t)=0$$ $$\frac{\partial u}{\partial x}(L,t)=0$$ with the temperature initially $$u(x,0)=6+ 4 \cos \left ( \frac{3 \pi x}{L} \right )$$

Mathematica

$\left \{\left \{u(x,t)\to 4 e^{-\frac{9 \pi ^2 k t}{L^2}} \cos \left (\frac{3 \pi x}{L}\right )+6\right \}\right \}$

Maple

$u \left ( x,t \right ) =6+4\,\cos \left ( 3\,{\frac{\pi \,x}{L}} \right ){{\rm e}^{-9\,{\frac{k\,{\pi }^{2}t}{{L}^{2}}}}}$

Hand solution

The same boundary conditions was encountered in Haberman problem 2.3.7 earlier, therefore the solution used here starts from the same general solution already found, which is\begin{align*} \lambda _{0} & =0\\ \lambda _{n} & =\left ( \frac{n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \\ u\left ( x,t\right ) & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}

At $$t=0$$, the above becomes\begin{align*} A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) & =f\left ( x\right ) \\ & =6+4\cos \frac{3\pi x}{L} \end{align*}

Comparing terms shows that\begin{align*} A_{0} & =6\\ A_{3} & =4 \end{align*}

And all other $$A_{n}=0$$. Hence the solution is$u\left ( x,t\right ) =6+4\cos \left ( \frac{3\pi }{L}x\right ) e^{-k\left ( \frac{3\pi }{L}\right ) ^{2}t}$

_______________________________________________________________________________________

5.9 left and right end insulated, No source (Haberman 2.4.1 (c))

problem number 28

This is problem 2.4.1 part(c) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Solve the heat equation

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

The boundary conditions are $$\frac{\partial u}{\partial x}(0,t)=0$$ $$\frac{\partial u}{\partial x}(L,t)=0$$ with the temperature initially $$u(x,0)=-2 \sin \frac{\pi x}{L}$$

Mathematica

$\left \{\left \{u(x,t)\to \frac{2 \underset{n=1}{\overset{\infty }{\sum }}\frac{2 \left (1+(-1)^n\right ) e^{-\frac{k n^2 \pi ^2 t}{L^2}} L \cos \left (\frac{n \pi x}{L}\right )}{\left (n^2-1\right ) \pi }}{L}-\frac{4}{\pi }\right \}\right \}$

Maple

$u \left ( x,t \right ) ={\frac{1}{\pi } \left ( \sum _{n=2}^{\infty }4\,{\frac{ \left ( -1 \right ) ^{n}+1}{\pi \, \left ({n}^{2}-1 \right ) }\cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{k\,{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}}\pi -4 \right ) }$

Hand solution

The same boundary conditions was encountered in Haberman problem 2.3.7 solved above, therefore the solution used here starts from the same general solution already found, which is\begin{align*} \lambda _{0} & =0\\ \lambda _{n} & =\left ( \frac{n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \\ u\left ( x,t\right ) & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}

At $$t=0$$ the above becomes\begin{align*} f\left ( x\right ) & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) \\ -2\sin \frac{\pi x}{L} & =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) \end{align*}

Multiplying both sides by $$\cos \left ( \frac{m\pi }{L}x\right )$$ and integrating gives\begin{align*} -2\int _{0}^{L}\sin \left ( \frac{\pi x}{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx & =\int _{0}^{L}\left ( A_{0}\cos \left ( \frac{m\pi }{L}x\right ) +\cos \left ( \frac{m\pi }{L}x\right ) \sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{n\pi }{L}x\right ) \right ) dx\\ & =\int _{0}^{L}A_{0}\cos \left ( \frac{m\pi }{L}x\right ) dx+\int _{0}^{L}\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{m\pi }{L}x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx \end{align*}

Interchanging the order of integration and summation$\int _{0}^{L}-2\sin \left ( \frac{\pi x}{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx=\int _{0}^{L}A_{0}\cos \left ( \frac{m\pi }{L}x\right ) dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx$ Case $$m=0$$

The above becomes$-2\int _{0}^{L}\sin \left ( \frac{\pi x}{L}\right ) dx=\int _{0}^{L}A_{0}dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac{n\pi }{L}x\right ) dx$ But $$\int _{0}^{L}\cos \left ( \frac{n\pi }{L}x\right ) dx=0$$ hence\begin{align*} \int _{0}^{L}-2\sin \left ( \frac{\pi x}{L}\right ) dx & =\int _{0}^{L}A_{0}dx\\ A_{0}L & =-2\int _{0}^{L}\sin \left ( \frac{\pi x}{L}\right ) dx\\ A_{0}L & =-2\left ( -\frac{\cos \left ( \frac{\pi x}{L}\right ) }{\frac{\pi }{L}}\right ) _{0}^{L}\\ & =-\frac{2L}{\pi }\left ( -\cos \left ( \frac{\pi L}{L}\right ) +\cos \left ( \frac{\pi 0}{L}\right ) \right ) \\ & =-\frac{2L}{\pi }\left ( -\left ( -1\right ) +1\right ) \\ & =-\frac{4L}{\pi } \end{align*}

Hence$A_{0}=\frac{-4}{\pi }$ Case $$m>0$$

$\int _{0}^{L}-2\sin \left ( \frac{\pi x}{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx=\int _{0}^{L}A_{0}\cos \left ( \frac{m\pi }{L}x\right ) dx+\sum _{n=1}^{\infty }A_{n}\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx$ One term survives the summation resulting in$\int _{0}^{L}-2\sin \left ( \frac{\pi x}{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx=\frac{-4}{\pi }\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) dx+A_{m}\int _{0}^{L}\cos ^{2}\left ( \frac{m\pi }{L}x\right ) dx$ But $$\int _{0}^{L}\cos \left ( \frac{m\pi }{L}x\right ) dx=0$$ and $$\int _{0}^{L}\cos ^{2}\left ( \frac{m\pi }{L}x\right ) dx=\frac{L}{2}$$, therefore\begin{align*} \int _{0}^{L}-2\sin \left ( \frac{\pi x}{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx & =A_{m}\frac{L}{2}\\ A_{n} & =\frac{-4}{L}\int _{0}^{L}\sin \left ( \frac{\pi x}{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx \end{align*}

But$\int _{0}^{L}\sin \left ( \frac{\pi x}{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx=\frac{-L\left ( 1+\cos \left ( n\pi \right ) \right ) }{\pi \left ( n^{2}-1\right ) }$ Therefore\begin{align*} A_{n} & =4\frac{\left ( 1+\cos \left ( n\pi \right ) \right ) }{\pi \left ( n^{2}-1\right ) }\\ & =4\frac{\left ( -1\right ) ^{n}+1}{\pi \left ( n^{2}-1\right ) }\qquad n=1,2,3,\cdots \end{align*}

Hence the solution becomes$u\left ( x,t\right ) =\frac{-4}{\pi }+\frac{4}{\pi }\sum _{n=1}^{\infty }\frac{\left ( -1\right ) ^{n}+1}{\left ( n^{2}-1\right ) }\cos \left ( \frac{n\pi }{L}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$

_______________________________________________________________________________________

5.10 left and right end insulated, No source (Haberman 2.4.1 (d))

problem number 29

This is problem 2.4.1 part(d) from Richard Haberman applied partial diﬀerential equations, 5th edition.

Solve the heat equation

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

The boundary conditions are $$\frac{\partial u}{\partial x}(0,t)=0$$ and $$\frac{\partial u}{\partial x}(L,t)=0$$ with the temperature initially $$u(x,0)=-3 \cos \frac{8 \pi x}{L}$$

Mathematica

$\left \{\left \{u(x,t)\to -3 e^{-\frac{64 \pi ^2 k t}{L^2}} \cos \left (\frac{8 \pi x}{L}\right )\right \}\right \}$

Maple

$u \left ( x,t \right ) =-3\,\cos \left ( 8\,{\frac{\pi \,x}{L}} \right ){{\rm e}^{-64\,{\frac{k\,{\pi }^{2}t}{{L}^{2}}}}}$

_______________________________________________________________________________________

5.11 left and insulated, right end ﬁxed at zero. No source (Haberman 2.4.2)

problem number 30

This is problem 2.4.2 from Richard Haberman applied partial diﬀerential equations, 5th edition.

Solve the heat equation

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

The boundary conditions are $$\frac{\partial u}{\partial x}(0,t)=0$$ $$u(L,t)=0$$ with the temperature initially $$u(x,0)=f(x)$$

Mathematica

$\left \{\left \{u(x,t)\to \frac{2 \underset{n=0}{\overset{\infty }{\sum }}e^{-\frac{k (2 n+1)^2 \pi ^2 t}{4 L^2}} \cos \left (\frac{(2 n+1) \pi x}{2 L}\right ) \int _0^L \cos \left (\frac{(2 n+1) \pi x}{2 L}\right ) f(x) \, dx}{L}\right \}\right \}$

Maple

$u \left ( x,t \right ) =\sum _{n=0}^{\infty } \left ( 2\,{\frac{1}{L}\cos \left ( 1/2\,{\frac{ \left ( 1+2\,n \right ) \pi \,x}{L}} \right ){{\rm e}^{-1/4\,{\frac{k\,{\pi }^{2} \left ( 1+2\,n \right ) ^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \cos \left ( 1/2\,{\frac{ \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) \,{\rm d}x} \right )$

Hand solution

$\frac{\partial u}{\partial t}=\kappa \frac{\partial ^{2}u}{\partial x^{2}}$ Let $$u\left ( x,t\right ) =T\left ( t\right ) X\left ( x\right )$$, then the PDE becomes$\frac{1}{\kappa }T^{\prime }X=X^{\prime \prime }T$ Dividing by $$XT$$$\frac{1}{\kappa }\frac{T^{\prime }}{T}=\frac{X^{\prime \prime }}{X}$ Since each side depends on diﬀerent independent variable and both are equal, they must be both equal to same constant, say $$-\lambda$$. Where $$\lambda$$ is real. $\frac{1}{\kappa }\frac{T^{\prime }}{T}=\frac{X^{\prime \prime }}{X}=-\lambda$ The two ODE’s are\begin{align} T^{\prime }+k\lambda T & =0\tag{1}\\ X^{\prime \prime }+\lambda X & =0\tag{2} \end{align}

Per problem statement, $$\lambda \geq 0$$, so only two cases needs to be examined.

Case $$\lambda =0$$

The space equation becomes $$X^{\prime \prime }=0$$ with the solution $X=Ax+b$ Hence left B.C. implies $$X^{\prime }\left ( 0\right ) =0$$ or $$A=0$$. Therefore the solution becomes $$X=b$$. The right B.C. implies $$X\left ( L\right ) =0$$ or $$b=0$$. Therefore this leads to $$X=0$$ as the only solution. This results in trivial solution. Therefore $$\lambda =0$$ is not an eigenvalue.

Case $$\lambda >0$$

Starting with the space ODE, the solution is\begin{align*} X\left ( x\right ) & =A\cos \left ( \sqrt{\lambda }x\right ) +B\sin \left ( \sqrt{\lambda }x\right ) \\ X^{\prime }\left ( x\right ) & =-A\sqrt{\lambda }\sin \left ( \sqrt{\lambda }x\right ) +B\sqrt{\lambda }\cos \left ( \sqrt{\lambda }x\right ) \end{align*}

Left B.C. gives\begin{align*} 0 & =X^{\prime }\left ( 0\right ) \\ & =B\sqrt{\lambda } \end{align*}

Hence $$B=0$$ since it is assumed $$\lambda \neq 0$$ and $$\lambda >0$$. Solution becomes$X\left ( x\right ) =A\cos \left ( \sqrt{\lambda }x\right )$ Applying right B.C. gives\begin{align*} 0 & =X\left ( L\right ) \\ & =A\cos \left ( \sqrt{\lambda }L\right ) \end{align*}

$$A=0$$ leads to trivial solution. Therefore $$\cos \left ( \sqrt{\lambda }L\right ) =0$$ or\begin{align*} \sqrt{\lambda } & =\frac{n\pi }{2L}\qquad n=1,3,5,\cdots \\ & =\frac{\left ( 2n-1\right ) \pi }{2L}\qquad n=1,2,3\cdots \end{align*}

Hence\begin{align*} \lambda _{n} & =\left ( \frac{n\pi }{2L}\right ) ^{2}\qquad n=1,3,5,\cdots \\ & =\frac{\left ( 2n-1\right ) ^{2}\pi ^{2}}{4L^{2}}\qquad n=1,2,3\cdots \end{align*}

Therefore$X_{n}\left ( x\right ) =A_{n}\cos \left ( \frac{n\pi }{2L}x\right ) \qquad n=1,3,5,\cdots$ And the corresponding time solution$T_{n}=e^{-k\left ( \frac{n\pi }{2L}\right ) ^{2}t}\qquad n=1,3,5,\cdots$ Hence\begin{align*} u_{n}\left ( x,t\right ) & =X_{n}T_{n}\\ u\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }A_{n}\cos \left ( \frac{n\pi }{2L}x\right ) e^{-k\left ( \frac{n\pi }{2L}\right ) ^{2}t}\\ & =\sum _{n=1}^{\infty }A_{n}\cos \left ( \frac{\left ( 2n-1\right ) \pi }{2L}x\right ) e^{-k\left ( \frac{\left ( 2n-1\right ) \pi }{2L}\right ) ^{2}t} \end{align*}

From initial conditions$f\left ( x\right ) =\sum _{n=1,3,5,\cdots }^{\infty }A_{n}\cos \left ( \frac{n\pi }{2L}x\right )$ Multiplying both sides by $$\cos \left ( \frac{m\pi }{2L}x\right )$$ and integrating$\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{m\pi }{2L}x\right ) dx=\int \left ( \sum _{n=1,3,5,\cdots }^{\infty }A_{n}\cos \left ( \frac{m\pi }{2L}x\right ) \cos \left ( \frac{n\pi }{2L}x\right ) \right ) dx$ Interchanging order of summation and integration and applying orthogonality results in\begin{align*} \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{m\pi }{2L}x\right ) dx & =A_{m}\frac{L}{2}\\ A_{n} & =\frac{2}{L}\int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{n\pi }{2L}x\right ) dx \end{align*}

Therefore the solution is\begin{align*} u\left ( x,t\right ) & =\frac{2}{L}\sum _{n=1,3,5,\cdots }^{\infty }\left [ \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{n\pi }{2L}x\right ) dx\right ] \cos \left ( \frac{n\pi }{2L}x\right ) e^{-k\left ( \frac{n\pi }{2L}\right ) ^{2}t}\\ & =\frac{2}{L}\sum _{n=0}^{\infty }\left ( \int _{0}^{L}f\left ( x\right ) \cos \left ( \frac{\left ( 2n+1\right ) \pi }{2L}x\right ) dx\right ) \cos \left ( \frac{\left ( 2n+1\right ) \pi }{2L}x\right ) e^{-k\left ( \frac{\left ( 2n+1\right ) \pi }{2L}\right ) ^{2}t} \end{align*}

_______________________________________________________________________________________

5.12 Left end insulated, right end has convection heat loss, No source

problem number 31

This problem is taken from Maple primes post https://www.mapleprimes.com/posts/209681-Solving-PDEs-With-Initial-And-Boundary

Solve the heat equation

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

The boundary conditions are, on the left end $$\frac{\partial u}{\partial x}(0,t)=0$$ and on the right end $$\frac{\partial u}{\partial x}(1,t)=-u(1,t)$$ with the temperature initially $$u(x,0)=1-\frac{1}{4} x^3$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t),\left \{u^{(1,0)}(0,t)=0,u^{(1,0)}(1,t)=-u(1,t)\right \},u(x,0)=1-\frac{x^3}{4}\right \},u(x,t),\{x,t\},\text{Assumptions}\to \{k>0,t>0\}\right ]$

Maple

$u \left ( x,t \right ) =\mbox{{\tt casesplit/ans}} \left ( \sum _{n=0}^{\infty }3\,{\frac{{{\rm e}^{-k{\lambda _{{n}}}^{2}t}} \left ( \left ({\lambda _{{n}}}^{3}+2\,\lambda _{{n}} \right ) \sin \left ( \lambda _{{n}} \right ) -2+ \left ( -{\lambda _{{n}}}^{2}+2 \right ) \cos \left ( \lambda _{{n}} \right ) \right ) \cos \left ( \lambda _{{n}}x \right ) }{{\lambda _{{n}}}^{3} \left ( \sin \left ( 2\,\lambda _{{n}} \right ) +2\,\lambda _{{n}} \right ) }}, \left \{{\it And} \left ( \tan \left ( \lambda _{{n}} \right ) \lambda _{{n}}-1=0,0<\lambda _{{n}} \right ) \right \} \right )$

_______________________________________________________________________________________

5.13 Periodic boundary conditions, No source

problem number 32

Solve the heat equation

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

For $$-L<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} u(-L,t) &= u(L,t) \\ \frac{ \partial u}{\partial x}(-L,t) &= \frac{ \partial u}{\partial x}(L,t) \end{align*}

And initial conditions $$u(x,0)=f(x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t),\left \{u(-L,t)=u(L,t),u^{(1,0)}(-L,t)=u^{(1,0)}(L,t)\right \},u(x,0)=f(x)\right \},u(x,t),\{x,t\},\text{Assumptions}\to \{-L\leq x\leq L,t>0\}\right ]$

Maple

$u \left ( x,t \right ) =1/2\,{\frac{1}{L} \left ( 2\,\sum _{n=1}^{\infty } \left ({\frac{1}{L}{{\rm e}^{-{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}} \left ( \sin \left ({\frac{n\pi \,x}{L}} \right ) \int _{-L}^{L}\!f \left ( x \right ) \sin \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x+\cos \left ({\frac{n\pi \,x}{L}} \right ) \int _{-L}^{L}\!f \left ( x \right ) \cos \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x \right ) } \right ) L+\int _{-L}^{L}\!f \left ( x \right ) \,{\rm d}x \right ) }$

_______________________________________________________________________________________

5.14 Left and right end have Robin boundary conditions. No source

problem number 33

Solve the heat equation

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

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{ \partial u}{\partial x}(0,t) +u(0,t) &=0 \\ \frac{ \partial u}{\partial x}(L,t) +u(L,t) &=0 \end{align*}

And initial condition $$u(x,0)=f(x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t),\left \{u^{(1,0)}(0,t)+u(0,t)=0,u^{(1,0)}(L,t)+u(L,t)=0\right \},u(x,0)=f(x)\right \},u(x,t),\{x,t\},\text{Assumptions}\to \{t\geq 0,k>0,x\geq 0,x\leq L\}\right ]$

Maple

$u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac{1}{L \left ({\pi }^{2}{n}^{2}+{L}^{2} \right ) } \left ( -\pi \,n\cos \left ({\frac{n\pi \,x}{L}} \right ) +\sin \left ({\frac{n\pi \,x}{L}} \right ) L \right ){{\rm e}^{-{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \left ( -\pi \,n\cos \left ({\frac{n\pi \,x}{L}} \right ) +\sin \left ({\frac{n\pi \,x}{L}} \right ) L \right ) \,{\rm d}x} \right )$

_______________________________________________________________________________________

5.15 with domain from -1 to +1, both ends ﬁxed at zero temperature. no source

problem number 34

Solve the heat equation

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

For $$-1<x<1$$ and $$t>0$$. The boundary conditions are zero at both ends. Initial condition is $$u(x,0)=f(x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=u^{(2,0)}(x,t),\{u(-1,t)=0,u(1,t)=0\},u(x,0)=f(x)\right \},u(x,t),\{x,t\}\right ]$

Maple

$u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( \sin \left ( n\pi \,x \right ){{\rm e}^{-{\pi }^{2}{n}^{2}t}}\int _{-1}^{1}\!f \left ( x \right ) \sin \left ( n\pi \,x \right ) \,{\rm d}x+\cos \left ( 1/2\, \left ( 2\,n-1 \right ) \pi \,x \right ){{\rm e}^{-1/4\,{\pi }^{2} \left ( 2\,n-1 \right ) ^{2}t}}\int _{-1}^{1}\!f \left ( x \right ) \cos \left ( 1/2\, \left ( 2\,n-1 \right ) \pi \,x \right ) \,{\rm d}x \right )$

_______________________________________________________________________________________

5.16 Left and right end ﬁxed at non-zero temperature, zero intial conditions, no source term

problem number 35

Taken from Maple PDE help pages

Solve the heat equation

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

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= 20 \\ u(1,t) &= 50 \end{align*}

Initial condition is $$u(x,0)=0$$

Mathematica

$\left \{\left \{u(x,t)\to -\frac{2 \underset{n=1}{\overset{\infty }{\sum }}\frac{\left (20-50 (-1)^n\right ) e^{-n^2 \pi ^2 t} \sin (n \pi x)}{n}}{\pi }+30 x+20\right \}\right \}$

Maple

$u \left ( x,t \right ) =20+30\,x+\sum _{n=1}^{\infty }{\frac{ \left ( 100\, \left ( -1 \right ) ^{n}-40 \right ) \sin \left ( n\pi \,x \right ){{\rm e}^{k{\pi }^{2}{n}^{2}t}}}{n\pi }}$

_______________________________________________________________________________________

5.17 Left held at constant non-zero temperature, right nonhomogeneous Neumann, No source (Haberman 8.2.1 (a))

problem number 36

This is problem 8.2.1 part(a) from Richard Haberman applied partial diﬀerential equations 5th edition.

Solve the heat equation

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

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= A \\ \frac{ \partial u}{\partial x}(L,t) &= B \end{align*}

Initial condition is $$u(x,0)=f(x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t),u(x,0)=f(x),\left \{u(0,t)=A,u^{(1,0)}(L,t)=B\right \}\right \},u(x,t),x,t,\text{Assumptions}\to L>0\right ]$

Maple

$u \left ( x,t \right ) =\sum _{n=0}^{\infty } \left ( -2\,{\frac{1}{L}\sin \left ( 1/2\,{\frac{ \left ( 1+2\,n \right ) \pi \,x}{L}} \right ){{\rm e}^{-1/4\,{\frac{k{\pi }^{2} \left ( 1+2\,n \right ) ^{2}t}{{L}^{2}}}}}\int _{0}^{L}\! \left ( Bx+A-f \left ( x \right ) \right ) \sin \left ( 1/2\,{\frac{ \left ( 1+2\,n \right ) \pi \,x}{L}} \right ) \,{\rm d}x} \right ) +Bx+A$

Hand solution

Let $$u\left ( x,t\right ) =v\left ( x,t\right ) +u_{E}\left ( x\right ) \tag{1}$$ We can look for $$u_{E}\left ( x\right )$$ which is the steady state solution that satisﬁes the non-homogenous boundary conditions. In (1) $$v\left ( x,t\right )$$ satisﬁes the PDE itself but with homogenous boundary conditions. The ﬁrst step is to ﬁnd $$u_{E}\left ( x\right )$$. We use the equilibrium solution in this case. At equilibrium $$\frac{\partial u_{E}\left ( x,t\right ) }{\partial t}=0$$ and hence the solution is given $$\frac{d^{2}u_{E}}{\partial x^{2}}=0$$ or $u_{E}\left ( x\right ) =c_{1}x+c_{2}$ At $$x=0,u_{E}\left ( x\right ) =A$$, Hence $c_{2}=A$ And solution becomes $$u_{E}\left ( x\right ) =c_{1}x+A$$. at $$x=L,\frac{\partial u_{E}\left ( x\right ) }{\partial x}=c_{1}=B$$, Therefore$u_{E}\left ( x\right ) =Bx+A$ Now we plug-in (1) into the original PDE, this gives$\frac{\partial v\left ( x,t\right ) }{\partial t}=k\left ( \frac{\partial ^{2}v\left ( x,t\right ) }{\partial x}+\frac{\partial ^{2}u_{E}\left ( x\right ) }{\partial x}\right )$ But $$\frac{\partial ^{2}u_{E}\left ( x\right ) }{\partial x}=0$$, hence we need to solve $\frac{\partial v\left ( x,t\right ) }{\partial t}=k\frac{\partial ^{2}v\left ( x,t\right ) }{\partial x}$ for $$v\left ( x,t\right ) =u\left ( x,t\right ) -u_{E}\left ( x\right )$$ with homogenous boundary conditions $$v\left ( 0,t\right ) =0,\frac{\partial v\left ( L,t\right ) }{\partial t}=0$$ and initial conditions \begin{align*} v\left ( x,0\right ) & =u\left ( x,0\right ) -u_{E}\left ( x\right ) \\ & =f\left ( x\right ) -\left ( Bx+A\right ) \end{align*}

This PDE we already solved before and we know that it has the following solution\begin{align} v\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt{\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\nonumber \\ \lambda _{n} & =\left ( \frac{n\pi }{2L}\right ) ^{2}\qquad n=1,3,5,\cdots \tag{2} \end{align}

With $$b_{n}$$ found from orthogonality using initial conditions $$v\left ( x,0\right ) =f\left ( x\right ) -\left ( Bx+A\right )$$\begin{align*} v\left ( x,0\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt{\lambda _{n}}x\right ) \\ \int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt{\lambda _{m}}x\right ) dx & =\int _{0}^{L}\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt{\lambda _{n}}x\right ) \sin \left ( \sqrt{\lambda _{m}}x\right ) dx\\ \int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt{\lambda _{m}}x\right ) dx & =b_{m}\frac{L}{2} \end{align*}

Hence$$b_{n}=\frac{2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt{\lambda _{n}}x\right ) dx\qquad n=1,3,5,\cdots \tag{3}$$ Therefore, from (1) the solution is\begin{align*} u\left ( x,t\right ) & =\sum _{n=1,3,5,\cdots }^{\infty }b_{n}\sin \left ( \sqrt{\lambda _{n}}x\right ) e^{-k\lambda _{n}t}+\overset{u_{E}\left ( x\right ) }{\overbrace{Bx+A}}\\ & =Bx+A+\sum _{n=1,3,5,\cdots }^{\infty }\left ( \frac{2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt{\frac{n\pi }{L}}x\right ) dx\right ) \sin \left ( \sqrt{\frac{n\pi }{L}}x\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t} \end{align*}

Or

$u\left ( x,t\right ) =Bx+A+\sum _{n=0}^{\infty }\left ( \frac{2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( Bx+A\right ) \right ) \sin \left ( \sqrt{\frac{\left ( 2n+1\right ) \pi }{2L}}x\right ) dx\right ) \sin \left ( \sqrt{\frac{\left ( 2n+1\right ) \pi }{2L}}x\right ) e^{-k\left ( \frac{\left ( 2n+1\right ) \pi }{2L}\right ) ^{2}t}$

_______________________________________________________________________________________

5.18 Left and right end ﬁxed at constant non-zero temperature, non zero intial conditions, with source term that is constant (Haberman 8.2.1 (d))

problem number 37

This is problem 8.2.1 part(d) from Richard Haberman applied partial diﬀerential equations 5th edition.

Solve the heat equation

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

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= A \\ u(L,t) &= B \end{align*}

Initial condition is $$u(x,0)=f(x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t)+k,u(x,0)=f(x),\{u(0,t)=\text{A0},u(\text{L0},t)=\text{B0}\}\right \},u(x,t),x,t\right ]$

Maple

$u \left ( x,t \right ) =1/2\,{\frac{1}{L} \left ( 2\,\sum _{n=1}^{\infty } \left ( -{\frac{1}{{L}^{2}}\int _{0}^{L}\!2\, \left ( -f \left ( x \right ) L+1/2\,{L}^{2}x+ \left ( -1/2\,{x}^{2}+A \right ) L-x \left ( A-B \right ) \right ) \sin \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x\sin \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}} \right ) L+{L}^{2}x+ \left ( -{x}^{2}+2\,A \right ) L-2\,x \left ( A-B \right ) \right ) }$

Hand solution

Let $$u\left ( x,t\right ) =v\left ( x,t\right ) +u_{E}\left ( x\right ) \tag{1}$$ Where $$u_{E}\left ( x\right )$$ is the equilibrium solution which needs to satisfy only the nonhomogeneous B.C. And $$v\left ( x,t\right )$$ is transient solution to heat PDE with homogeneous B.C.

At equilibrium, $$u_{t}=ku_{xx}+Q\left ( x\right )$$ becomes\begin{align*} 0 & =ku_{E}^{\prime \prime }+Q\left ( x\right ) \\ & =ku_{E}^{\prime \prime }+k\\ & =k\left ( u_{E}^{\prime \prime }+1\right ) \end{align*}

Hence$u_{E}^{\prime \prime }=-1$ The solution to this ODE is $u_{E}=c_{1}x+c_{2}-\frac{1}{2}x^{2}$ At $$x=0$$, the above gives$A=c_{2}$ And at $$x=L$$\begin{align*} B & =c_{1}L+A-\frac{1}{2}L^{2}\\ c_{1} & =\frac{B-A+\frac{1}{2}L^{2}}{L}\\ & =\frac{B}{L}-\frac{A}{L}+\frac{1}{2}L \end{align*}

Hence $u_{E}=\left ( \frac{B}{L}-\frac{A}{L}+\frac{1}{2}L\right ) x+A-\frac{1}{2}x^{2}$ Hence from (1)\begin{align} u\left ( x,t\right ) & =v\left ( x,t\right ) +u_{E}\tag{1A}\\ & =v\left ( x,t\right ) +\left ( \frac{B}{L}-\frac{A}{L}+\frac{1}{2}L\right ) x+A-\frac{1}{2}x^{2}\nonumber \end{align}

Substituting this in $$u_{t}=ku_{xx}+k$$ gives\begin{align} v_{t} & =k\left ( v_{xx}-1\right ) +k\nonumber \\ & =kv_{xx}\tag{2} \end{align}

We need to solve the above for $$v\left ( x,t\right )$$, but with homogeneous B.C. $$v\left ( 0,t\right ) =0,v\left ( L,t\right ) =0$$. The eigenvalues for the homogeneous PDE $$v_{t}=kv_{xx}$$ with these boundary conditions is known to be $$\lambda _{n}=\left ( \frac{n\pi }{L}\right ) ^{2}\,$$, for $$n=1,2,\cdots$$ and the corresponding eigenfunctions are $$X_{n}\left ( x\right ) =\sin \left ( \sqrt{\lambda _{n}}x\right )$$. Now, using eigenfunction expansion, let$$v\left ( x,t\right ) =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) X_{n}\left ( x\right ) \tag{3}$$ Substituting (3) into (2) gives$\sum _{n=1}^{\infty }b_{n}^{\prime }\left ( t\right ) X_{n}\left ( x\right ) =k\sum _{n=1}^{\infty }b_{n}\left ( t\right ) X_{n}^{\prime \prime }\left ( x\right )$ But $$X_{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}X_{n}\left ( x\right )$$, therefore the above becomes$\sum _{n=1}^{\infty }b_{n}^{\prime }\left ( t\right ) X_{n}\left ( x\right ) +k\sum _{n=1}^{\infty }\lambda _{n}b_{n}\left ( t\right ) X_{n}\left ( x\right ) =0$ Since the above is true for each $$n$$ and since eigenfunctions can not be zero, the above simpliﬁes to$$b_{n}^{\prime }\left ( t\right ) +k\lambda _{n}b_{n}\left ( t\right ) =0\tag{4}$$ This is linear in $$b\left ( t\right )$$. The solution using integrating factor is$b_{n}\left ( t\right ) =b_{0}\left ( 0\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}$ Therefore (3) becomes\begin{align*} v\left ( x,t\right ) & =\sum _{n=1}^{\infty }b_{n}\left ( t\right ) X_{n}\left ( x\right ) \\ & =\sum _{n=1}^{\infty }b_{0}\left ( 0\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\sin \left ( \frac{n\pi }{L}x\right ) \end{align*}

And from (1)\begin{align} u\left ( x,t\right ) & =v\left ( x,t\right ) +u_{E}\left ( x\right ) \nonumber \\ & =\overset{u_{E}}{\overbrace{\left ( \frac{B}{L}-\frac{A}{L}+\frac{1}{2}L\right ) x+A-\frac{1}{2}x^{2}}}+\sum _{n=1}^{\infty }b_{0}\left ( 0\right ) e^{-k\left ( \frac{n\pi }{L}\right ) ^{2}t}\sin \left ( \frac{n\pi }{L}x\right ) \tag{5} \end{align}

At $$t=0$$ the above becomes$f\left ( x\right ) =\frac{Bx}{L}-\frac{Ax}{L}+\frac{1}{2}Lx+A-\frac{1}{2}x^{2}+\sum _{n=1}^{\infty }b_{0}\left ( 0\right ) \sin \left ( \frac{n\pi }{L}x\right )$ For $$n>0$$, and applying orthogonality$\int _{0}^{L}f\left ( x\right ) \sin \left ( \frac{n\pi }{L}x\right ) dx=\int _{0}^{L}\left ( \frac{Bx}{L}-\frac{Ax}{L}+\frac{1}{2}Lx+A-\frac{1}{2}x^{2}\right ) \sin \left ( \frac{n\pi }{L}x\right ) dx+\int _{0}^{L}b_{0}\left ( 0\right ) \sin ^{2}\left ( \frac{n\pi }{L}x\right ) dx$ Hence$\int _{0}^{L}\left ( f\left ( x\right ) -\left ( \frac{Bx}{L}-\frac{Ax}{L}+\frac{1}{2}Lx+A-\frac{1}{2}x^{2}\right ) \right ) \sin \left ( \frac{n\pi }{L}x\right ) dx=\frac{L}{2}b_{0}\left ( 0\right )$ Therefore$b_{0}\left ( 0\right ) =\frac{2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( \frac{Bx}{L}-\frac{Ax}{L}+\frac{1}{2}Lx+A-\frac{1}{2}x^{2}\right ) \right ) \sin \left ( \frac{n\pi }{L}x\right ) dx$ Substituting the above in (5) gives$u\left ( x,t\right ) =\frac{Bx}{L}-\frac{Ax}{L}+\frac{1}{2}Lx+A-\frac{1}{2}x^{2}+\sum _{n=1}^{\infty }\left ( \frac{2}{L}\int _{0}^{L}\left ( f\left ( x\right ) -\left ( \frac{Bx}{L}-\frac{Ax}{L}+\frac{1}{2}Lx+A-\frac{1}{2}x^{2}\right ) \right ) \sin \left ( \frac{n\pi }{L}x\right ) dx\right ) e^{-k\frac{n\pi }{L}t}\sin \left ( \frac{n\pi }{L}x\right )$

_______________________________________________________________________________________

5.19 Left and right end ﬁxed zero temperature, non zero intial conditions, internal source term present

problem number 38

Solve the heat equation

$\frac{ \partial u}{\partial t} + u(x,t) = k \frac{ \partial ^2 u}{\partial x^2}$

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= 0 \\ u(L,t) &= 0 \end{align*}

Initial condition is $$u(x,0)=f(x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)+u(x,t)=u^{(2,0)}(x,t),u(x,0)=f(x),\{u(0,t)=0,u(L,t)=0\}\right \},u(x,t),x,t\right ]$

Maple

$u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac{1}{L}\sin \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{t \left ({\pi }^{2}{n}^{2}+{L}^{2} \right ) }{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \sin \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x} \right )$

_______________________________________________________________________________________

5.20 Left and right end ﬁxed zero temperature, non zero intial conditions, internal source term present

problem number 39

Solve the heat equation

$\frac{ \partial u}{\partial t} + u(x,t) = 100 \frac{ \partial ^2 u}{\partial x^2}$

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= 0 \\ u(1,t) &= 0 \end{align*}

Initial condition is $$u(x,0)=\sin (2 \pi x)-\sin (5 \pi x)$$

Mathematica

$u(x,t)\to e^{-400 \pi ^2 t} \sin (2 \pi x)-e^{-2500 \pi ^2 t} \sin (5 \pi x)$

Maple

$u \left ( x,t \right ) =\sin \left ( 2\,\pi \,x \right ){{\rm e}^{-400\,{\pi }^{2}t}}-\sin \left ( 5\,\pi \,x \right ){{\rm e}^{-2500\,{\pi }^{2}t}}$

_______________________________________________________________________________________

5.21 Left and right end ﬁxed zero temperature, intial conditions is hat function, No source

problem number 40

Solve the heat equation

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

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= 0 \\ u(40,t) &= 0 \end{align*}

Initial condition is

$$u\left (x,0\right ) =\left \{ \begin{array} [c]{ccc}x & 0 \leq x < 20\\ 40-x & 20 \geq x \leq 40 \end{array} \right .$$

Mathematica

$\left \{\left \{u(x,t)\to \underset{n=1}{\overset{\infty }{\sum }}\frac{640 e^{-\frac{n^2 \pi ^2 t}{1600}} \cos \left (\frac{n \pi }{4}\right ) \sin ^3\left (\frac{n \pi }{4}\right ) \sin \left (\frac{n \pi x}{40}\right )}{n^2 \pi ^2}\right \}\right \}$

Maple

$u \left ( x,t \right ) =\sum _{n=1}^{\infty }160\,{\frac{\sin \left ( 1/40\,n\pi \,x \right ) \sin \left ( 1/2\,\pi \,n \right ) }{{\pi }^{2}{n}^{2}}{{\rm e}^{-{\frac{{\pi }^{2}{n}^{2}t}{1600}}}}}$

_______________________________________________________________________________________

5.22 Left and right end ﬁxed zero temperature, intial conditions non zero at single location, No source

problem number 41

Added July 2, 2018, taken from Maple 2018.1 improvement to PDE document.

Solve the heat equation

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

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= 0 \\ u(1,t) &= 0 \end{align*}

Initial condition is

$$u\left (x,0\right ) =\left \{ \begin{array} [c]{ccc}1 & x=1\\ 0 & \text{otherwise} \end{array} \right .$$

Mathematica

$\left \{\left \{u(x,t)\to \underset{n=1}{\overset{\infty }{\sum }}-\frac{2 \left (-1+(-1)^n\right ) e^{-n^2 \pi ^2 t} \sin (n \pi x)}{n \pi }\right \}\right \}$

Maple

$u \left ( x,t \right ) =x+\sum _{n=1}^{\infty }2\,{\frac{\sin \left ( n\pi \,x \right ){{\rm e}^{-{\pi }^{2}{n}^{2}t}}}{\pi \,n}}$

_______________________________________________________________________________________

5.23 Left temperature depends on time, right end ﬁxed at zero. zero initial conditions, No source

problem number 42

added March 8, 2018. Exam problem

Solve the heat equation

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

For $$0<x<\pi$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= t \\ u(\pi ,t) &= 0 \end{align*}

Initial condition is $$u(x,0)=0$$.

Mathematica

$\left \{\left \{u(x,t)\to \underset{n=1}{\overset{\infty }{\sum }}-\frac{\left (2-2 e^{-n^2 t}\right ) \sin (n x)}{n^3 \pi }-\frac{t x}{\pi }+t\right \}\right \}$

Maple

$u \left ( x,t \right ) =1/6\,{\frac{1}{\pi } \left ( 6\,\sum _{n=1}^{\infty }2\,{\frac{\sin \left ( nx \right ){{\rm e}^{-{n}^{2}t}}}{\pi \,{n}^{3}}}\pi -6\, \left ( 1/6\,{x}^{2}-1/3\,\pi \,x+t \right ) \left ( -\pi +x \right ) \right ) }$

_______________________________________________________________________________________

5.24 Left and right end ﬁxed at zero temperature. non zero initial conditions, external source depends on space only (Haberman 8.2.1 (f))

problem number 43

This is problem 8.2.1, part(f) from Richard Haberman applied partial diﬀerential equations 5th edition.

Solve the heat equation

$\frac{ \partial u}{\partial t}= k \frac{ \partial ^2 u}{\partial x^2} + \sin \left ( \frac{2 \pi x}{L} \right )$

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &= 0 \\ \frac{\partial u}{\partial x}(L,t) &= 0 \\ \end{align*}

Initial condition is $$u(x,0)=f(x)$$.

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t)+\sin \left (\frac{2 \pi x}{L}\right ),u(x,0)=f(x),\left \{u^{(1,0)}(0,t)=0,u^{(1,0)}(L,t)=0\right \}\right \},u(x,t),x,t,\text{Assumptions}\to \{L>0,k>0,t>0\}\right ]$

Maple

$u \left ( x,t \right ) =1/4\,{\frac{1}{{\pi }^{2}kL} \left ( 4\,\sum _{n=1}^{\infty } \left ( -1/2\,{\frac{1}{{\pi }^{2}kL}\int _{0}^{L}\!{L}^{2}\sin \left ( 2\,{\frac{\pi \,x}{L}} \right ) \cos \left ({\frac{n\pi \,x}{L}} \right ) -2\,\pi \, \left ( -2\,\pi \,k{\it \_C2}+2\,k\pi \,f \left ( x \right ) +Lx \right ) \cos \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x\cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}} \right ){\pi }^{2}kL+4\,{\it \_C2}\,{\pi }^{2}kL+{L}^{3}\sin \left ( 2\,{\frac{\pi \,x}{L}} \right ) -2\,{L}^{2}x\pi -\int _{0}^{L}\!-4\,f \left ( x \right ){\pi }^{2}k+4\,{\it \_C2}\,{\pi }^{2}k+{L}^{2}\sin \left ( 2\,{\frac{\pi \,x}{L}} \right ) -2\,Lx\pi \,{\rm d}x \right ) }$

_______________________________________________________________________________________

5.25 Left and right end ﬁxed at zero temperature. non zero initial conditions, external source depends on time only (Pinchover and Rubinstein 6.25)

problem number 44

Added July 2, 2018. Taken from Maple 2018.1 document, originally exercise 6.25 from Pinchover and Rubinstein.

Solve the heat equation

$\frac{ \partial u}{\partial t}= k \frac{ \partial ^2 u}{\partial x^2} + \cos (w t)$

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &= 0 \\ \frac{\partial u}{\partial x}(L,t) &= 0 \\ \end{align*}

Initial condition is $$u(x,0)=x$$.

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t)+\cos (t w),u(x,0)=x,\left \{u^{(1,0)}(0,t)=0,u^{(1,0)}(L,t)=0\right \}\right \},u(x,t),x,t,\text{Assumptions}\to \{L>0,t>0,k>0\}\right ]$

Maple

$u \left ( x,t \right ) =1/2\,{\frac{1}{w} \left ( Lw+2\,\sum _{n=1}^{\infty }2\,{\frac{L \left ( \left ( -1 \right ) ^{n}-1 \right ) }{{n}^{2}{\pi }^{2}}\cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}}w+2\,\sin \left ( wt \right ) \right ) }$

_______________________________________________________________________________________

5.26 Left and right end ﬁxed at zero temperature. non zero initial conditions, external source depends on time and space

problem number 45

Solve the heat equation

$\frac{ \partial u}{\partial t}= k \frac{ \partial ^2 u}{\partial x^2} + \left ( e^{-c t} \sin \left ( \frac{2 \pi x}{L} \right ) \right )$

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &= 0 \\ \frac{\partial u}{\partial x}(L,t) &= 0 \\ \end{align*}

Initial condition is $$u(x,0)=f(x)$$.

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t)+e^{-c t} \sin \left (\frac{2 \pi x}{L}\right ),u(x,0)=f(x),\left \{u^{(1,0)}(0,t)=0,u^{(1,0)}(L,t)=0\right \}\right \},u(x,t),x,t,\text{Assumptions}\to \{L>0,k>0,t>0\}\right ]$

Maple

$u \left ( x,t \right ) =1/3\,{\frac{1}{L\pi \, \left ({L}^{2}c-{\pi }^{2}k \right ) } \left ( L\sum _{n=3}^{\infty }12\,{\frac{{L}^{2} \left ({L}^{2}c-{\pi }^{2}k \right ) \left ( \left ( -1 \right ) ^{n}-1 \right ) }{ \left ( -{\pi }^{2}k{n}^{2}+{L}^{2}c \right ) \left ({n}^{2}-4 \right ) }\cos \left ({\frac{n\pi \,x}{L}} \right ) \left ({{\rm e}^{-{\frac{{\pi }^{2}k{n}^{2}t}{{L}^{2}}}}}-{{\rm e}^{-tc}} \right ) }+ \left ( 3\,{L}^{3}\pi \,c-3\,L{\pi }^{3}k \right ) \sum _{n=1}^{\infty } \left ( 2\,{\frac{1}{L}\cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{-{\frac{{\pi }^{2}k{n}^{2}t}{{L}^{2}}}}}\int _{0}^{L}\!f \left ( x \right ) \cos \left ({\frac{n\pi \,x}{L}} \right ) \,{\rm d}x} \right ) +8\,{L}^{3}{{\rm e}^{-{\frac{{\pi }^{2}kt}{{L}^{2}}}}}\cos \left ({\frac{\pi \,x}{L}} \right ) -8\,{L}^{3}\cos \left ({\frac{\pi \,x}{L}} \right ){{\rm e}^{-tc}}+3\,\int _{0}^{L}\!f \left ( x \right ) \,{\rm d}x\pi \, \left ({L}^{2}c-{\pi }^{2}k \right ) \right ) }$

_______________________________________________________________________________________

5.27 Left and right end insulated. non zero initial conditions, external source depends on time and space (Pinchover and Rubinstein 6.17)

problem number 46

Pinchover and Rubinstein’s exercise 6.17. Taken from Maple document for new improvements in Maple 2018.1

Solve the heat equation

${\frac{\partial }{\partial t}}u \left ( x,t \right ) -{\frac{\partial ^{2}}{\partial{x}^{2}}}u \left ( x,t \right ) =1+x\cos \left ( t\right )$

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &=\sin (t) \\ \frac{\partial u}{\partial x}(1,t) &=\sin (t) \end{align*}

Initial condition is $$u (x,0) =1+ \cos ( 2 \pi x)$$.

Mathematica

$\text{DSolve}\left [\left \{u^{(2,0)}(x,t)+x \cos (t)+1=u^{(1,0)}(x,t),\cos (2 \pi x)+1=u(x,0),\left \{\sin (t)=u^{(1,0)}(0,t),\sin (t)=u^{(1,0)}(1,t)\right \}\right \},u(x,t),x,t\right ]$

Maple

$u \left ( x,t \right ) =1+\cos \left ( 2\,\pi \,x \right ){{\rm e}^{-4\,{\pi }^{2}t}}+t+x\sin \left ( t \right )$

_______________________________________________________________________________________

5.28 Left end insulated, right end non-homogeneous Neumann boundary condition, no source

problem number 47

Second example from Maple document for new improvements in Maple 2018.1

Solve the heat equation

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

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &=0 \\ \frac{\partial u}{\partial x}(1,t) &=1 \end{align*}

Initial condition is $$u(x,0) =\frac{1}{2} x^2 + x$$.

Mathematica

$\text{DSolve}\left [\left \{u^{(1,0)}(x,t)=13 u^{(2,0)}(x,t),u(x,0)=\frac{x^2}{2}+x,\left \{u^{(1,0)}(0,t)=0,u^{(1,0)}(1,t)=1\right \}\right \},u(x,t),x,t\right ]$

Maple

$u \left ( x,t \right ) =1/2+\sum _{n=1}^{\infty }2\,{\frac{\cos \left ( n\pi \,x \right ){{\rm e}^{-13\,{\pi }^{2}{n}^{2}t}} \left ( \left ( -1 \right ) ^{n}-1 \right ) }{{\pi }^{2}{n}^{2}}}+13\,t+1/2\,{x}^{2}$

_______________________________________________________________________________________

5.29 Left and right end ﬁxed at zero, source depends on time and space (Pinchover and Rubinstein 6.23)

problem number 48

4th example from Maple document for new improvements in Maple 2018.1, originally taken from Pinchover and Rubinstein’s exercise 6.23 .

Solve the heat equation on bar

$\frac{\partial u }{\partial t} = \frac{\partial ^{2} u}{\partial{x}^{2}} + g(x,t)$

Where $$g(x,t) = e^{3 t} \cos (17 \pi x)$$ for $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &=0 \\ \frac{\partial u}{\partial x}(1,t) &=0 \end{align*}

Initial condition is $$u(x,0) =f(x)$$ where $$f(x) = 3 \cos (42 \pi x)$$.

Mathematica

$\left \{\left \{u(x,t)\to \frac{e^{3 t} \cos (17 \pi x)}{3+289 \pi ^2}-\frac{e^{-289 \pi ^2 t} \cos (17 \pi x)}{3+289 \pi ^2}+3 e^{-1764 \pi ^2 t} \cos (42 \pi x)\right \}\right \}$

Maple

$u \left ( x,t \right ) ={\frac{ \left ( 867\,{\pi }^{2}+9 \right ) \cos \left ( 42\,\pi \,x \right ){{\rm e}^{-1764\,{\pi }^{2}t}}+\cos \left ( 17\,\pi \,x \right ) \left ({{\rm e}^{3\,t}}-{{\rm e}^{-289\,{\pi }^{2}t}} \right ) }{289\,{\pi }^{2}+3}}$

_______________________________________________________________________________________

5.30 Left and right end insulated, source depends on time and space (Pinchover and Rubinstein 6.21)

problem number 49

Taken from Maple document for new improvements in Maple 2018.1, originally taken from Pinchover and Rubinstein’s exercise 6.21

Solve the heat equation on bar

$\frac{\partial u }{\partial t} = \frac{\partial ^{2} u}{\partial{x}^{2}} + g(x,t)$

Where $$g(x,t) = t \cos (2001 x)$$ for $$0<x<\pi$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &=0 \\ \frac{\partial u}{\partial x}(1,t) &=0 \end{align*}

Initial condition is $$u(x,0) =f(x)$$ where $$f(x) = \pi \cos (2 x)$$.

Mathematica

$\left \{\left \{u(x,t)\to \pi e^{-4 t} \cos (2 x)+\frac{e^{-4004001 t} \cos (2001 x)}{16032024008001}+\frac{t \cos (2001 x)}{4004001}-\frac{\cos (2001 x)}{16032024008001}\right \}\right \}$

Maple

$u \left ( x,t \right ) ={\frac{ \left ( 4004001\,t+{{\rm e}^{-4004001\,t}}-1 \right ) \cos \left ( 2001\,x \right ) }{16032024008001}}+\cos \left ( 2\,x \right ){{\rm e}^{-4\,t}}\pi$

_______________________________________________________________________________________

5.31 Left and right end nonhomogeneous Dirichlet BC that depends on time, source that depends on space

problem number 50

Added March 28, 2018. A problem from my PDE animation page.

Solve the heat equation

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

For $$0<x<\pi$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= \frac{t \sin t}{5} \\ u(\pi ,t) &= \frac{t \cos t}{10} \\ \end{align*}

Initial condition is $$u(x,0)=60 - 20 x$$.

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=u^{(2,0)}(x,t)+x,u(x,0)=60-2 x,\left \{u(0,t)=\frac{1}{5} t \sin (t),u(\pi ,t)=\frac{1}{10} t \cos (t)\right \}\right \},u(x,t),x,t,\text{Assumptions}\to \{t>0,x>0\}\right ]$

Maple

$u \left ( x,t \right ) =1/10\,{\frac{1}{\pi } \left ( \cos \left ( t \right ) tx+2\, \left ( \pi -x \right ) t\sin \left ( t \right ) +10\,\sum _{n=1}^{\infty }1/10\,{\frac{1}{\pi \,{n}^{3} \left ({n}^{4}+1 \right ) ^{2}} \left ( 40\, \left ( \left ( 30\,{n}^{10}+1/20\,{n}^{8}+60\,{n}^{6}+30\,{n}^{2} \right ) \left ( -1 \right ) ^{1+n}+ \left ( \pi \,{n}^{10}+1/2\,\pi \,{n}^{8}+2\,\pi \,{n}^{6}+ \left ( \pi +1/20 \right ){n}^{4}+\pi \,{n}^{2}+\pi /2 \right ) \left ( -1 \right ) ^{n}+30\,{n}^{10}+{\frac{299\,{n}^{6}}{5}}+30\,{n}^{2} \right ) \sin \left ( nx \right ){{\rm e}^{-{n}^{2}t}}-{n}^{2} \left ({n}^{2} \left ( t{n}^{4}-2\,{n}^{2}+t \right ) \left ( -1 \right ) ^{n}+2\,{n}^{6}+2\,t{n}^{4}-2\,{n}^{2}+2\,t \right ) \cos \left ( nx-t \right ) + \left ({n}^{2} \left ({n}^{6}+t{n}^{4}-{n}^{2}+t \right ) \left ( -1 \right ) ^{n}-2\,{n}^{4} \left ( t{n}^{4}-2\,{n}^{2}+t \right ) \right ) \sin \left ( nx-t \right ) +{n}^{2} \left ( 2\, \left ( -1 \right ) ^{1+n}{n}^{4}+{n}^{2}t \left ({n}^{4}+1 \right ) \left ( -1 \right ) ^{n}+2\,{n}^{6}+2\,t{n}^{4}-2\,{n}^{2}+2\,t \right ) \cos \left ( nx+t \right ) + \left ({n}^{2} \left ({n}^{6}+t{n}^{4}-{n}^{2}+t \right ) \left ( -1 \right ) ^{n}-2\,{n}^{4} \left ( t{n}^{4}-2\,{n}^{2}+t \right ) \right ) \sin \left ( nx+t \right ) +20\,\sin \left ( nx \right ) \left ( -1 \right ) ^{1+n}\pi \, \left ({n}^{4}+1 \right ) ^{2} \right ) }\pi \right ) }$

_______________________________________________________________________________________

5.32 Left and right end ﬁxed at zero, non zero initial conditions, source that depends on time and space

problem number 51

Taken from Maple PDE help pages

Solve the heat equation for $$u(x,t)$$

$\frac{ \partial u}{\partial t}= k \frac{ \partial ^2 u}{\partial x^2} + f(x,t)$

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= 0 \\ u(1,t) &= 0 \\ \end{align*}

Initial condition is $$u(x,0)=g(x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=f(x,t)+k u^{(2,0)}(x,t),u(x,0)=g(x),\{u(0,t)=0,u(1,t)=0\}\right \},u(x,t),x,t,\text{Assumptions}\to \{k>0,t>0,x>0,x<1\}\right ]$

Maple

$u \left ( x,t \right ) =\sum _{n=1}^{\infty } \left ( 2\,{\frac{1}{l}\sin \left ({\frac{n\pi \,x}{l}} \right ){{\rm e}^{-{\frac{k{\pi }^{2}{n}^{2}t}{{l}^{2}}}}}\int _{0}^{l}\!g \left ( x \right ) \sin \left ({\frac{n\pi \,x}{l}} \right ) \,{\rm d}x} \right ) +\int _{0}^{t}\!\sum _{n=1}^{\infty } \left ( 2\,{\frac{1}{l}\sin \left ({\frac{n\pi \,x}{l}} \right ){{\rm e}^{{\frac{k{\pi }^{2}{n}^{2} \left ( -t+\tau \right ) }{{l}^{2}}}}}\int _{0}^{l}\!f \left ( x,\tau \right ) \sin \left ({\frac{n\pi \,x}{l}} \right ) \,{\rm d}x} \right ) \,{\rm d}\tau$

_______________________________________________________________________________________

5.33 Left end held ﬁxed at constant temperature, right end at zero. Zero initial conditions, source that depends on time and space (Haberman 8.3.6)

problem number 52

Problem 8.3.6 from Richard Haberman applied partial diﬀerential equations book, 5th edition

Solve the heat equation for $$u(x,t)$$

$\frac{ \partial u}{\partial t}= \frac{ \partial ^2 u}{\partial x^2} + \sin (5 x) e^{-2 t}$

For $$0<x<\pi$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t) &= 1 \\ u(\pi ,t) &= 0 \\ \end{align*}

Initial condition is $$u(x,0)=0$$

For hand solution see my HW9, Math 322, UW Madison.

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=u^{(2,0)}(x,t)+e^{-2 t} \sin (5 x),u(x,0)=0,\{u(0,t)=1,u(\pi ,t)=0\}\right \},u(x,t),x,t\right ]$

Maple

$u \left ( x,t \right ) =1/23\,{\frac{1}{\pi } \left ( 23\,\sum _{n=1}^{\infty }-2\,{\frac{\sin \left ( nx \right ){{\rm e}^{-{n}^{2}t}}}{n\pi }}\pi +\pi \, \left ({{\rm e}^{-2\,t}}-{{\rm e}^{-25\,t}} \right ) \sin \left ( 5\,x \right ) -23\,x+23\,\pi \right ) }$

Hand solution

This problem has nonhomogeneous B.C. and non-homogenous in the PDE itself (source present). First step is to use reference function to remove the nonhomogeneous B.C. then use the method of eigenfunction expansion on the resulting problem.

Let $r\left ( x\right ) =c_{1}x+c_{2}$ At $$x=0,r\left ( x\right ) =1$$, hence $$1=c_{2}$$ and at $$x=\pi ,r\left ( x\right ) =0$$, hence $$0=c_{1}\pi +1$$ or $$c_{1}=-\frac{1}{\pi }$$, hence$r\left ( x\right ) =1-\frac{x}{\pi }$ Therefore$u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x\right )$ Where $$v\left ( x,t\right )$$ solution for the given PDE but with homogeneous B.C., therefore \begin{align} \frac{\partial v\left ( x,t\right ) }{\partial t} & =\frac{\partial ^{2}v\left ( x,t\right ) }{\partial x^{2}}+e^{-2t}\sin 5x\tag{1}\\ v\left ( 0,t\right ) & =0\nonumber \\ v\left ( \pi ,t\right ) & =0\nonumber \\ v\left ( x,0\right ) & =u\left ( x,0\right ) -r\left ( x\right ) =0-\left ( 1-\frac{x}{\pi }\right ) =\frac{x}{\pi }-1\nonumber \end{align}

We now solve (1). This is homogeneous in the PDE itself. To solve, we ﬁrst solve the nonhomogeneous PDE in order to ﬁnd the eigenfunctions. Hence we need to solve$\frac{\partial v\left ( x,t\right ) }{\partial t}=\frac{\partial ^{2}v\left ( x,t\right ) }{\partial x^{2}}$ This has solution$$v\left ( x,t\right ) =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \phi _{n}\left ( x\right ) \tag{2}$$ With\begin{align*} \phi _{n}\left ( x\right ) & =\sin \left ( \sqrt{\lambda _{n}}x\right ) \qquad n=1,2,3\cdots \\ \lambda _{n} & =n^{2}\qquad n=1,2,3\cdots \end{align*}

Plug-in (2) back into (1) gives\begin{align*} \sum _{n=1}^{\infty }a_{n}^{\prime }\left ( t\right ) \phi _{n}\left ( x\right ) & =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \phi _{n}\left ( x\right ) +e^{-2t}\sin 5x\\ & =\sum _{n=1}^{\infty }a_{n}\left ( t\right ) \frac{\partial ^{2}}{\partial x^{2}}\phi _{n}\left ( x\right ) +e^{-2t}\sin 5x \end{align*}

But $$\frac{\partial ^{2}}{\partial x^{2}}\phi _{n}\left ( x\right ) =-\lambda _{n}\phi _{n}=-n\phi _{n}$$, hence the above becomes\begin{align*} \sum _{n=1}^{\infty }a_{n}^{\prime }\left ( t\right ) \phi _{n}\left ( x\right ) +n^{2}a_{n}\left ( t\right ) \phi _{n}\left ( x\right ) & =e^{-2t}\sin 5x\\ \sum _{n=1}^{\infty }\left ( a_{n}^{\prime }\left ( t\right ) +n^{2}a_{n}\left ( t\right ) \right ) \sin \left ( nx\right ) & =e^{-2t}\sin 5x \end{align*}

Therefore, since Fourier series expansion is unique, we can compare coeﬃcients and obtain$a_{n}^{\prime }\left ( t\right ) +n^{2}a_{n}\left ( t\right ) =\left \{ \begin{array} [c]{ccc}e^{-2t} & & n=5\\ 0 & & n\neq 5 \end{array} \right .$ For the case $$n=5$$\begin{align*} a_{5}^{\prime }\left ( t\right ) +25a_{5}\left ( t\right ) & =e^{-2t}\\ \frac{d}{dt}\left ( a_{5}\left ( t\right ) e^{25t}\right ) & =e^{23t}\\ a_{5}\left ( t\right ) e^{25t} & =\int e^{23t}dt+c\\ & =\frac{e^{23t}}{23}+c \end{align*}

Hence$a_{5}\left ( t\right ) =\frac{e^{-2t}}{23}+ce^{-25t}$ At $$t=0,$$ $$a_{5}\left ( 0\right ) =\frac{1}{23}+c$$, hence$c=a_{5}\left ( 0\right ) -\frac{1}{23}$ And the solution becomes$a_{5}\left ( t\right ) =\frac{1}{23}e^{-2t}+\left ( a_{5}\left ( 0\right ) -\frac{1}{23}\right ) e^{-25t}$ For the case $$n\neq 5$$\begin{align*} a_{n}^{\prime }\left ( t\right ) +n^{2}a_{n}\left ( t\right ) & =0\\ \frac{d}{dt}\left ( a_{n}\left ( t\right ) e^{n^{2}t}\right ) & =0\\ a_{n}\left ( t\right ) e^{n^{2}t} & =c\\ a_{n}\left ( t\right ) & =ce^{-n^{2}t} \end{align*}

At $$t=0,$$ $$a_{n}\left ( 0\right ) =c$$, hence$a_{n}\left ( t\right ) =a_{n}\left ( 0\right ) e^{-nt}$ Therefore$a_{n}\left ( t\right ) =\left \{ \begin{array} [c]{ccc}\frac{1}{23}e^{-2t}+\left ( a_{5}\left ( 0\right ) -\frac{1}{23}\right ) e^{-25t} & & n=5\\ a_{n}\left ( 0\right ) e^{-n^{2}t} & & n\neq 5 \end{array} \right .$ To ﬁnd $$a_{n}\left ( 0\right )$$ we use orthogonality.  Since $$u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x\right )$$, then$u\left ( x,t\right ) =\left ( \sum _{n=1}^{\infty }a_{n}\left ( t\right ) \sin \left ( nx\right ) \right ) +\left ( 1-\frac{x}{\pi }\right )$ And at $$t=0$$ the above becomes$0=\left ( \sum _{n=1}^{\infty }a_{n}\left ( 0\right ) \sin \left ( nx\right ) \right ) +\left ( 1-\frac{x}{\pi }\right )$ Or$\frac{x}{\pi }-1=\sum _{n=1}^{\infty }a_{n}\left ( 0\right ) \sin \left ( nx\right )$ Applying orthogonality$\int _{0}^{\pi }\left ( \frac{x}{\pi }-1\right ) \sin \left ( n^{\prime }x\right ) dx=a_{n^{\prime }}\left ( 0\right ) \int _{0}^{\pi }\sin ^{2}\left ( n^{\prime }x\right ) dx$ Therefore\begin{align*} a_{n}\left ( 0\right ) & =\frac{\int _{0}^{\pi }\left ( \frac{x}{\pi }-1\right ) \sin \left ( nx\right ) dx}{\frac{\pi }{2}}\\ & =\frac{2}{\pi }\int _{0}^{\pi }\left ( \frac{x}{\pi }-1\right ) \sin \left ( nx\right ) dx\\ & =\frac{2}{\pi }\left [ -\int _{0}^{\pi }\sin \left ( nx\right ) dx+\frac{1}{\pi }\int _{0}^{\pi }x\sin \left ( nx\right ) dx\right ] \\ & =\frac{2}{\pi }\left [ -\left ( \frac{-\cos \left ( nx\right ) }{n}\right ) _{0}^{\pi }+\frac{1}{\pi }\left ( \frac{\sin \left ( nx\right ) }{n^{2}}-\frac{x\cos \left ( nx\right ) }{n}\right ) _{0}^{\pi }\right ] \\ & =\frac{2}{\pi }\left [ \left ( \frac{\cos \left ( n\pi \right ) }{n}-\frac{1}{n}\right ) +\frac{1}{\pi }\left ( \left ( \frac{\sin \left ( n\pi \right ) }{n^{2}}-\frac{\pi \cos \left ( n\pi \right ) }{n}\right ) -\left ( \frac{\sin \left ( 0\right ) }{n^{2}}-\frac{0\cos \left ( 0\right ) }{n}\right ) \right ) \right ] \\ & =\frac{2}{\pi }\left [ \left ( \frac{-1^{n}}{n}-\frac{1}{n}\right ) +\frac{1}{\pi }\left ( 0-\frac{\pi \left ( -1\right ) ^{n}}{n}\right ) \right ] \\ & =\frac{2}{\pi }\left [ \frac{\left ( -1\right ) ^{n}}{n}-\frac{1}{n}-\frac{\left ( -1\right ) ^{n}}{n}\right ] \\ & =\frac{-2}{n\pi } \end{align*}

Therefore $$a_{5}\left ( 0\right ) =\frac{-2}{5\pi }$$. Hence$a_{n}\left ( t\right ) =\left \{ \begin{array} [c]{ccc}\frac{1}{23}e^{-2t}+\left ( \frac{-2}{5\pi }-\frac{1}{23}\right ) e^{-25t} & & n=5\\ \frac{-2}{n\pi }e^{-n^{2}t} & & n\neq 5 \end{array} \right .$ Where \begin{align*} u\left ( x,t\right ) & =v\left ( x,t\right ) +r\left ( x\right ) \\ & =\left ( \sum _{n=1}^{\infty }a_{n}\left ( t\right ) \sin \left ( nx\right ) \right ) +\left ( 1-\frac{x}{\pi }\right ) \\ & =\left ( 1-\frac{x}{\pi }\right ) +\left ( \sum _{\substack{n=1\\n\neq 5}}^{\infty }\frac{-2}{n\pi }e^{-n^{2}t}\sin \left ( nx\right ) \right ) +\left ( \frac{1}{23}e^{-2t}+\left ( \frac{-2}{5\pi }-\frac{1}{23}\right ) e^{-25t}\right ) \sin \left ( 5x\right ) \end{align*}

5.34

_______________________________________________________________________________________

5.35 Both left and right end nonhomogeneous Neumann condition which is function of time, source that depends on time and space (Haberman 8.2.2. (a))

problem number 53

Problem 8.2.2 part(a) from Richard Haberman applied partial diﬀerential equations book, 5th edition

Solve the heat equation for $$u(x,t)$$

$\frac{ \partial u}{\partial t}= \frac{ \partial ^2 u}{\partial x^2} +Q(x,t)$

For $$0<x<L$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{ \partial u}{\partial x}(0,t) &= A(t) \\ \frac{ \partial u}{\partial x}(L,t) &= B(t)\\ \end{align*}

Initial condition is $$u(x,0)=f(x)$$

For hand solution see my HW9, Math 322, UW Madison. The text does not actually asks to solve this PDE but only to reduce the problem to one with homogeneous B.C.

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=k u^{(2,0)}(x,t)+Q(x,t),u(x,0)=f(x),\left \{u^{(1,0)}(0,t)=A(t),u^{(1,0)}(L,t)=B(t)\right \}\right \},u(x,t),x,t,\text{Assumptions}\to L>0\right ]$

Maple

$u \left ( x,t \right ) =1/2\,{\frac{1}{{L}^{2}} \left ( 2\,xA \left ( t \right ){L}^{2}+{x}^{2}B \left ( t \right ) L-{x}^{2}A \left ( t \right ) L+2\,\int _{0}^{t}\!1/2\,{\frac{1}{{L}^{2}} \left ( 2\,\sum _{n=1}^{\infty } \left ( -{\frac{1}{{L}^{2}}\int _{0}^{L}\!-2\,\cos \left ({\frac{n\pi \,x}{L}} \right ) \left ( 1/2\,x \left ( x-2\,L \right ){\frac{\rm d}{{\rm d}\tau }}A \left ( \tau \right ) -1/2\,{x}^{2}{\frac{\rm d}{{\rm d}\tau }}B \left ( \tau \right ) -Q \left ( x,\tau \right ) L+k \left ( A \left ( \tau \right ) -B \left ( \tau \right ) \right ) \right ) \,{\rm d}x\cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{{\frac{k{\pi }^{2}{n}^{2} \left ( t-\tau \right ) }{{L}^{2}}}}}} \right ){L}^{2}-\int _{0}^{L}\!-x \left ( x-2\,L \right ){\frac{\rm d}{{\rm d}\tau }}A \left ( \tau \right ) +{x}^{2}{\frac{\rm d}{{\rm d}\tau }}B \left ( \tau \right ) +2\,Q \left ( x,\tau \right ) L-2\,k \left ( A \left ( \tau \right ) -B \left ( \tau \right ) \right ) \,{\rm d}x \right ) }\,{\rm d}\tau{L}^{2}+2\,\sum _{n=1}^{\infty } \left ({\frac{1}{{L}^{2}}\int _{0}^{L}\! \left ( -2\,\tau \,A \left ( 0 \right ) L+{\tau }^{2}A \left ( 0 \right ) -{\tau }^{2}B \left ( 0 \right ) +2\,f \left ( \tau \right ) L \right ) \cos \left ({\frac{n\pi \,\tau }{L}} \right ) \,{\rm d}\tau \cos \left ({\frac{n\pi \,x}{L}} \right ){{\rm e}^{{\frac{k{\pi }^{2}{n}^{2}t}{{L}^{2}}}}}} \right ){L}^{2}+\int _{0}^{L}\! \left ( -2\,L\tau +{\tau }^{2} \right ) A \left ( 0 \right ) -{\tau }^{2}B \left ( 0 \right ) +2\,f \left ( \tau \right ) L\,{\rm d}\tau \right ) }$

Hand solution

Let $$u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x,t\right ) \tag{1}$$ Since the problem has time dependent source function $$Q\left ( x,t\right )$$ then $$r\left ( x,t\right )$$ is now a reference function that only needs to satisfy the non-homogenous boundary conditions which in this problem are at both ends and $$v\left ( x,t\right )$$ has homogenous boundary conditions. The ﬁrst step is to ﬁnd $$r\left ( x,t\right )$$. Let$r\left ( x,t\right ) =c_{1}\left ( t\right ) x+c_{2}\left ( t\right ) x^{2}$ Then$\frac{\partial r\left ( x,t\right ) }{\partial x}=c_{1}\left ( t\right ) +2c_{2}\left ( t\right ) x$ At $$x=0$$$A\left ( t\right ) =c_{1}\left ( t\right )$ And at $$x=L$$\begin{align*} B\left ( t\right ) & =c_{1}\left ( t\right ) +2c_{2}\left ( t\right ) L\\ c_{2}\left ( t\right ) & =\frac{B\left ( t\right ) -c_{1}\left ( t\right ) }{2L} \end{align*}

Solving for $$c_{1},c_{2}$$ gives$$r\left ( x,t\right ) =A\left ( t\right ) x+\left ( \frac{B\left ( t\right ) -A\left ( t\right ) }{2L}\right ) x^{2}\tag{2}$$ Replacing (1) into the original PDE $$u_{t}=ku_{xx}+Q\left ( x,t\right )$$ gives\begin{align*} \frac{\partial }{\partial t}\left ( v\left ( x,t\right ) -r\left ( x,t\right ) \right ) & =k\frac{\partial ^{2}}{\partial x}\left ( v\left ( x,t\right ) -r\left ( x,t\right ) \right ) +Q\left ( x,t\right ) \\ \frac{\partial v}{\partial t}-\frac{\partial r}{\partial t} & =k\frac{\partial ^{2}v}{\partial x^{2}}-k\frac{\partial ^{2}r}{\partial x^{2}}+Q\left ( x,t\right ) \end{align*}

But $$r_{xx}=\frac{B\left ( t\right ) -A\left ( t\right ) }{L}$$, hence the above reduces to$$v_{t}=kv_{xx}+Q\left ( x,t\right ) -k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}+r_{t}\tag{3}$$ Let $\tilde{Q}\left ( x,t\right ) =Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}$ Then (3) becomes$$v_{t}=kv_{xx}+\tilde{Q}\left ( x,t\right ) \tag{4}$$ The above PDE now has homogenous boundary conditions \begin{align*} v_{t}\left ( 0,t\right ) & =0\\ v_{t}\left ( L,t\right ) & =0 \end{align*}

And initial condition is \begin{align*} v\left ( x,0\right ) & =u\left ( x,0\right ) -r\left ( x,0\right ) \\ & =f\left ( x\right ) -\left ( A\left ( 0\right ) x+\left ( \frac{B\left ( 0\right ) -A\left ( 0\right ) }{2L}\right ) x^{2}\right ) \end{align*}

PDE (4) with its homogenous boundary conditions is standard one, its corresponding eigenvalue boundary value ODE $$X^{\prime \prime }+\lambda X=0$$ has $$\lambda =0$$ as eigenvalue with corresponding eigenfunction $$\Phi _{0}\left ( x\right ) =1$$ and $$\lambda _{n}=\left ( \frac{n\pi }{L}\right ) ^{2}$$ for $$n=1,2,3,\cdots$$ with corresponding eigenfunctions $$\Phi _{n}\left ( x\right ) =\cos \left ( \sqrt{\lambda _{n}}x\right )$$. Using these, we can write the solution to (4) using eigenfunction expansion as$$v\left ( x,t\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \tag{4A}$$ Hence $$v_{t}\left ( x,t\right ) =\sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right )$$ and $$v_{xx}\left ( x,t\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right )$$. Substituing these into (4) gives$\sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) +\tilde{Q}\left ( x,t\right )$ Expanding $$\tilde{Q}\left ( x,t\right )$$ using same eigenfunctions since they are complete, the above becomes$\sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) +\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right )$ But $$\Phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\Phi _{n}\left ( x\right )$$ and the above becomes\begin{align} \sum _{n=0}^{\infty }c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) & =-\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) +\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \nonumber \\ c_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) +c_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) & =b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \nonumber \\ c_{n}^{\prime }\left ( t\right ) +c_{n}\left ( t\right ) \lambda _{n} & =b_{n}\left ( t\right ) \nonumber \\ c_{n}^{\prime }\left ( t\right ) +c_{n}\left ( t\right ) \frac{n^{2}\pi ^{2}}{L^{2}} & =b_{n}\left ( t\right ) \tag{5} \end{align}

To ﬁnd $$b_{n}\left ( t\right )$$, since $$\tilde{Q}\left ( x,t\right ) =Q\left ( x,t\right ) +\frac{\partial r}{\partial t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}$$ then$Q\left ( x,t\right ) +\frac{\partial r}{\partial t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}=\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right )$ Multiplying both sides by $$\Phi _{m}\left ( x\right )$$ and integrating gives\begin{align*} \int _{0}^{L}\left ( Q\left ( x,t\right ) +\frac{\partial r}{\partial t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \Phi _{m}\left ( x\right ) dx & =\int _{0}^{L}\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \Phi _{m}\left ( x\right ) dx\\ & =\sum _{n=0}^{\infty }b_{n}\left ( t\right ) \left ( \int _{0}^{L}\Phi _{n}\left ( x\right ) \Phi _{m}\left ( x\right ) dx\right ) \end{align*}

By orthogonality$\int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \Phi _{m}\left ( x\right ) dx=b_{m}\left ( t\right ) \int _{0}^{L}\Phi _{m}^{2}\left ( x\right ) dx$ When $$m=0,\Phi _{0}\left ( x\right ) =1$$ and the above gives\begin{align*} \int _{0}^{L}Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}dx & =b_{0}\left ( t\right ) \int _{0}^{L}dx\\ b_{0}\left ( t\right ) & =\frac{1}{L}\int _{0}^{L}Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}dx \end{align*}

When $$m=1,2,3,\cdots$$\begin{align*} \int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx & =b_{m}\left ( t\right ) \int _{0}^{L}\cos ^{2}\left ( \frac{m\pi }{L}x\right ) dx\\ \int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx & =b_{m}\left ( t\right ) \frac{L}{2}\\ b_{m}\left ( t\right ) & =\frac{2}{L}\int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac{m\pi }{L}x\right ) dx \end{align*}

Therefore (5) is now solved. When $$n=0$$ (5) becomes\begin{align*} c_{0}^{\prime }\left ( t\right ) +c_{0}\left ( t\right ) \frac{n^{2}\pi ^{2}}{L^{2}} & =b_{0}\left ( t\right ) \\ c_{0}^{\prime }\left ( t\right ) & =b_{0}\left ( t\right ) \\ c_{0}^{\prime }\left ( t\right ) & =\frac{1}{L}\int _{0}^{L}Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}dx \end{align*}

Hence$c_{0}\left ( t\right ) =\int _{0}^{t}\left ( \frac{1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}$ For $$n=1,2,3,\cdots$$ (5) becomes\begin{align*} c_{n}^{\prime }\left ( t\right ) +c_{n}\left ( t\right ) \frac{n^{2}\pi ^{2}}{L^{2}} & =b_{n}\left ( t\right ) \\ & =\frac{2}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx \end{align*}

Intergating factor is $$I=e^{\int \frac{n^{2}\pi ^{2}}{L^{2}}dt}=e^{\frac{n^{2}\pi ^{2}}{L^{2}}t}$$ and the solution to the above becomes\begin{align*} \frac{d}{dt}\left ( c_{n}\left ( t\right ) e^{\frac{n^{2}\pi ^{2}}{L^{2}}t}\right ) & =\frac{2e^{\frac{n^{2}\pi ^{2}}{L^{2}}t}}{L}\int _{0}^{L}\left ( Q\left ( x,t\right ) +r_{t}-k\frac{B\left ( t\right ) -A\left ( t\right ) }{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\\ c_{n}\left ( t\right ) e^{\frac{n^{2}\pi ^{2}}{L^{2}}t} & =\int _{0}^{t}\left ( \frac{2e^{\frac{n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) dt+C_{n}\\ c_{n}\left ( t\right ) & =e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac{2e^{\frac{n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t} \end{align*}

Now that we found $$c_{n}\left ( t\right )$$ for $$n=0,1,2,3,\cdots$$ the solution for $$v\left ( x,t\right )$$ is found from 4A.\begin{align*} v\left ( x,t\right ) & =\sum _{n=0}^{\infty }c_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & =\int _{0}^{t}\left ( \frac{1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}+\sum _{n=1}^{\infty }c_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & \\ & =\int _{0}^{t}\left ( \frac{1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}\\ & +\sum _{n=1}^{\infty }\left ( e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac{2e^{\frac{n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t}\right ) \cos \left ( \frac{n\pi }{L}x\right ) \end{align*}

But $u\left ( x,t\right ) =v\left ( x,t\right ) +r\left ( x,t\right )$ Hence\begin{align*} u\left ( x,t\right ) & =A\left ( t\right ) x+\left ( \frac{B\left ( t\right ) -A\left ( t\right ) }{2L}\right ) x^{2}+\int _{0}^{t}\left ( \frac{1}{L}\int _{0}^{L}Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}dx\right ) dt+C_{0}\\ & +\sum _{n=1}^{\infty }\left ( e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac{2e^{\frac{n^{2}\pi ^{2}}{L^{2}}\tau }}{L}\int _{0}^{L}\left ( Q\left ( x,\tau \right ) +r_{\tau }-k\frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{L}\right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t}\right ) \cos \left ( \frac{n\pi }{L}x\right ) \end{align*}

But \begin{align*} r_{\tau } & =\frac{d}{dt}\left ( A\left ( \tau \right ) x+\left ( \frac{B\left ( \tau \right ) -A\left ( \tau \right ) }{2L}\right ) x^{2}\right ) \\ & =\frac{2LA^{\prime }\left ( \tau \right ) x+\left ( B^{\prime }\left ( \tau \right ) -A^{\prime }\left ( \tau \right ) \right ) x^{2}}{2L} \end{align*}

Hence\begin{align*} u\left ( x,t\right ) & =A\left ( t\right ) x+\left ( \frac{B\left ( t\right ) -A\left ( t\right ) }{2L}\right ) x^{2}+\frac{1}{2L^{2}}\int _{0}^{t}\left ( \int _{0}^{L}2LQ\left ( x,\tau \right ) +2LA^{\prime }\left ( \tau \right ) x+\left ( B^{\prime }\left ( \tau \right ) -A^{\prime }\left ( \tau \right ) \right ) x^{2}-2k\left ( B\left ( \tau \right ) -A\left ( \tau \right ) \right ) dx\right ) dt+C_{0}\\ & +\sum _{n=1}^{\infty }\left ( e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t}\int _{0}^{t}\left ( \frac{e^{\frac{n^{2}\pi ^{2}}{L^{2}}\tau }}{L^{2}}\int _{0}^{L}\left ( 2LQ\left ( x,\tau \right ) +2LA^{\prime }\left ( \tau \right ) x+\left ( B^{\prime }\left ( \tau \right ) -A^{\prime }\left ( \tau \right ) \right ) x^{2}-2k\left ( B\left ( \tau \right ) -A\left ( \tau \right ) \right ) \right ) \cos \left ( \frac{n\pi }{L}x\right ) dx\right ) dt+C_{n}e^{-\frac{n^{2}\pi ^{2}}{L^{2}}t}\right ) \cos \left ( \frac{n\pi }{L}x\right ) \end{align*}

The constants $$C_{0},C_{n}$$ can be found from initial conditions $$u\left ( x,0\right ) =f\left ( x\right )$$.

_______________________________________________________________________________________

5.36 left and right end nonhomogeneous held at ﬁxed temperature, No source (Articolo 8.4.1)

problem number 54

Example 8.4.1 from Partial diﬀerential equations and boundary value problems with Maple by George A. Articolo, 2nd ed.

Solve the heat equation for $$u(x,t)$$

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

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t)=10 \\ u(1,t) = 20\\ \end{align*}

Initial condition is $$u(x,0)=60 x - 50 x^2+10$$ and $$k=\frac{1}{20}$$

Mathematica

$\left \{\left \{u(x,t)\to \underset{n=1}{\overset{\infty }{\sum }}-\frac{200 \left (-1+(-1)^n\right ) e^{-\frac{1}{20} n^2 \pi ^2 t} \sin (n \pi x)}{n^3 \pi ^3}+10 x+10\right \}\right \}$

Maple

$u \left ( x,t \right ) =10+10\,x+\sum _{n=1}^{\infty }-200\,{\frac{ \left ( \left ( -1 \right ) ^{n}-1 \right ) \sin \left ( n\pi \,x \right ){{\rm e}^{-1/20\,{\pi }^{2}{n}^{2}t}}}{{n}^{3}{\pi }^{3}}}$

_______________________________________________________________________________________

5.37 left end held at ﬁxed temperature, right end Robin BC, with source that depends on time (Articolo 8.4.3)

problem number 55

Example 8.4.3 from Partial diﬀerential equations and boundary value problems with Maple by George A. Articolo, 2nd ed.

Solve the heat equation for $$u(x,t)$$

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

For $$0<x<1$$ and $$t>0$$. The boundary conditions are \begin{align*} u(0,t)&=5 \\ u(1,t)+ \frac{\partial u}{\partial x}(1,t) &= 10\\ \end{align*}

Initial condition is $$u(x,0)=\frac{- 40 x^2}{3}+ \frac{45 x}{2}+5$$ and $$k=\frac{1}{20}$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=\frac{1}{20} u^{(2,0)}(x,t)+t,u(x,0)=-\frac{40 x^2}{3}+\frac{45 x}{2}+5,\left \{u(0,t)=5,u^{(1,0)}(1,t)+u(1,t)=10\right \}\right \},u(x,t),x,t\right ]$

Maple

$\text{ sol=() }$

_______________________________________________________________________________________

5.38 left end insulated, right end set at ﬁxed ﬂux with no source

problem number 56

Solve the heat equation for $$u(x,t)$$

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

For $$0<x$$ and $$t>0$$. The boundary conditions are \begin{align*} \frac{\partial u}{\partial x}(0,t) &= 0\\ \frac{\partial u}{\partial x}(1,t) &= 1 \end{align*}

Initial condition is $$u(x,0)=\frac{1}{2} x^2+x$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=13 u^{(2,0)}(x,t),u(x,0)=\frac{x^2}{2}+x,\left \{u^{(1,0)}(0,t)=0,u^{(1,0)}(1,t)=1\right \}\right \},u(x,t),x,t\right ]$

Maple

$u \left ( x,t \right ) =1/2+\sum _{n=1}^{\infty }2\,{\frac{\cos \left ( n\pi \,x \right ){{\rm e}^{-13\,{\pi }^{2}{n}^{2}t}} \left ( \left ( -1 \right ) ^{n}-1 \right ) }{{\pi }^{2}{n}^{2}}}+13\,t+1/2\,{x}^{2}$

_______________________________________________________________________________________

5.39 non zero heat ﬂux at both ends, and no source

problem number 57

Solve the heat equation for $$u(x,t)$$

$u_t = u_{xx}$

For $$0<x<\pi$$ and $$t>0$$. The boundary conditions are \begin{align*} u_x(0,t) &= 1\\ u_x(1,t) &= -1 \end{align*}

Initial condition is $$u(x,0)=\sin (x)$$

Mathematica

$\text{DSolve}\left [\left \{u^{(0,1)}(x,t)=u^{(2,0)}(x,t)-\frac{x^2}{\pi }+x,u(x,0)=\sin (x),\left \{u^{(1,0)}(0,t)=1,u^{(1,0)}(\pi ,t)=-1\right \}\right \},u(x,t),\{x,t\}\right ]$

Maple

$u \left ( x,t \right ) =1/6\,{\frac{1}{\pi } \left ( 6\,\sum _{n=2}^{\infty }-2\,{\frac{\cos \left ( nx \right ){{\rm e}^{-{n}^{2}t}} \left ( \left ( -1 \right ) ^{n}+1 \right ) }{{n}^{2} \left ({n}^{2}-1 \right ) \pi }}\pi -{\pi }^{2}+6\,\pi \,x-6\,{x}^{2}-12\,t+12 \right ) }$

Hand solution

Since the boundary conditions are not homogeneous, we can’t use separation of variables. Let the solution  be

$u=v\left ( x,t\right ) +r\left ( x\right )$ Where $$v\left ( x,t\right )$$ is the solution to $$v_{t}=v_{xx}$$ and homogenous B.C. $$v_{x}\left ( 0,t\right ) =0,v_{x}\left ( \pi ,t\right ) =0$$ and $$r\left ( x\right )$$ is any reference solution which only needs to satisfy the nonhomogeneous boundary conditions: $$r^{\prime }\left ( 0\right ) =1,r^{\prime }\left ( \pi \right ) =-1$$. By guessing, let $$r\left ( x\right ) =Ax+Bx^{2}$$. Let see if this satisﬁes the boundary conditions. $$r^{\prime }=A+2Bx$$. At $$x=0$$ this implies $$1=A$$. Hence $$r=x+Bx^{2}$$. Now $$r^{\prime }=1+2Bx$$. At $$x=\pi$$ this gives $$-1=1+2B\pi$$ or $$B=-\frac{1}{\pi }$$. Therefore $r\left ( x\right ) =x-\frac{1}{\pi }x^{2}$ Substituting $$u=v\left ( x,t\right ) +r\left ( x\right )$$ into the PDE $$u_{t}=u_{xx}$$ and noting that $$r^{\prime \prime }\left ( x\right ) =-\frac{2}{\pi }$$ gives$$v_{t}=v_{xx}-\frac{2}{\pi }\tag{1}$$ PDE (1) is now solved using eigenfunction expansion. We need to ﬁnd eigenfunctions and eigenvalues of $$v_{t}=v_{xx}$$ with $$v_{x}\left ( 0,t\right ) =0,v_{x}\left ( \pi ,t\right ) =0$$. This is known PDE and have eigenfunctions and eigenvalues as follows. For zero eigenvalue, the eigenfunction is an arbitrary constant. Say $$\beta$$. let $$\beta =1$$ since scale is not important.$\Phi _{0}\left ( x\right ) =1$ And for $$n=1,2,3,\cdots$$ \begin{align*} \Phi _{n}\left ( x\right ) & =\cos \left ( \sqrt{\lambda _{n}}x\right ) \\ & =\cos \left ( nx\right ) \end{align*}

with eigenvalues $$\lambda _{n}=n^{2}$$ for $$n=1,2,3,\cdots$$. Now we can eigenfunction expansion and assume the solution to (1) is $$v\left ( x,t\right ) =\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \tag{2}$$ Plugging this into the PDE (1) gives$\sum _{n=0}^{\infty }A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) -\frac{2}{\pi }$ But $$\Phi _{n}^{\prime \prime }\left ( x\right ) =-\lambda _{n}\Phi _{n}\left ( x\right )$$ and the above simpliﬁes to$\sum _{n=0}^{\infty }A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =-\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) -\frac{2}{\pi }$ Since eigenfunctions are complete, we can expand $$\frac{2}{\pi }$$ using them and the above becomes\begin{align} \sum _{n=0}^{\infty }A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) & =-\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) -\sum _{n=0}^{\infty }C_{n}\Phi _{n}\left ( x\right ) \nonumber \\ A_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) +A_{n}\left ( t\right ) \lambda _{n}\Phi _{n}\left ( x\right ) & =-C_{n}\Phi _{n}\left ( x\right ) \nonumber \\ A_{n}^{\prime }\left ( t\right ) +A_{n}\left ( t\right ) \lambda _{n} & =-C_{n}\tag{3} \end{align}

To ﬁnd $$C_{n}$$$\sum _{n=0}^{\infty }C_{n}\Phi _{n}\left ( x\right ) =\frac{2}{\pi }$ For $$n=0$$$C_{0}\Phi _{0}\left ( x\right ) =\frac{2}{\pi }$ But $$\Phi _{0}\left ( x\right ) =1$$, hence $C_{0}=\frac{2}{\pi }$ All other $$C_{m}\,\$$ for $$m>0$$ are zero. Hence (3) becomes, for $$n=0$$ (since $$\lambda _{0}=0$$)\begin{align*} A_{0}^{\prime }\left ( t\right ) & =-\frac{2}{\pi }\\ A_{0}\left ( t\right ) & =-\frac{2}{\pi }t+B_{0} \end{align*}

Where $$B_{0}$$ is integration constant. For $$n>0$$ (3) becomes$A_{n}^{\prime }\left ( t\right ) +A_{n}\left ( t\right ) n^{2}=0$ This has the solution$A_{n}\left ( t\right ) =B_{n}e^{-n^{2}t}$ Where $$B_{n}$$ is constant of integration. Hence from (2)\begin{align*} v\left ( x,t\right ) & =\sum _{n=0}^{\infty }A_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & =A_{0}\left ( t\right ) +\sum _{n=1}^{\infty }A_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \\ & =-\frac{2}{\pi }t+B_{0}+\sum _{n=1}^{\infty }B_{n}e^{-n^{2}t}\cos \left ( nx\right ) \end{align*}

Since $$u=v\left ( x,t\right ) +r\left ( x\right )$$ then the solution becomes$$u\left ( x,t\right ) =\left ( x-\frac{1}{\pi }x^{2}\right ) -\frac{2}{\pi }t+B_{0}+\sum _{n=1}^{\infty }B_{n}e^{-n^{2}t}\cos \left ( nx\right ) \tag{4}$$ At $$t=0$$$$\sin \left ( x\right ) =\left ( x-\frac{1}{\pi }x^{2}\right ) +B_{0}+\sum _{n=1}^{\infty }B_{n}\cos \left ( nx\right ) \tag{5}$$ case $$n=0$$$\int _{0}^{\pi }\sin \left ( x\right ) \cos \left ( \sqrt{\lambda _{0}}x\right ) dx=\int _{0}^{\pi }\left ( x-\frac{1}{\pi }x^{2}\right ) \cos \left ( \sqrt{\lambda _{0}}x\right ) dx+\int _{0}^{\pi }B_{0}\cos \left ( \sqrt{\lambda _{0}}x\right ) dx$ But $$\lambda _{0}=0$$ hence\begin{align*} \int _{0}^{\pi }\sin \left ( x\right ) dx & =\int _{0}^{\pi }\left ( x-\frac{1}{\pi }x^{2}\right ) dx+\int _{0}^{\pi }B_{0}dx\\ 2 & =\frac{\pi ^{2}}{6}+B_{0}\pi \\ B_{0} & =\frac{2}{\pi }-\frac{\pi }{6} \end{align*}

For $$n>0$$, Multiplying both sides of (5) by $$\cos \left ( mx\right )$$ and integrating$\int _{0}^{\pi }\sin \left ( x\right ) \cos \left ( mx\right ) dx=\int _{0}^{\pi }\left ( x-\frac{1}{\pi }x^{2}\right ) \cos \left ( mx\right ) dx+\sum _{n=1}^{\infty }B_{n}\int _{0}^{\pi }\cos \left ( nx\right ) \cos \left ( mx\right ) dx$ For $$m=1$$\begin{align*} 0 & =0+B_{1}\frac{\pi }{2}\\ B_{1} & =0 \end{align*}

For $$m>1$$\begin{align*} -\frac{1+\left ( -1\right ) ^{m}}{m^{2}\left ( -1+m^{2}\right ) } & =\frac{\pi }{2}B_{m}\\ B_{m} & =\frac{-2}{\pi }\left ( \frac{1}{m^{2}}\frac{\left ( -1\right ) ^{m}+1}{m^{2}-1}\right ) \end{align*}

Hence solution (4) becomes\begin{align*} u\left ( x,t\right ) & =\left ( x-\frac{1}{\pi }x^{2}\right ) -\frac{2}{\pi }t-\frac{\pi }{6}+\frac{2}{\pi }+\sum _{n=1}^{\infty }B_{n}e^{-n^{2}t}\cos \left ( nx\right ) \\ u\left ( x,t\right ) & =\left ( x-\frac{1}{\pi }x^{2}\right ) -\frac{2}{\pi }t-\frac{\pi }{6}+\frac{2}{\pi }+\sum _{n=2}^{\infty }\frac{-2}{\pi }\left ( \frac{1}{n^{2}}\frac{\left ( -1\right ) ^{n}+1}{n^{2}-1}\right ) e^{-n^{2}t}\cos \left ( nx\right ) \end{align*}