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 on with is used; its exact solution is known and allows measuring true errors:
Each method is run with subintervals and the logarithmic ratio from Convergence, consistency and order is applied to the maximum errors.
Euler, with the exact solution
| N | Maximum error | |
|---|---|---|
| 2 | 2.7167 | n/a |
| 4 | 2.7167 | 0.0000 |
| 8 | 1.0659 | 1.3497 |
| 16 | 0.4878 | 1.1277 |
| 32 | 0.2361 | 1.0467 |
| 64 | 0.1164 | 1.0202 |
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 | ||
|---|---|---|
| 4 | 18.2934 | n/a |
| 8 | 1.9319 | 3.2432 |
| 16 | 0.3288 | 2.5549 |
| 32 | 0.0686 | 2.2603 |
| 64 | 0.0158 | 2.1154 |
Runge-Kutta 4
| N | Maximum error | |
|---|---|---|
| 2 | 4.7316 | n/a |
| 4 | 0.1442 | 5.0362 |
| 8 | 6.531·10⁻³ | 4.4646 |
| 16 | 3.469·10⁻⁴ | 4.2347 |
| 32 | 1.992·10⁻⁵ | 4.1223 |
| 64 | 1.192·10⁻⁶ | 4.0624 |