Preface


This tutorial was made solely for the purpose of education and it was designed for students taking Applied Math 0340. It is primarily for students who have some experience using Mathematica. If you have never used Mathematica before and would like to learn more of the basics for this computer algebra system, it is strongly recommended looking at the APMA 0330 tutorial. As a friendly reminder, don't forget to clear variables in use and/or the kernel. The Mathematica commands in this tutorial are all written in bold black font, while Mathematica output is in regular fonts.

Finally, you can copy and paste all commands into your Mathematica notebook, change the parameters, and run them because the tutorial is under the terms of the GNU General Public License (GPL). You, as the user, are free to use the scripts for your needs to learn the Mathematica program, and have the right to distribute this tutorial and refer to this tutorial as long as this tutorial is accredited appropriately. The tutorial accompanies the textbook Applied Differential Equations. The Primary Course by Vladimir Dobrushkin, CRC Press, 2015; http://www.crcpress.com/product/isbn/9781439851043

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 first course APMA0330
Return to the main page for the second course APMA0340
Return to Part IV of the course APMA0340
Introduction to Linear Algebra

Finite Difference Methods

In this section, we extend Euler methods to systems of differential equations. It is a custom to denote by t the independent variable that we associate with time. Then denoting the derivatives by dots, we illustrate the concepts by considering the iniiytal value problem

\[ \begin{cases} \dot{x} &= f(t, x, y) , \\ \dot{y} &= g(t,x,y) , \end{cases} \qquad\mbox{subject to }\qquad \begin{cases} x(t_0 ) = x_0 , \\ y(t_0 ) = y_0 . \end{cases} \]
Here f and g are given functions and t0, x0, and y0 are specified points. Using vectors, we can rewrite the initial value problem in compact form:
\[ \dot{\bf x} = {\bf f} (t,{\bf x}) , \qquad {\bf x} (t_0 ) = {\bf x}_0 , \]
where
\[ {\bf x}(t) = \begin{bmatrix} x(t) \\ y(t) \end{bmatrix} , \qquad {\bf f}(t, {\bf x}) = \begin{bmatrix} f(t,x,y) \\ g(t,x,y) \end{bmatrix} , \qquad {\bf x}_0 = \begin{bmatrix} x_0 \\ y_0 \end{bmatrix} . \]
A solution to the above problem is a pair of differentiable functions x(t) and y(t) with the property that when x(t) and y(t) are substituted in f(t,x,y) and g(t,x,y), the result is equal to the derivative \( \dot{x} \) and \( \dot{y} , \) respectively.

A numerical solution to the given system over the interval \( a \le t \le b \) is found by considering the differentials

\[ {\text d}x = f(t,x,y)\,{\text d}t \qquad\mbox{and}\qquad {\text d}y = g(t,x,y)\,{\text d}t \]
Euler's method for solving the system is obtained by substituting approximations to the differential dt = tk+1 - tk,    dx = xk+1 - xk,   , and   dy = yk+1 - yk into definition of the differential to get
\[ \begin{split} x_{k+1} - x_k &= f(t_k , x_k , y_k ) , \\ y_{k+1} - y_k &= g(t_k , x_k , y_k ) . \end{split} \]
The interval is divided into m subintervals of width \( h = (b-a)/m , \) and the mesh points become \( t_{k+1} = t_k +h . \) This is used to get the recursive formulas for Euler's rule:
\[ \begin{split} t_{k+1} &= t_k +h , \\ x_{k+1} &= x_k + h \,f(t_k , x_k , y_k ) , \\ y_{k+1} &= y_k + h \,g(t_k , x_k , y_k ) , \qquad \mbox{for}\quad k=0,1,2,\ldots , m-1. \end{split} \]

Example: Consider the initial ■

  1. Christiansen G., American Journal of Physics, 1978, Vol. 46, pp. 748
  2. Cromer A., Stable solutions using the Euler approximation, American Journal of Physics, 1981, Vol. 49, pp. 455 https://doi.org/10.1119/1.12478
  3. Stanley, R.W., Numerical methods in mechanics, American Journal of Physics, 1984, Vol. 52, pp. 499--507.

 

Return to Mathematica page

Return to the main page (APMA0340)
Return to the Part 1 Matrix Algebra
Return to the Part 2 Linear Systems of Ordinary Differential Equations
Return to the Part 3 Non-linear Systems of Ordinary Differential Equations
Return to the Part 4 Numerical Methods
Return to the Part 5 Fourier Series
Return to the Part 6 Partial Differential Equations
Return to the Part 7 Special Functions