home

PDF (letter size

Collection of PDE animations


January 29, 2024   Compiled on January 29, 2024 at 3:34am

Contents

1 Heat PDE
2 Wave PDE
3 Laplace and Poisson PDE
4 Burger’s PDE
4.1 Example 1
5 Misc. PDE’s
5.1 FitzHugh-Nagumo in 2D
5.1.1 Example 1
5.1.2 Example 2
6 Appendix
6.1 Summary table
6.2 Using Mathematica to obtain the eigenvalues and eigenfunctions for heat PDE in 1D
6.2.1 \(u(0)=0,u(L)=0\)
6.2.2 \(u^{\prime }(0)=0,u^{\prime }(L)=0\)
6.2.3 \(u^{\prime }(0)=0,u(L)=0\)
6.2.4 \(u(0)=0,u^{\prime }(L)=0\)
6.2.5 \(u(0)=0,u\left ( L\right ) +u^{\prime }(L)=0\)
6.2.6 \(u\left ( 0\right ) +u^{\prime }(0)=0,u^{\prime }(L)=0\)
6.2.7 \(u(-L)=0,u\left ( L\right ) =0\)

These are collection of PDE problems solved analytically and animated. Most of the animations where done in Mathematica, some in Maple and Matlab.

Chapter 1
Heat PDE

Animations moved to This page

Chapter 2
Wave PDE

Animations moved to This page

Chapter 3
Laplace and Poisson PDE

Animations moved to This page

Chapter 4
Burger’s PDE

Solve \begin {equation} u_{t}+u\ u_{x}=Du_{xx} \tag {1} \end {equation}

BC\begin {align*} u\left ( 0,t\right ) & =0\qquad t>0\\ u\left ( L,t\right ) & =0\qquad t>0 \end {align*}

Initial conditions\[ u\left ( x,0\right ) =f\left ( x\right ) \qquad 0<x<L \]

Where \(D\) is the diffusion constant.

Solution

Using Cole-Hopf, let \begin {equation} u\left ( x,t\right ) =-2D\frac {\phi _{x}}{\phi } \tag {2} \end {equation} where \(\phi \equiv \phi \left ( x,t\right ) \). Rewriting equation (1) as

\begin {align} u_{t} & =Du_{xx}-u\ u_{x}\nonumber \\ & =\left ( Du_{x}-\frac {u^{2}}{2}\right ) _{x} \tag {3} \end {align}

Substituting (2) into (3) gives

\begin {align} \left ( -2D\frac {\phi _{x}}{\phi }\right ) _{t} & =\left [ D\left ( -2D\frac {\phi _{x}}{\phi }\right ) _{x}-\frac {1}{2}\left ( -2D\frac {\phi _{x}}{\phi }\right ) ^{2}\right ] _{x}\nonumber \\ -2D\left ( \frac {\phi _{x}}{\phi }\right ) _{t} & =\left ( -2D^{2}\left ( \frac {\phi _{x}}{\phi }\right ) _{x}-2D^{2}\left ( \frac {\phi _{x}}{\phi }\right ) ^{2}\right ) _{x}\nonumber \\ -2D\left ( \frac {\phi _{x}}{\phi }\right ) _{t} & =-2D^{2}\left ( \left ( \frac {\phi _{x}}{\phi }\right ) _{x}+\left ( \frac {\phi _{x}}{\phi }\right ) ^{2}\right ) _{x} \tag {4} \end {align}

But \[ \left ( \frac {\phi _{x}}{\phi }\right ) _{t}=-\frac {1}{\phi ^{2}}\phi _{t}\phi _{x}+\frac {1}{\phi }\phi _{xt}\]

And

\[ \left ( \frac {\phi _{t}}{\phi }\right ) _{x}=-\frac {1}{\phi ^{2}}\phi _{x}\phi _{t}+\frac {1}{\phi }\phi _{tx}\]

Therefore \(\left ( \frac {\phi _{x}}{\phi }\right ) _{t}=\left ( \frac {\phi _{t}}{\phi }\right ) _{x}\). Using this in LHS of (4) gives

\begin {equation} -2D\left ( \frac {\phi _{t}}{\phi }\right ) _{x}=-2D^{2}\left ( \left ( \frac {\phi _{x}}{\phi }\right ) _{x}+\left ( \frac {\phi _{x}}{\phi }\right ) ^{2}\right ) _{x} \tag {5} \end {equation}

And \begin {align*} \left ( \frac {\phi _{x}}{\phi }\right ) _{x}+\left ( \frac {\phi _{x}}{\phi }\right ) ^{2} & =-\frac {1}{\phi ^{2}}\phi _{x}^{2}+\frac {\phi _{xx}}{\phi }+\frac {\phi _{x}^{2}}{\phi ^{2}}\\ & =\frac {\phi _{xx}}{\phi } \end {align*}

Using the above in the RHS of (5) gives

\begin {equation} -2D\left ( \frac {\phi _{t}}{\phi }\right ) _{x}=-2D^{2}\left ( \frac {\phi _{xx}}{\phi }\right ) _{x} \tag {6} \end {equation}

Integrating both side w.r.t. \(x\) gives

\[ -2D\frac {\phi _{t}}{\phi }=-2D^{2}\frac {\phi _{xx}}{\phi }+G\left ( t\right ) \]

Where \(G\left ( t\right ) \) is the constant of integration since \(\phi \equiv \phi \left ( x,t\right ) \). The above simplifies to the heat PDE in \(\phi \left ( x,t\right ) \)

\begin {equation} \phi _{t}=D\phi _{xx}+G\left ( t\right ) \phi \tag {6A} \end {equation}

Let \begin {equation} \psi =\phi e^{-\int G\left ( t\right ) dt} \tag {6B} \end {equation}

Then \begin {align*} \psi _{t} & =\phi _{t}e^{-\int G\left ( t\right ) dt}-\phi G\left ( t\right ) e^{-\int G\left ( t\right ) dt}\\ & =\left ( \phi _{t}-\phi G\left ( t\right ) \right ) e^{-\int G\left ( t\right ) dt} \end {align*}

But from (6A), we see that \(\phi _{t}-\phi G\left ( t\right ) =D\phi _{xx}\). Therefore the above becomes

\[ \psi _{t}=D\phi _{xx}e^{-\int G\left ( t\right ) dt}\]

But from (6B), we see that \(\phi _{xx}e^{-\int G\left ( t\right ) dt}=\psi _{xx}\), therefore the above becomes

\[ \psi _{t}=D\psi _{xx}\]

Which is the heat PDE. The original BC and initial conditions are now transformed to \(\psi \) to solve the above. Since \(u=-2D\frac {\phi _{x}}{\phi }\), then solving this first for \(\phi \)

\begin {align*} \frac {\phi _{x}}{\phi } & =-\frac {1}{2D}u\\ \frac {\partial \phi }{\partial x}\frac {1}{\phi } & =-\frac {1}{2D}u\\ \frac {d\phi }{\phi } & =-\frac {1}{2D}udx \end {align*}

Integrating gives

\begin {align*} \ln \phi & =-\frac {1}{2D}\int _{0}^{x}u\ ds+C_{0}\\ \phi \left ( x,t\right ) & =Ce^{-\frac {1}{2D}\int _{0}^{x}u\ ds} \end {align*}

Since \(u=-2D\frac {\phi _{x}}{\phi }\), then the constant \(C\) cancels out. Then we it can be set to any value as it does not affect the solution. Let \(C=1\) and the above becomes

\begin {equation} \phi \left ( x,t\right ) =e^{-\frac {1}{2D}\int _{0}^{x}u\ ds} \tag {7} \end {equation}

(7) is now used to transform the initial conditions. When \(u\left ( x,0\right ) =f\left ( x\right ) \) the above becomes

\begin {align*} \phi \left ( x,0\right ) & =e^{-\frac {1}{2D}\int _{0}^{x}u\left ( s,0\right ) \ ds}\\ & =e^{-\frac {1}{2D}\int _{0}^{x}f\left ( s\right ) \ ds} \end {align*}

Since from (6B), \(\psi \left ( x,t\right ) =\phi e^{-\int G\left ( t\right ) dt}=\phi e^{-\int _{0}^{t}G\left ( s\right ) ds}\) therefore

\begin {align*} \psi \left ( x,0\right ) & =\phi \left ( x,0\right ) e^{0}\\ & =\phi \left ( x,0\right ) \\ & =e^{-\frac {1}{2D}\int _{0}^{x}f\left ( s\right ) \ ds} \end {align*}

To transform the boundary conditions, \(u=-2D\frac {\phi _{x}}{\phi }\) is used. When \(u\left ( 0,t\right ) =0\) then \(0=-2D\frac {\phi _{x}\left ( 0,t\right ) }{\phi \left ( 0,t\right ) }\) or

\[ \phi _{x}\left ( 0,t\right ) =0 \]

But \(\psi =\phi e^{-\int _{0}^{t}G\left ( s\right ) ds}\), then \(\psi _{x}=\phi _{x}e^{-\int _{0}^{t}G\left ( s\right ) ds}\) and therefore

\begin {align*} \psi _{x}\left ( 0,t\right ) & =\phi _{x}\left ( 0,t\right ) e^{-\int _{0}^{t}G\left ( s\right ) ds}\\ & =0 \end {align*}

Similarly, when \(u\left ( L,t\right ) =0\) then \(0=-2D\frac {\phi _{x}\left ( L,t\right ) }{\phi \left ( L,t\right ) }\) or

\[ \phi _{x}\left ( L,t\right ) =0 \]

Which gives

\[ \psi _{x}\left ( L,t\right ) =0 \]

Hence the heat PDE to solve is

\[ \psi _{t}=D\psi _{xx}\]

BC\begin {align*} \psi _{x}\left ( 0,t\right ) & =0\qquad t>0\\ \psi _{x}\left ( L,t\right ) & =0\qquad t>0 \end {align*}

Initial conditions\[ \psi \left ( x,0\right ) =e^{-\frac {1}{2D}\int _{0}^{x}f\left ( s\right ) \ ds}\qquad 0<x<L \]

The above heat PDE is now solved for \(\psi \left ( x,t\right ) \). This solution is transformed back to \(u\left ( x,t\right ) \). First using \(\psi =\phi e^{-\int G\left ( t\right ) dt}\) to find \(\phi \left ( x,t\right ) \), then using \(u\left ( x,t\right ) =-2D\frac {\phi _{x}}{\phi }\), to find \(u\left ( x,t\right ) \).

So in summary, there are two transformations needed. Going from \(u\left ( x,t\right ) \rightarrow \phi \left ( x,t\right ) \) uses Cole-Hopf. Going from \(\phi \left ( x,t\right ) \rightarrow \psi \left ( x,t\right ) \) uses \(\psi \left ( x,t\right ) =\phi \left ( x,t\right ) e^{-\int G\left ( t\right ) dt}.\) It is \(\psi \left ( x,t\right ) \) which is solved as the heat PDE \(\psi _{t}=D\psi _{xx}\) and not \(\phi \left ( x,t\right ) \), which is just an intermediate transformation.

4.1 Example 1

Let \(\,L=2\pi ,0<x<2\pi ,D=\frac {1}{10},\)\[ u\left ( x,0\right ) =f\left ( x\right ) =\sin x \] And boundary conditions \(u\left ( 0,t\right ) =u\left ( 2\pi ,0\right ) =0\). From above, after carrying the forward transformation, the PDE to solve is found to be

\[ \psi _{t}=D\psi _{xx}\]

With transformed boundary conditions

\begin {align*} \psi _{x}\left ( 0,t\right ) & =0\qquad t>0\\ \psi _{x}\left ( 2\pi ,t\right ) & =0\qquad t>0 \end {align*}

And transformed initial conditions

\[ \psi \left ( x,0\right ) =e^{-\frac {1}{2D}\int \sin \left ( x\right ) \ dx}=e^{\frac {1}{2D}\cos \left ( x\right ) }\]

This heat PDE is standard and has known solution by separation of variables which is

\begin {align*} \psi \left ( x,t\right ) & =c_{0}+\sum _{n=1}^{\infty }c_{n}e^{-D\lambda _{n}t}\cos \left ( \sqrt {\lambda _{n}}x\right ) \\ \lambda _{n} & =\left ( \frac {n\pi }{L}\right ) ^{2}\qquad n=1,2,3,\cdots \end {align*}

Or, since \(L=2\pi \),

\begin {align*} \psi \left ( x,t\right ) & =c_{0}+\sum _{n=1}^{\infty }c_{n}e^{-D\frac {n^{2}}{4}t}\cos \left ( \frac {n}{2}x\right ) \\ \lambda _{n} & =\frac {n^{2}}{4}\qquad n=1,2,3,\cdots \end {align*}

Where \begin {align*} c_{0} & =\frac {1}{L}\int _{0}^{L}\psi \left ( x,0\right ) dx\\ & =\frac {1}{2\pi }\int _{0}^{2\pi }e^{\frac {\cos \left ( x\right ) }{2D}}dx\\ & =\operatorname {BesselI}\left ( 0,\frac {1}{2D}\right ) \end {align*}

And

\begin {align*} c_{n} & =\frac {2}{L}\int _{0}^{L}\psi \left ( x,0\right ) \cos \left ( \sqrt {\lambda _{n}}x\right ) dx\\ & =\frac {1}{\pi }\int _{0}^{2\pi }e^{\frac {\cos \left ( x\right ) }{2D}}\cos \left ( \frac {n}{2}x\right ) dx \end {align*}

The after integral has no closed form solution. Hence the solution is

\[ \psi \left ( x,t\right ) =\operatorname {BesselI}\left ( 0,\frac {1}{2D}\right ) +\frac {1}{\pi }\sum _{n=1}^{\infty }\left ( \int _{0}^{2\pi }e^{\frac {\cos \left ( x\right ) }{2D}}\cos \left ( \frac {n}{2}x\right ) dx\right ) e^{-D\frac {n^{2}}{4}t}\cos \left ( \frac {n}{2}x\right ) \]

But \(\psi =\phi e^{-\int G\left ( t\right ) dt}\), therefore

\[ \phi \left ( x,t\right ) =\psi \left ( x,t\right ) e^{\int G\left ( t\right ) dt}\]

But I do not know what \(G\left ( t\right ) \) is. This was used during the forward transformation only and was eliminated. So how to find \(\phi \left ( x,t\right ) \)? Need to find \(\phi \left ( x,t\right ) \) to be able to find \(u\left ( x,t\right ) \) from \(u\left ( x,t\right ) =-2D\frac {\phi _{x}}{\phi }\).

Chapter 5
Misc. PDE’s

5.1 FitzHugh-Nagumo in 2D

5.1.1 Example 1
5.1.2 Example 2

This was solved numerically in Matlab.

5.1.1 Example 1

The equations to solve are the following on the unit square in 2D.\begin {align*} \frac {\partial v\left ( x,y,t\right ) }{\partial t} & =D\nabla ^{2}v+\left ( a-v\right ) \left ( v-1\right ) v-w+I\\ \frac {\partial w\left ( x,y,t\right ) }{\partial t} & =\epsilon \left ( v-\gamma w\right ) \end {align*}

Using \(a=0.1,\gamma =2,\epsilon =0.005,D=5\times 10^{-5},I=0,\) hence the PDE’s are\begin {align*} \frac {\partial v\left ( x,y,t\right ) }{\partial t} & =\left ( 5\times 10^{-5}\right ) \nabla ^{2}v+\left ( 0.1-v\right ) \left ( v-1\right ) v-w\\ \frac {\partial w\left ( x,y,t\right ) }{\partial t} & =0.005\left ( v-2w\right ) \end {align*}

Initial conditions, \(t=0\)\begin {align*} v\left ( x,y,0\right ) & =\exp \left ( -100\left ( x^{2}+y^{2}\right ) \right ) \\ w\left ( x,y,0\right ) & =0 \end {align*}

Boundary conditions are homogeneous Neumann for \(v\). (I solved this numerically, fractional step method. ADI for the diffusion solve).

5.1.2 Example 2

The equations to solve are the following on the unit square in 2D.\begin {align*} \frac {\partial v\left ( x,y,t\right ) }{\partial t} & =D\nabla ^{2}v+\left ( a-v\right ) \left ( v-1\right ) v-w+I\\ \frac {\partial w\left ( x,y,t\right ) }{\partial t} & =\epsilon \left ( v-\gamma w\right ) \end {align*}

Using \(a=0.1,\gamma =2,\epsilon =0.005,D=5\times 10^{-5},I=0,\) hence the PDE’s are\begin {align*} \frac {\partial v\left ( x,y,t\right ) }{\partial t} & =\left ( 5\times 10^{-5}\right ) \nabla ^{2}v+\left ( 0.1-v\right ) \left ( v-1\right ) v-w\\ \frac {\partial w\left ( x,y,t\right ) }{\partial t} & =0.005\left ( v-2w\right ) \end {align*}

Initial conditions, \(t=0\)\begin {align*} v\left ( x,y,0\right ) & =1-2x\\ w\left ( x,y,0\right ) & =0.05y \end {align*}

Boundary conditions are homogeneous Neumann for \(v\). (I solved this numerically, fractional step method. ADI for the diffusion solve). See my Matlab web page for source code.

Chapter 6
Appendix

6.1 Summary table

Heat PDE \(\frac {\partial u}{\partial t}=k\frac {\partial ^{2}u}{\partial x^{2}}\) in \(1D\) (in a rod)

Left side Right side \(u(x,0)\) \(\lambda =0\) \(\lambda >0\)
\(u\left ( 0\right ) =0\) \(u\left ( L\right ) =0\) triangle No \(\begin {array} [c]{l}\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \\ X_{n}=B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\end {array} \)
\(u\left ( 0\right ) =0\) \(u\left ( L\right ) =0\) \(100\) No \(\begin {array} [c]{l}\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \\ X_{n}=B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\end {array} \)
\(u\left ( 0\right ) =T_{0}\) \(u\left ( L\right ) =0\) \(x\) No \(\begin {array} [c]{l}\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \\ X_{n}=B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =T_{0}-\frac {T_{0}}{L}x+\sum _{n=1}^{\infty }B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\end {array} \)
\(\frac {\partial u\left ( 0\right ) }{\partial x}=0\) \(\frac {\partial u\left ( L\right ) }{\partial x}=0\) \(x\) \(\begin {array} [c]{l}\lambda _{0}=0\\ X_{0}=A_{0}\end {array} \) \(\begin {array} [c]{l}\lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \\ X_{n}=A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\end {array} \)
\(\frac {\partial u\left ( 0\right ) }{\partial x}=0\) \(u\left ( L\right ) =T_{0}\) \(0\) No \(\begin {array} [c]{l}\lambda _{n}=\left ( \frac {n\pi }{2L}\right ) ^{2},n=1,3,5,\cdots \\ X_{n}=A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =T_{0}+\sum _{n=1,3,5,\cdots }^{\infty }A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\end {array} \)
\(\frac {\partial u\left ( 0\right ) }{\partial x}=0\) \(u\left ( L\right ) =0\) \(f\left ( x\right ) \) No \(\begin {array} [c]{l}\lambda _{n}=\left ( \frac {n\pi }{2L}\right ) ^{2},n=1,3,5,\cdots \\ X_{n}=A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =\sum _{n=1,3,5\cdots }^{\infty }A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\end {array} \)
\(u\left ( 0\right ) =0\) \(\frac {\partial u\left ( L\right ) }{\partial x}=0\) \(f\left ( x\right ) \) No \(\begin {array} [c]{l}\lambda _{n}=\left ( \frac {n\pi }{2L}\right ) ^{2},n=1,3,5,\cdots \\ X_{n}=B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ 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}\end {array} \)
\(u\left ( 0\right ) =0\) \(u\left ( L\right ) +\frac {\partial u\left ( L\right ) }{\partial x}=0\) \(f\left ( x\right ) \) No \(\begin {array} [c]{l}\tan \left ( \sqrt {\lambda _{n}}L\right ) +\sqrt {\lambda _{n}}=0\\ X_{n}=B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =\sum _{n=1}^{\infty }B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}\end {array} \)
\(u\left ( 0\right ) +\frac {\partial u\left ( 0\right ) }{\partial x}=0\) \(u\left ( 0\right ) =0\) 0 \(\begin {array} [c]{l}\lambda _{0}=0\\ X_{0}=A_{0}\end {array} \) \(\tan \left ( \sqrt {\lambda _{n}}L\right ) -\sqrt {\lambda _{n}}=0\)
\(u\left ( -1\right ) =0\) \(u\left ( 1\right ) =0\) \(f\left ( x\right ) \) No \(\begin {array} [c]{l}\sqrt {\lambda _{n}}=\frac {n\pi }{2}\qquad n=1,2,3,\cdots \\ X_{n}=A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) ,\sin \left ( \sqrt {\lambda _{n}}x\right ) \\ u\left ( x,t\right ) =\sum _{n=1,3,\cdots }^{\infty }A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) e^{-\lambda _{n}t}+\sum _{n=2,4,\cdots }^{\infty }B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-\lambda _{n}t}\end {array} \)

Heat PDE \(\frac {\partial u}{\partial t}=\alpha \frac {\partial ^{2}u}{\partial x^{2}}-\beta u\) in \(1D\) (in a rod) with \(\alpha ,\beta >0\) for \(0<x<\pi \)

Left side Right side initial condition \(\lambda =0\) \(\lambda >0\) analytical solution \(u\left ( x,t\right ) \)
\(\frac {\partial u\left ( 0,t\right ) }{\partial x}=0\) \(\frac {\partial u\left ( \pi ,t\right ) }{\partial x}=0\) \(u\left ( x,0\right ) =x\) \(\begin {array} [c]{l}\lambda _{0}=0\\ X_{0}=A_{0}\end {array} \) \(\begin {array} [c]{l}\lambda _{n}=n^{2},n=1,2,3,\cdots \\ X\left ( x\right ) =A_{0}+\sum _{n=1}^{\infty }A_{n}\cos \left ( nx\right ) \end {array} \) \(\frac {\pi }{2}+c_{0}\left ( e^{-\beta t}-1\right ) +\frac {2}{\pi }\sum _{n=1}^{\infty }\frac {\left ( \left ( -1\right ) ^{n}-1\right ) }{n^{2}}\cos \left ( nx\right ) e^{-\left ( n^{2}\alpha +\beta \right ) t}\)

(TO DO) Heat PDE for periodic conditions \(u\left ( -L\right ) =u\left ( L\right ) \) and \(\frac {\partial u\left ( -L\right ) }{\partial x}=\frac {\partial u\left ( L\right ) }{\partial x}\)

\[ \lambda _{n}=\left ( \frac {n\pi }{L}\right ) ^{2},n=1,2,3,\cdots \]\[ u\left ( x,t\right ) ={\overbrace {a_{0}}}+{\overbrace {\sum _{n=1}^{\infty }A_{n}\cos \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}+\sum _{n=1}^{\infty }B_{n}\sin \left ( \sqrt {\lambda _{n}}x\right ) e^{-k\lambda _{n}t}}}\]

6.2 Using Mathematica to obtain the eigenvalues and eigenfunctions for heat PDE in 1D

6.2.1 \(u(0)=0,u(L)=0\)
6.2.2 \(u^{\prime }(0)=0,u^{\prime }(L)=0\)
6.2.3 \(u^{\prime }(0)=0,u(L)=0\)
6.2.4 \(u(0)=0,u^{\prime }(L)=0\)
6.2.5 \(u(0)=0,u\left ( L\right ) +u^{\prime }(L)=0\)
6.2.6 \(u\left ( 0\right ) +u^{\prime }(0)=0,u^{\prime }(L)=0\)
6.2.7 \(u(-L)=0,u\left ( L\right ) =0\)

6.2.1 \(u(0)=0,u(L)=0\)

For eigenvalue

ClearAll[y,x,L]; 
op={-y''[x]  ,DirichletCondition[y[x]==0,x==0], 
DirichletCondition[y[x]==0,x==L]}; 
(*or simply*) 
op={-y''[x],DirichletCondition[y[x]==0,True]}; 
eig=DEigenvalues[op,y[x],{x,0,L},5]
 

\[ \left \{\frac {\pi ^2}{L^2},\frac {4 \pi ^2}{L^2},\frac {9 \pi ^2}{L^2},\frac {16 \pi ^2}{L^2},\frac {25 \pi ^2}{L^2}\right \} \]

FindSequenceFunction[eig,n]
 

\[ \frac {\pi ^2 n^2}{L^2} \]

For eigenfunctions

ClearAll[y,x,L]; 
op={-y''[x]  ,DirichletCondition[y[x]==0,x==0], 
DirichletCondition[y[x]==0,x==L]}; 
eigf=Last@DEigensystem[op,y[x],{x,0,L},5]
 

\[ \left \{\sin \left (\frac {\pi x}{L}\right ),\sin \left (\frac {2 \pi x}{L}\right ),\sin \left (\frac {3 \pi x}{L}\right ),\sin \left (\frac {4 \pi x}{L}\right ),\sin \left (\frac {5 \pi x}{L}\right )\right \} \]

FullSimplify[FindSequenceFunction[eigf,n]];
 

\[ \sin \left (\frac {\pi n x}{L}\right ) \]

6.2.2 \(u^{\prime }(0)=0,u^{\prime }(L)=0\)

For eigenvalue

ClearAll[y,x,L]; 
op={-y''[x]+NeumannValue[0,True]}; 
eig=DEigenvalues[op,y[x],{x,0,L},5]
 

\[ \left \{0,\frac {\pi ^2}{L^2},\frac {4 \pi ^2}{L^2},\frac {9 \pi ^2}{L^2},\frac {16 \pi ^2}{L^2}\right \} \]

FindSequenceFunction[eig,n]
 

\[ \frac {\pi ^2 (n-1)^2}{L^2} \]

ClearAll[y,x,L]; 
op={-y''[x]+NeumannValue[0,True]}; 
eigf=Last@DEigensystem[op,y[x],{x,0,L},5]
 

\[ \left \{1,\cos \left (\frac {\pi x}{L}\right ),\cos \left (\frac {2 \pi x}{L}\right ),\cos \left (\frac {3 \pi x}{L}\right ),\cos \left (\frac {4 \pi x}{L}\right )\right \} \]

FullSimplify[FindSequenceFunction[eigf, n]];
 

\[ \cos \left (\frac {\pi (n-1) x}{L}\right ) \]

6.2.3 \(u^{\prime }(0)=0,u(L)=0\)

For eigenvalue

ClearAll[y,x,L]; 
op={-y''[x]+NeumannValue[0,x==0],DirichletCondition[y[x]==0,x==L]}; 
eig=DEigenvalues[op,y[x],{x,0,L},6] 
\begin{MMAinline} 
 
\[ 
\left\{\frac{\pi^2}{4 L^2},\frac{9 \pi^2}{4 L^2},\frac{25 \pi^2}{4 L^2}% 
,\frac{49 \pi^2}{4 L^2},\frac{81 \pi^2}{4 L^2},\frac{121 \pi^2}{4 L^2}\right\} 
\] 
 
\begin{MMAinline} 
Simplify[FindSequenceFunction[eig,n]]
 

\[ \frac {\pi ^2 (1-2 n)^2}{4 L^2} \]

For eigenfunctions

eigf=Last@DEigensystem[op,y[x],{x,0,L},7]
 

\[ \left \{\cos \left (\frac {\pi x}{2 L}\right ),\cos \left (\frac {3 \pi x}{2 L}\right ),\cos \left (\frac {5 \pi x}{2 L}\right ),\cos \left (\frac {7 \pi x}{2 L}\right ),\cos \left (\frac {9 \pi x}{2 L}\right )\right \} \]

FullSimplify[FindSequenceFunction[eigf,n]];
 

\[ \cos \left (\frac {\pi (1-2 n) x}{2 L}\right ) \]

6.2.4 \(u(0)=0,u^{\prime }(L)=0\)

Eigenvalue are the same as above

ClearAll[y,x,L]; 
op={-y''[x]+NeumannValue[0,x==L],DirichletCondition[y[x]==0,x==0]}; 
eig=DEigenvalues[op,y[x],{x,0,L},6]
 

\[ \left \{\frac {\pi ^2}{4 L^2},\frac {9 \pi ^2}{4 L^2},\frac {25 \pi ^2}{4 L^2},\frac {49 \pi ^2}{4 L^2},\frac {81 \pi ^2}{4 L^2},\frac {121 \pi ^2}{4 L^2}\right \} \]

FindSequenceFunction[eig,n]
 

\[ \frac {\pi ^2 (1-2 n)^2}{4 L^2} \]

For eigenfunctions

eigf=Last@DEigensystem[op,y[x],{x,0,L},6]
 

\[ \left \{\sin \left (\frac {\pi x}{2 L}\right ),\sin \left (\frac {3 \pi x}{2 L}\right ),\sin \left (\frac {5 \pi x}{2 L}\right ),\sin \left (\frac {7 \pi x}{2 L}\right ),\sin \left (\frac {9 \pi x}{2 L}\right ),\sin \left (\frac {11 \pi x}{2 L}\right )\right \} \]

FullSimplify[FindSequenceFunction[eigf, n]];
 

\[ -\sin \left (\frac {\pi (1-2 n) x}{2 L}\right ) \]

6.2.5 \(u(0)=0,u\left ( L\right ) +u^{\prime }(L)=0\)

For eigenvalue

(*can only find them numerially*) 
ClearAll[y,x]; 
op={-y''[x]+NeumannValue[y[x],x==1],DirichletCondition[y[x]==0,x==0]}; 
eig=DEigenvalues[op,y[x],{x,0,1},6]//N 
(* {4.11586,24.1393,63.6591,122.889,201.851,300.55}*) 
NSolve[Tan[Sqrt[lam]]+Sqrt[lam]==0&& 0<lam<130,lam] 
(*{{lam->4.11586},{lam->24.1393},{lam->63.6591},{lam->122.889}}*)
 

For eigenfunctions

ClearAll[y,x]; 
op={-y''[x]+NeumannValue[y[x],x==1],DirichletCondition[y[x]==0,x==0]}; 
eig=Last@DEigensystem[op,y[x],{x,0,1},6]//N
 

\[ \{\sin (2.02876 x),\sin (4.91318 x),\sin (7.97867 x),\sin (11.0855 x),\sin (14.2074 x),\sin (17.3364 x)\} \]

6.2.6 \(u\left ( 0\right ) +u^{\prime }(0)=0,u^{\prime }(L)=0\)

For eigenvalue

 
(*can only find them numerially. Notice the sign difference now. *) 
ClearAll[y,x]; 
op={-y''[x]+NeumannValue[-y[x],x==0],DirichletCondition[y[x]==0,x==1]}; 
eig=DEigenvalues[op,y[x],{x,0,1},6]//N 
(* {0.,20.1908,59.6814,118.914,197.924,296.774}*) 
NSolve[Tan[Sqrt[lam]]-Sqrt[lam]==0&& 0<=lam<130,lam] 
(*{{lam->0.},{lam->20.1907},{lam->59.6795},{lam->118.9},{lam->197.858}% 
,{lam->296.554}}*)
 

For eigenfunctions, mathematica only gives plots, so not shown.

6.2.7 \(u(-L)=0,u\left ( L\right ) =0\)

For eigenvalue

ClearAll[y,x,L]; 
op={-y''[x],DirichletCondition[y[x]==0,x==-L],DirichletCondition[y[x]==0,x==L]}% 
; 
eig=DEigenvalues[op,y[x],{x,-L,L},6]
 

\[ \left \{\frac {\pi ^2}{4 L^2},\frac {\pi ^2}{L^2},\frac {9 \pi ^2}{4 L^2},\frac {4 \pi ^2}{L^2},\frac {25 \pi ^2}{4 L^2},\frac {9 \pi ^2}{L^2}\right \} \]

Simplify[FindSequenceFunction[eig,n]]
 

\[ \frac {\pi ^2 n^2}{4 L^2} \]

For eigenfunctions

eigf= Last@DEigensystem[op,y[x],{x,-L,L},6]
 

\[ \left \{\sin \left (\frac {\pi (L+x)}{2 L}\right ),\sin \left (\frac {\pi (L+x)}{L}\right ),\sin \left (\frac {3 \pi (L+x)}{2 L}\right ),\sin \left (\frac {2 \pi (L+x)}{L}\right ),\sin \left (\frac {5 \pi (L+x)}{2 L}\right )\right \} \]

FullSimplify[FindSequenceFunction[eigf,n]]; 
Assuming[Element[n,Integers]&&Element[L,Reals],FullSimplify[
 

\[ \frac {1}{2} i \left (\left (-i e^{-\frac {i \pi x}{2 L}}\right )^n-\left (i e^{\frac {i \pi x}{2 L}}\right )^n\right ) \]