Preface


This tutorial is made solely for the purpose of education and it is designed for students taking Applied Math 0330. It is primarily for students who have very little experience or have never used Mathematica before and would like to learn more of the basics for this computer algebra system. As a friendly reminder, don't forget to clear variables in use and/or the kernel.

Finally, the commands in this tutorial are all written in bold black font, while Mathematica output is in regular fonts. This means that you can copy and paste all comamnds into Mathematica, change the parameters and run them. You, as the user, are free to use the scripts to your needs for learning how to use the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately.

Return to computing page for the first course APMA0330
Return to computing page for the second course APMA0340
Return to Mathematica tutorial for the first course APMA0330
Return to Mathematica tutorial for the second course APMA0340
Return to the main page for the course APMA0330
Return to the main page for the course APMA0340
Return to Part VII of the course APMA0330

Finite Difference Schemes


Methods involving difference quotient approximations for derivatives can be used for solving certain second-order boundary value problems. Consider the Dirichlet boundary value problem for the linear differential equation

\[ x'' (t) = p(t)\,x' + q(t)\,x + r(t) \qquad \mbox{subject} \quad u(a) = \alpha, \quad u(b) = \beta \]
over interval [a,b]. Form a partition of [a,b] using the uniform mesh points \( a=t_0 < t_1 < \cdots < t_m =b , \) where \( t_j = a+ jh, \quad j=0,1,2,\ldots , m \) with step length \( h =(b-a)/m . \) We use the central difference formulas to approximate derivatives
\[ \begin{split} x' (t) &= \frac{x(t_{j+1}) - x(t_{j-1})}{2h} + O \left( h^2 \right) , \\ x'' (t) &= \frac{x(t_{j+1}) - 2\, x(t_j ) + x(t_{j-1})}{2h} + O \left( h^2 \right) . \end{split} \]
To start the derivation, we replace each term \( x( t_j ) \) on the right side with xj and the resulting equations are substituted into the given differential equation. This yields
\[ \frac{x(t_{j+1}) - 2\, x(t_j ) + x(t_{j-1})}{2h} + O \left( h^2 \right) = p(t_j ) \left( \frac{x(t_{j+1}) - x(t_{j-1})}{2h} + O \left( h^2 \right) \right) + q(t_j ) + r(t_j ) . \]
For simplicity, we introduce the notation \( p_j = p(t_j ) , \quad q_j = q(t_j ) , \quad r_j = r(t_j ) . \) Next, we drop the two terms O(h3) to obtain
\[ \frac{x(t_{j+1}) - 2\, x(t_j ) + x(t_{j-1})}{2h} = p_j \, \frac{x(t_{j+1}) - x(t_{j-1})}{2h} + q_j + r_j . \]
This difference equation is used to compute numerical approximations to the iven differential equation. This is carried out by multiplying each side by h2 and then collecting terms involving xj-1, xj, and xj+1 and arranging them in a system of linear equations:
\[ \left( - \frac{h}{2} \, p_j -1 \right) x_{j-1} + \left( 2 + h^2 q_j \right) x_j + \left( \frac{h}{2} \, p_j -1 \right) x_{j+1} = -h^2 r_j , \]
for \( j=1,2,\ldots , m-1 , \) where \( x_0 = \alpha \) and \( x_m = \beta . \) This system has the familiar tridiagonal form, which is more visible when displayed with matrix notation:
\[ \begin{bmatrix} 2+h^2 q_1 & \frac{h}{2}\,p_1 -1 &&& \\ -\frac{h}{2}\, p_2 -1 & 2 + h^2 q_2 & \frac{h}{2}\,p_1 -1 && \\ \vdots & \vdots & &&& \\ & - \frac{h}{2}\,p_j & 2 + h^2 q_j & \frac{h}{2}\,p_j & 0 \\ && -\frac{h}{2} \,p_{m-2} -1 & 2 + h^2 q_{m-2} & \frac{h}{2} \, p_{m-2} -1 \\ &&&-\frac{h}{2} \,p_{m-1} -1 & 2 + h^2 q_{m-1} & \frac{h}{2} \, p_{m-1} -1 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_j \\ \vdots \\ x_{m-2} \\ x_{m-1} \end{bmatrix} = \begin{bmatrix} e_0 -h^2 r_1 \\ -h^2 r_2 \\ \vdots \\ -h^2 r_j \\ \vdots \\ -h^2 r_{m-2} \\ e_m - h^2 r_{m-1} \end{bmatrix} , \]
where
\[ e_0 = \left( \frac{h}{2}\, p_1 +1 \right) \alpha \qquad\mbox{and} \qquad e_m = \left( 1- \frac{h}{2} \, p_{m-1} \right) \beta . \]

There is a special scheme, called progonka or forward elimination and back substitution (FEBS) to solve algebraic equations with tridiagonal matrices. This scheme, which is widely used in numerical simulations, was first discovered by a prominent Soviet mathematician Israel Moiseevich Gel'fand (1913--2009) in his student work. He personally never claimed his authority for the discovery because he thought it was just easy (from his point of view) application of Gauss elimination. In engineering, the FEBS method is sometimes accosiated with Llewellyn H. Thomas from Bell laboratories who used it in 1946.

Example.

 

 

Return to Mathematica page
Return to the main page (APMA0330)
Return to the Part 1 (Plotting)
Return to the Part 2 (First Order ODEs)
Return to the Part 3 (Numerical Methods)
Return to the Part 4 (Second and Higher Order ODEs)
Return to the Part 5 (Series and Recurrences)
Return to the Part 6 (Laplace Transform)
Return to the Part 7 (Boundary Value Problems)