I have implemented an Adams Bashforth 4 method to solve an Initial Value Problem for an ODE and I am testing it against the test equation:

$y'=\lambda y$ with $y(0)=1$ with the exact solution: $y(t)=e^{\lambda t}$. I have set $\lambda =1$.

I get decent results and decent rate of convergence because the loglog plot is linear with slope of 4 (AD4 is of order 4 so the error is $O(h^4)$). Here is the global error when I am testing it in the interval $t \in [0,3]$ enter image description here

Is this consistent with theory? Also, where will you plot the $O(h^4)-$line in this graph? I know it needs to be parallel to the AD4 line but where? In general, I don't really know the connection between the global error and $O(h^4)$

Here is my data

h        = ( 0.1, 0.05, 0.01, 0.005)
ad4error = (3.477e-03, 2.493e-04, 4.445e-07, 2.816e-08)  
  • $\begingroup$ "I'm a self-learner so I don't read books." proceeds to post question on SE. Not making fun of you but I found this amusing! $\endgroup$ Mar 6, 2019 at 6:36
  • $\begingroup$ There is no substitute for books. Writing books requires a massive effort and forces the author to review, revise and extend her presentation of all subjects and how they interact. Order books through your public library $\endgroup$ Mar 6, 2019 at 8:31
  • $\begingroup$ You want to use a slope triangle and to position it close to the curve representing our actual data. This way you will be able to show the order of growth of the error in a compact and easily comprehensible manner. $\endgroup$
    – Nox
    Mar 6, 2019 at 16:31

1 Answer 1


I'm going to turn my comment into an answer.

The error order tells you up to which order (exclusive) the discrete solution corresponds to the exact solution.

An $\mathcal{O}(\Delta t^4)$ method reproduces the orders 0-3 of the Taylor expansion of the function around $\Delta t$ (i.e. in the expression $f(t+\Delta t) = f(t) +\dots$).

Put bluntly (and mathematically imprecisely) if you halve the size of the time step $\Delta t$ the deviation will be smaller by $2^4$. This, of course, assumes that the error is computed at the same final time. Or, if you want to use the log-log plot effectively you can say that by reducing the step size by one order of magnitude $\Delta t = 10^{-1} \rightarrow \Delta t = 10^{-2}$ the deviation from the analytic solution will be reduced by 4 orders of magnitude, i.e., instead of $10^{-2}$ it will be $10^{-6}$.

To visualize the growth of an error one could plot curves of different orders ($\Delta t^2, \Delta t^3$ etc.) and try and compare the result to these curves. This is very finnicky in a log-log plot and results in a rather confusing plot. A better way is to define a function that will draw a slope triangle with appropriately labelled sides close to the curve(s) you want to show the behaviour of.

I have used this in the analysis of the implementation of $\mathcal{P}_2,\mathcal{P}_3$ finite elements in my thesis, as can be seen in the following plot.

Finite element errors for a Poisson equation on a rectangle, using different FE orders.

Note that this plot would be really confusing if I were to add an entire curve for each growth order. Admittedly, the slope triangles could have been placed better, but they do show the growth order (one power of $2$ of mesh width corresponds to $n$ powers of $10$ on the error axis).

  • $\begingroup$ To be honest your excellent answer is way beyond what I am asking for. I don't have the theoritical knowledge to follow you 100%. The global error for a method of order $p$ is bounded such that $|E_N|\ \leq Ch^p$. I am basically asking how to find that $C$ constant and plot the line on the graph shown in my post $\endgroup$
    – k.dkhk
    Mar 7, 2019 at 16:34
  • 1
    $\begingroup$ If you want an empirical constant just divide the computed error for a given step-size by the step-size and take the maximum of the results, e.g. $max_i\lbrace \frac{|E(h_i)|}{h_i}\rbrace$. To plot a simple line (I advise against that) is then to simply generate $y_i = C\cdot h_i$ with the constant you obtained and the step-sizes $h_i$ and then plot it against $h_i$. $\endgroup$
    – Nox
    Mar 7, 2019 at 16:45
  • $\begingroup$ Let's I find $C$ the way you have described here. Then I use this method/solver on a NEW IV problem, let's say: $y'=y*sin(t)$ and I find values for $y$ for a given $h$. Is it hen fair to say that my error is bounded such that is is $Ch^4$ at the most? I might not have been clear with my question but that is basically what I try estimate with the $O(h^p)$ error as I described. Thank you very much for your help so far by the way $\endgroup$
    – k.dkhk
    Mar 7, 2019 at 20:07
  • $\begingroup$ The constant is implicitly dependent upon the equation. For each problem you'll find a different constant. But once you've found a constant for a particular equation then the estimate will likely be true for that specific equation. $\endgroup$
    – Nox
    Mar 11, 2019 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.