Examples and Problems
Problem 1
One way to better understand how the different numerical methods work is to create a table for a series of steps to see how they evolve. Two examples are provided here in the form of Excel files.
Example 1:
\[\frac{dy}{dt} = y\]
\[y_{0} = 1\]
\[0 \leq t \leq 4\]
The exact solution is, \(y(t) = e^{t}\).
Download example 1 Excel file.
Example 2:
\[\frac{dy}{dt} = t + y\]
\[y_{0} = 0\]
\[0 \leq t \leq 4\]
The exact solution is, \(y(t) = e^{t} - \ t - 1\).
Download example 2 Excel file.
Problem 1:
Using these Excel files as templates, solve the following problem using the forward Euler, modified Euler and Runge-Kutta 4th order methods.
\[f(t,y) = ty + t^{3}\]
\[y_{0} = 1\ \]
\[0 \leq t \leq 4\]
The exact solution is, \(y\left( t \right) = 3e^{{(t}^{2} / 2)} - t^{2} - 2\).
Problem 2
Solve Problem 1 using Python. Right click the links to download two JupyterLab files (example 1 and example 2). These files solve the two example problems given in Problem 1 and can be used as templates to solve the problem. The files can be run using Google Colab. Upload the files into Colab by selecting ‘File>Upload notebook’.
Problem 3
For the differential equation described in Problem 1 show that the forward Euler, modified Euler and Runge-Kutta methods are 1st, 2nd and 4th order methods respectively by graphing the errors. Solve the differential equation over the range \(0 \leq t \leq 4\) for \(\mathrm{\Delta}t\) = 1.0, 0.1, 0.01, 0.001 and 0.0001. Determine the difference between the estimated value and the exact solution at \(t = 4\) and plot on a log-log plot. For very small steps, \(\mathrm{\Delta}t < 0.0001\), truncation errors within Python may produce inaccurate results. At large steps the errors may deviate from a straight line on the log-log plot. Fit the error values over the linear range.
Problem 4
Demonstrate the superior stability of an implicit method compared to the equivalent explicit method by solving the following stiff equation using both the forward and backward Euler methods.
\[\frac{dy}{dt} = 10(1 - y)\]
\[y_{0} = 0.5\]
\[0 \leq t \leq 4\]
The explicit solution is \(y = {1 - \ e}^{- 10t}/2\). Show what happens when the step size increases from \(\mathrm{\Delta}t\) = 0.1, starting with \(\mathrm{\Delta}t\) = 0.2.