a) A second-order Runge-Kutta method, also known has Heun’s method, is derived in Sect. 8.4.5. Make a function ode_Heun(f, U_0, dt, T) (as a counterpart to ode_FE(f, U_0, dt, T) in ode_FE.py) for solving a scalar ODE problem u
= f (u, t), u(0) = U0, t ∈ (0, T ], with this method using a time step size Δt.
b) Solve the simple ODE problem u
= u, u(0) = 1, by the ode_Heun and the ode_FE function. Make a plot that compares Heun’s method and the Forward Euler method with the exact solution u(t) = et for t ∈ [0, 6]. Use a time step Δt = 0.5.
c) For the case in b), find through experimentation the largest value of Δt where the exact solution and the numerical solution by Heun’s method cannot be distinguished visually. It is of interest to see how far off the curve the Forward Euler method is when Heun’s method can be regarded as “exact” (for visual purposes).