Note
Go to the end to download the full example code
Convergence analysis of explicit Runge-Kutta methods for ODE IVP#
Evaluation of relative quadrature error with the following parameters:
eq_names = [
"y'' = -y" ,
"y'' = - exp(y)" ,
"y'' = xy" ,
"y' = Az; z' = By" ,
]
all_methods = { name : getattr(precomputed_tables,name) for name in dir(precomputed_tables) if isinstance(getattr(precomputed_tables,name),choreo.scipy_plus.ODE.ExplicitSymplecticRKTable) }
method_order_hierarchy = {}
for name, rk in all_methods.items():
order = rk.th_cvg_rate
cur_same_order = method_order_hierarchy.get(order, {})
cur_same_order[name] = rk
method_order_hierarchy[order] = cur_same_order
sorted_method_order = sorted(method_order_hierarchy)
The following plots give the measured relative error as a function of the number of quadrature subintervals
plt.show()
The following plots give the measured convergence rate as a function of the number of quadrature subintervals. The dotted lines are theoretical convergence rates.
plt.show()
We can see 3 distinct phases on these plots:
A first pre-convergence phase, where the convergence rate is growing towards its theoretical value. the end of the pre-convergence phase occurs for a number of sub-intervals roughtly independant of the convergence order of the quadrature method.
A steady convergence phase where the convergence remains close to the theoretical value
A final phase, where the relative error stagnates arround 1e-15. The value of the integral is computed with maximal accuracy given floating point precision. The approximation of the convergence rate is dominated by seemingly random floating point errors.
Error as a function of running time
plt.show()
Error as a function of running time for different orders
plt.show()
Total running time of the script: (0 minutes 26.444 seconds)