# How can I quantify the error of FFT-based poisson solvers?

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. 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. 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.

• Thanks for your answer, I just added a plot with the residual, do you have any comments regarding that part of the question? – Isopycnal Oscillation Apr 22 '13 at 20:50
• 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? – Ondřej Čertík Apr 22 '13 at 21:37
• 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. – Isopycnal Oscillation Apr 22 '13 at 23:08
• 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. – Nathan Collier Apr 22 '13 at 23:42