Exercise: numerical order estimation (Euler, Heun, RK4)

On the same logistic IVP, Euler's order is estimated with the exact solution, Heun's by comparing successive meshes without an exact solution, and RK4's, confirming orders 1, 2 and 4.

The reference problem

The logistic (Verhulst) IVP y(t)=(30.1y)yy'(t)=(3-0.1\,y)\,y on [0,2][0,2] with y(0)=10y(0)=10 is used; its exact solution is known and allows measuring true errors:

y(t)=301+2e3ty(t)=\frac{30}{1+2e^{-3t}}

Each method is run with N={2,4,8,16,32,64}N=\{2,4,8,16,32,64\} subintervals and the logarithmic ratio from Convergence, consistency and order is applied to the maximum errors.

Euler, with the exact solution

NMaximum error ENE_Nlog2(EN/2/EN)\log_2(E_{N/2}/E_N)
22.7167n/a
42.71670.0000
81.06591.3497
160.48781.1277
320.23611.0467
640.11641.0202
Euler errors against the exact solution.

Heun, without the exact solution

To illustrate the technique that needs no exact solution, with Heun each discrete solution is compared with the double-mesh one at the common nodes, εN=maxkyk(N)y2k(2N)\varepsilon_N=\max_k|y^{(N)}_k-y^{(2N)}_{2k}|:

NεN\varepsilon_Nlog2(εN/2/εN)\log_2(\varepsilon_{N/2}/\varepsilon_N)
418.2934n/a
81.93193.2432
160.32882.5549
320.06862.2603
640.01582.1154
Differences between successive meshes with Heun.

Runge-Kutta 4

NMaximum error ENE_Nlog2(EN/2/EN)\log_2(E_{N/2}/E_N)
24.7316n/a
40.14425.0362
86.531·10⁻³4.4646
163.469·10⁻⁴4.2347
321.992·10⁻⁵4.1223
641.192·10⁻⁶4.0624
RK4 errors against the exact solution.