logo

Numerical Solution to the Initial Value Problem for the Heat Equation Given Dirichlet Boundary Conditions 📂Numerical Analysis

Numerical Solution to the Initial Value Problem for the Heat Equation Given Dirichlet Boundary Conditions

Example 1

{ut=γuxxu(t,0)=u(t,l)=0u(0,x)=f(x) \begin{cases} u_{t} = \gamma u_{xx} \\ u(t,0) = u(t,l) = 0 \\ u(0,x) = f(x) \end{cases}

The given problem has an algebraic solution simple enough to solve, yet it serves as a clear example of why we learn numerical methods to solve differential equations. It shows how solving a simple differential equation of the form y=f(x,y)y ' = f(x,y) leads to the solution of partial differential equations.

Solution

Unlike in algebraic solutions, the value of γ\gamma is not important, so let’s say it is γ=1\gamma = 1 for convenience.

xj=δj x_{j} = \delta j If we set the step size of the Line Space xx to δ\delta, then for j=0,1,,mj= 0, 1, \cdots , m, it can be represented as shown above.

For the second order derivative approximation of xx UxxU(t,xj+1)2U(t,xj)+U(t,xj1)δ2 U_{xx} \approx {{ U(t, x_{j+1}) - 2 U(t, x_{j}) + U(t, x_{j-1}) } \over { \delta^2 }} then only for the equation regarding tt ut(t,xj)=u(t,xj+1)2u(t,xj)+u(t,xj1)δ2 u_{t} (t, x_{j}) = {{ u(t, x_{j+1}) - 2 u(t, x_{j}) + u(t, x_{j-1}) } \over { \delta^2 }} we can obtain m1m-1 equations. Representing this as a matrix gives us [ut(t,x1)ut(t,x2)ut(t,x3)ut(t,xm2)ut(t,xm1)]=1δ2[2100012100012000002100012][u(t,x1)u(t,x2)u(t,x3)u(t,xm2)u(t,xm1)] \begin{bmatrix} u_{t} (t, x_{1}) \\ u_{t} (t, x_{2}) \\ u_{t} (t, x_{3}) \\ \vdots \\ u_{t} (t, x_{m-2}) \\ u_{t} (t, x_{m-1}) \end{bmatrix} = {{1} \over {\delta^2}} \begin{bmatrix} -2 & 1 & 0 & \cdots & 0 & 0 \\ 1 & -2 & 1 & \cdots & 0 & 0 \\ 0 & 1 & -2 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \cdots & -2 & 1 \\ 0 & 0 & 0 & \cdots & 1 & -2 \end{bmatrix} \begin{bmatrix} u (t, x_{1}) \\ u (t, x_{2}) \\ u (t, x_{3}) \\ \vdots \\ u (t, x_{m-2}) \\ u (t, x_{m-1}) \end{bmatrix} and to save space, u(t):=[ut(t,x1)ut(t,x2)ut(t,x3)ut(t,xm2)ut(t,xm1)] \mathbf{u} ' (t) :=\begin{bmatrix} u_{t} (t, x_{1}) \\ u_{t} (t, x_{2}) \\ u_{t} (t, x_{3}) \\ \vdots \\ u_{t} (t, x_{m-2}) \\ u_{t} (t, x_{m-1}) \end{bmatrix}

Λ:=1δ2[2100012100012000002100012] \Lambda := {{1} \over {\delta^2}} \begin{bmatrix} -2 & 1 & 0 & \cdots & 0 & 0 \\ 1 & -2 & 1 & \cdots & 0 & 0 \\ 0 & 1 & -2 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \cdots & -2 & 1 \\ 0 & 0 & 0 & \cdots & 1 & -2 \end{bmatrix}

u(t):=[u(t,x1)u(t,x2)u(t,x3)u(t,xm2)u(t,xm1)] \mathbf{u} (t) := \begin{bmatrix} u (t, x_{1}) \\ u (t, x_{2}) \\ u (t, x_{3}) \\ \vdots \\ u (t, x_{m-2}) \\ u (t, x_{m-1}) \end{bmatrix} let’s say it is u(t)=Λu(t)\mathbf{u} ’ (t) = \Lambda \mathbf{u} (t). Now, setting the time step size tt to hh and calling it tk=hkt_{k} = hk, we can apply various methods to find the numerical solution.

Lesson: Stiff Differential Equations

However, all these are theoretical discussions, and actually finding a numerical solution poses significant challenges.

To know the eigenvalues of Λ\Lambda, let’s calculate the determinant of matrix ΛλIm1\Lambda - \lambda I_{m-1}.

Determinant of Tridiagonal Matrices: For the tridiagonal matrix Xn:=[x10001x10001x00000x10001x]X_{n} := \begin{bmatrix} x & 1 & 0 & \cdots & 0 & 0 \\ 1 & x & 1 & \cdots & 0 & 0 \\ 0 & 1 & x & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \cdots & x & 1 \\ 0 & 0 & 0 & \cdots & 1 & x \end{bmatrix}, xn=Un(x2)\displaystyle | x_{n}| = U_{n} \left( {{x} \over {2}} \right)

ΛλIm1=1δ2[2δ2λ100012δ2100012δ2000002δ2100012δ2] \Lambda - \lambda I_{m-1} = {{1} \over { \delta^2 }} \begin{bmatrix} -2 - \delta^2 \lambda & 1 & 0 & \cdots & 0 & 0 \\ 1 & -2 - \delta^2 & 1 & \cdots & 0 & 0 \\ 0 & 1 & -2 - \delta^2 & \cdots & 0 & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & 0 & \cdots & -2 - \delta^2 & 1 \\ 0 & 0 & 0 & \cdots & 1 & -2 - \delta^2 \end{bmatrix} since it is a tridiagonal matrix (m1)×(m1)(m - 1) \times (m-1), the determinant is calculated as det(ΛλIm1)=1δ2Um1(2δ2λ2) \det \left( \Lambda - \lambda I_{m-1} \right) = {{1} \over { \delta^2 }} U_{m-1} \left( {{-2 - \delta^2 \lambda } \over {2}} \right) . Here, Um1U_{m-1} means the second kind Chebyshev polynomials of order m1m-1.

Roots and Symmetry of the Second Kind Chebyshev Polynomials:

  • [1]: Roots of Un(X)\displaystyle U_{n} (X) are xk=cos(kn+1π)\displaystyle x_{k} = \cos \left( {{k} \over {n+1}} \pi \right), k=1,,nk=1, \cdots , n
  • [2]: Un(x)=(1)nUn(x)U_{n} (-x) = (-1)^{n} U_{n} (x)

Extracting 1-1 from the bracket gives us (1)m1δ2Um1(2+δ2λ2) {{(-1)^{m-1}} \over { \delta^2 }} U_{m-1} \left( {{2 + \delta^2 \lambda } \over {2}} \right) and to find the eigenvalues, only Um1(2+δ2λ2) U_{m-1} \left( {{2 + \delta^2 \lambda } \over {2}} \right) needs attention. The jjth root of Um1(2+δ2λ2)\displaystyle U_{m-1} \left( {{2 + \delta^2 \lambda } \over {2}} \right) for j=1,,(m1)j=1, \cdots , (m-1) is 2+δ2λj2=cos(jmπ) {{2 + \delta^2 \lambda_{j}} \over {2}} = \cos \left( {{j} \over {m}} \pi \right) and multiplying both sides by 22 gives 2+δ2λj=2cos(jmπ)=2cos(2j2mπ)=2[12sin2(jπ2m)] \begin{align*} \displaystyle 2+\delta^2 \lambda_{j} =& 2 \cos \left( {{j} \over {m}} \pi \right) \\ =& 2 \cos \left( 2 \cdot {{j} \over {2m}} \pi \right) \\ =& 2 \left[ 1 - 2 \sin^2 \left( {{ j \pi } \over { 2m }} \right) \right] \end{align*} Therefore, the eigenvalues are obtained as λj=4δ2sin2(jπ2m) \lambda_{j} = - {{4} \over { \delta^2 }} \sin^2 \left( {{j \pi } \over {2m}} \right) However, λm1=4δ2sin2((m1)π2m)4δ2=4m2 \begin{align*} \left| \lambda_{m-1} \right| =& \left| {{4} \over { \delta^2 }} \sin^2 \left( {{(m-1) \pi } \over {2m}} \right) \right| \\ \approx & {{4} \over {\delta^2}} \\ =& 4 m^2 \end{align*}

thus, as m=1δ\displaystyle m = {{1} \over {\delta}} gets larger, the magnitudes of the eigenvalues also hugely increase. If you chose a small δ\delta to split [0,1][0,1] into many parts to accurately know the numerical solution, it becomes exceedingly challenging to compute. Even if you set it to m=100m=100, u(t)=Λu(t)\mathbf{u} ’ (t) = \Lambda \mathbf{u} (t) becomes a Stiff problem, making it quite difficult to solve numerically.

See Also


  1. Atkinson. (1989). An Introduction to Numerical Analysis(2nd Edition): p414~417. ↩︎