I have an FFT code that solves a particular case of the steady Euler equations where a Poisson equation is solved, what is a good way to quantify the error? Is what I am doing ok?

Since I do not have an analytic solution to compare with what I have done is I have computed the solution on a very fine grid and then computed the error as such:

Let $x_f$ be the fine solution and $x_i$ the solution for coarser grids, the error for each grid $i$ is:

$error_i = \frac{\|x_f-x_i\|}{\|x_f\|}$

I then plot the error in a loglog plot as a function of number of grid points N.

error vs total number of grid points

The slope ratio is 1 to 1, so would it mean the scheme is 1st order accurate?

I also have the residual given by $res = \|LHS-RSH\|$ where the terms represent the left hand side minus the right hand side of the equation and have performed a similar plot, I am not sure what is the best way to interpret it though. Any help or input would be appreciated.

Norm of Residual vs total number of grid points


1 Answer 1


Here is a general procedure to do such error plots that I usually follow:

  1. Find such $N$ so that the solution is converged.

  2. Plot the error (for example $\frac{\|x_f-x_i\|}{\|x_f\|}$ as you did). You can use log-log plot (polynomial convergence will be a line) or log-linear plot (exponential convergence will be a line).

  3. Optionally, plot the expected convergence rate --- in your case plot the function $c N^{-1}$, where $c$ is a constant that you adjust so that this function agrees with your convergence graph for the smallest $N$ shown. If the two lines agree on your graph, then you have a first order convergence. It will be apparent from the graph once you plot it. Use $cN^{-2}$ for quadratic convergence and so on.

Note about the error formula: Sometimes you can plot some value (for example an energy $E$ in the Schroedinger equation) that converges to the exact value as you increase $N$. In that case, you can just plot $E-E_{conv}$, where you determine $E_{conv}$ from the step 1.

  • $\begingroup$ Thanks for your answer, I just added a plot with the residual, do you have any comments regarding that part of the question? $\endgroup$ Commented Apr 22, 2013 at 20:50
  • $\begingroup$ There I would plot $N^{-3}$ into the same graph, if you suspect third order convergence. I don't know what exactly LHS and RHS is, you would have to show the exact equations/definitions how to calculate the quantities. Is this the residual from the linear solver? $\endgroup$ Commented Apr 22, 2013 at 21:37
  • $\begingroup$ yes it is the residual from the solver, so essentially, given the final solution I plug it into the governing equation and compute the difference between the Left and Right hand sides of the equation. $\endgroup$ Commented Apr 22, 2013 at 23:08
  • $\begingroup$ Both plots are meaningful. Each of them says exactly what is depicted: the error in some measure reduces as resolution increases. There are just many ways to represent error. You have two ways and Ondřej suggests a third. Your first plot is what many people are expecting to see in numerical methods, mostly since for some methods/equations these rates can be theoretically derived. Thus your the convergence of your method can be compared to other methods. $\endgroup$ Commented Apr 22, 2013 at 23:42

Your Answer

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

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