Rate of convergence with matlab I am supposed to determine the order of convergence of Heun's method just by evaluating $ y'(t)=\lambda y(t)$ for several $\lambda$, several step sizes and several number of grid points. 
I already read that it is 2, but I do not know what I need to plot or which expression I need to evaluate in order to see this? 
 A: Say you want to run your algorithm to time $T$. Assume with time step $h$ it takes $N$ steps, and thus with time step $h/2$ it will take $2N$ steps. This was hinted at above, but assuming at the outset (with $h$ the space step and $p$ the order of the method) that 
$$
e_{n, h} = Ah^p \Rightarrow \quad e_{2n, h/2} = A \left( \frac{h}{2} \right)^p
$$
and dividing gives 
$$
\frac{e_n,h}{e_{2n, h/2}} = 2^p.
$$
Thus, taking the log base two of this value gives that 
$$
p = \log_2 \left( \frac{e_n,h}{e_{2n, h/2}} \right)
$$
Taking a sequence of different steps and plotting the ratio will gives a clearer idea of this value of $p$, since for various reasons it will not be exact for every (h, N) pair. 
A: Obtain the exact solution $z(t)$.
The local error of an approximation scheme is the error after one step. Compute the error $e(h)$ of a single step at various step sizes from a particular point. A method is said to be $n$th order if $e(h)= A h^n +o(h^n)$ for some constant $A$.
How could you work out what $n$ should be given $e(h)\approx A h^n$? Hint : Taking logarithms might help.
