I'm currently trying to integrate an equation using an RK4 integrator and I'm getting confused with regards to the global truncation error.
The problem consists of an integration from $t = 0$ seconds to $t = 258492$ seconds using a step-size of $2$ seconds. The question is: what would be the order of the error at the end of the integration?
I know that the global truncation error of the RK4 integration scheme is $O(h^4)$, but I'm confused as to what step-size $h$ I should use here to calculate the order of the error.
Let's first get our definitions straight, then the confusion should be almost gone.
Given an Interval $I=[t_0, t_0+T]$ and the following separation $$t_0<t_1<…<t_N=t_0+T$$ the step-size is defined as $h_n:= t_n-t_{n-1}$.
A one-step method $$u_n = u_{n-1}+h_nF(t_n,h_n;u_{n-1},u_n)$$ is called consistent of order $p$ if for the truncation error $$τ_n=h_n^{-1}(u(t_n)-u(t_{n-1}))-F(t_{n-1},h_n;u(t_{n-1}),u(t_n))$$ it holds $$\max_{t_n∈I}\|τ_n\|=\mathcal{O}(h^p),$$ for $h=\max_{1≤n≤N}h_n→0$.
If the method applied to an ODE is also stable, then it converges with order $p$. The applied method is stable, if the right hand side $f$ of the ODE $u'=f$ fulfils some Lipschitz-condition. Keep in mind, that there still might be some kind of step-size restriction.
The global truncation error $\|u(t_n) -u_n\|$ is just the accumulation of the (local) truncation error.
The important part is, that you consider $h→0$. If we are speaking about convergence, we mean convergence with respect to the step-size $h$ getting smaller.
Therefore, you can't tell if your RK method is of order $4$, if you only calculate the result for one step-size $h$.
Assuming convergence of your problem, try the following: Solve for $h_i=2^{-i}$, $i=0,1,2,...$ and calculate: $$α_i = \frac{1}{\log(2)} \log\left(\left|\frac{a(h_i)-a(h_{i+1})}{a(h_{i+1}) - a(h_{i+2})}\right|\right)$$ with $a(h) = u(t_{N})$ for stepsize $h$. You should see $α_i\approx 4$. Do a check and solve with some Euler method or Crank Nicolson.
The formula above assumes, that there exists some convergence $a(h)-a = \mathcal{O}(h^α)$.