2.8. Explicit Runge-Kutta Methods Exercises#

Answer the following exercises based on the content from this chapter. The solutions can be found in the appendices.

Exercise 2.1

Write the following Runge-Kutta method in a Butcher tableau.

\[\begin{align*} y_{n+1} &=y_n +\frac{h}{6}(k_1 +4k_3 +k_4 ),\\ k_1 &=f(t_n ,y_n ),\\ k_2 &=f(t_n +\frac{1}{4}h,y_n +\frac{1}{4}hk_1 ),\\ k_3 &=f(t_n +\frac{1}{2}h,y_n +\frac{1}{2}hk_2 ),\\ k_4 &=f(t_n +h,y_n +h(k_1 -2k_2 +2k_3 )). \end{align*}\]

Exercise 2.2

Write out the equations for the following Runge-Kutta method.

\[\begin{align*}\begin{array}{c|cccc} 0 & & & & \\ 1/4 & 1/4 & & & \\ 1/2 & -1/2 & 1 & & \\ 1 & 1/4 & 0 & 3/4 & \\ \hline & 0 & 4/9 & 1/3 & 2/9 \end{array}\end{align*}\]

Exercise 2.3

Derive an explicit second-order Runge-Kutta method where \(b_1 =\frac{1}{3}\).

Exercise 2.4

Determine the order, elementary weight and density of this rooted tree.

../_images/rooted_tree_exercise.svg

Exercise 2.5

Derive the order conditions for a third-order explicit Runge-Kutta method.

Exercise 2.6

Derive an explicit fourth-order Runge-Kutta method where \(c_2 = \frac{1}{4}\), \(c_3 = \frac{1}{2}\) and \(c_4 = 1\). (Hint: you might not need all of the row-sum conditions to get a solution).

Exercise 2.7

Using pen and paper, apply your Runge-Kutta method derived in Exercise 2.3 to solve the following initial value problem using a step length of \(h=0.4\)

\[\begin{align*} y' =t-y, \qquad t\in [0,2],\qquad y(0)=1 \end{align*}\]

Write your solutions correct to 4 decimal places.

Exercise 2.8

Define a Python or MATLAB function called myrk2() which uses the method from derived in Exercise 2.3 to compute the solution over a single step. Use your function along with the solveIVP() function to solve the initial value problem from Exercise 2.7. Present your solution in a table and as a plot of the numerical solutions against the exact solutions on the same set of axes.

Exercise 2.9

A third-order explicit Runge-Kutta method has the Butcher tableau

\[\begin{split} \begin{array}{c|ccc} 0 & 0 \\ 1/2 & 1/2 \\ 1 & -1 & 2 \\ \hline & 1/6 & 2/3 & 1/6 \end{array} \end{split}\]

Define two Python or MATLAB functions called myrk3() and myrk4() which uses this third-order method and the fourth-order method derived Exercise 2.6 to solve an initial value problem. Use your functions, along with your code from Exercise 2.8, to solve the initial value problem in Exercise 2.7. Present your solutions as a plot of the numerical solutions against the exact solution on the same set of axes.

Exercise 2.10

Use your functions myrk2(), myrk3() and myrk4() from Exercise 2.8 and Exercise 2.9 to solve the initial value problem from Exercise 2.7 using a range of step lengths starting at \(h=0.4\) and halving each time until \(h=0.025\). Plot the global truncation errors for the numerical solutions for the solution at \(t=2\) against \(h\) on a loglog scale and estimate the order of the three methods.

Exercise 2.11

Combining Heun’s method and Kutta’s third-order method gives the following Butcher tableau for an embedded Runge-Kutta method

\[\begin{split} \begin{array}{c|ccc} 0 & \\ 1/2 & 1/2 \\ 1 & -1 & 2 \\ \hline & 1/6 & 2/3 & 1/6 \\ & 0 & 1 & 0 \end{array}\end{split}\]

where the first row of the \(b\) coefficients gives the third-order accurate solution and the second row gives the second-order accurate solution. Define a function called rk23() that calculates the second and third order solutions over a single step and, along with the solveIVP_SSC() function from the section on adaptive stepsize control, use it to solve the initial value problem from Exercise 2.7 using an initial step length of \(h_0=0.4\) and an accuracy tolerance of \(tol = 10^{-4}\). How many successful steps and failed steps were used?