1
10.4 Consider the following first-order ODE:
from to with
(a) Solve with Euler’s explicit method using .
(b) Solve with the modified Euler method using .
(c) Solve with the classical third-order Runge–Kutta method using .
The analytical solution of the ODE is . In each part, calculate the error between the true
solution and the numerical solution at the points where the numerical solution is determined.
Solution
(a) The following script file solves the ODE with Euler’s explicit method using .
% 3ed Chapter 10 Problem 4 Part (a)
% Solving the ODE with Euler’s explicit method.
When the program is executed, the following results are displayed in the Command Window:
t =
2 3 4 5