# Accuracy of finite differences

I'm currently reading this paper, and I'm a bit confused about how they compute the accuracy of their algorithm.

In the aforementioned paper, they investigate the regularized long-wave equation: $$u_t + u_x + u u_x - u_{xxt} = 0 \tag{1}$$ They discretize the grid by spacing $h$ and time step $\tau$, giving the grid point $(ih,m \tau)$, where $i=0,1,2,\ldots$ and $m=0,1,2,\ldots$. For brevity, they use the notation: $u_i{}^m \equiv u(ih,m \tau)$. Furthermore, they introduce the well-known finite difference operators: $$\delta_x{}^2 w_i{}^m = \frac{w_{i+1}^m - 2w_i{}^m + w_{i-1}^m}{h^2}$$ $$H_x w_i{}^m = \frac{w_{i+1}^m - w_{i-1}^m}{2h}$$ $$\Delta_t w_i{}^m = \frac{w_i^{m+1} - w_i{}^m}{\tau}$$ Then they discuss the following scheme to solve equation (1): $$\Delta_t (1- \delta_x{}^2) w_i{}^m + \frac{1}{2}H_x(w_i{}^{m+1} + w_i{}^{m}) + \frac{1}{2} w_i{}^m H_x(w_i{}^{m+1} + w_i{}^{m}) = 0 \tag{2}$$ Up until here I understand everything, but then they go on and discuss the accuracy of this scheme:

To find the order of accuracy of the scheme, $w$ is replaced by $u$ in equation (2), where $u$ is a solution of equation (1) [...] Thus expanding all the terms about $(i,m+\frac{1}{2})$ shows that the first term approximates $u_t |_i^{m+(1/2)}$ and $u_{xxt}|_i^{m+(1/2)}$ with errors involving $\tau^2$ and $h^2$.

I don't really understand what the authors are doing here. I don't know what they mean with expanding the terms about $(i,m+\frac{1}{2})$.

The way I learned this is that, for instance, the term $\Delta_t w_i{}^m$ is using a forward difference approximation, and so the truncation error will be $O(\Delta t)$. Can anyone explain what they are doing, or give me a link to some note or books that explain what they are doing?

I think you probably already know all this, and maybe it's just the wording that is confusing. I'm going to rephrase what they're doing to make it more explicit. It's exactly the same calculation of truncation errors that you are already familiar with.

When approximating an operator $\mathcal{L}$ with an FD operator $L\approx \mathcal{L}$, the truncation error is the operator $E$ in $Lv = \mathcal{L}v + Ev$. If you're solving $\mathcal{L}u=0$, then the approximation $Lu=0$ corresponds to an exact solution of $\mathcal{L}u = -Eu$, with global error given by $\mathcal{L}^{-1}Eu$.

When they replace the $w$ in the FD formula with an exact solution $u$ of $\mathcal{L}u=0$, they are applying the FD operator $L$ to an exact solution $u$ to get $Lu = \mathcal{L}u + Eu = Eu$ ($\mathcal{L}u=0$). Thus they get the truncation error $Eu$. Technically this is slightly different from applying $L$ to an arbitrary function because the assumption $\mathcal{L}u=0$ may be used in calculating $Eu$, but this is irrelevant when solving a homogeneous equation $\mathcal{L}u=0$ with a zero r.h.s.

When they say they expand about $(i,m+\frac12)$, they are trying to evaluate $Eu$ in closed form by expanding $Lu$ in Taylor series. Consider the simpler case: $$\Delta_t u(ih,m\tau) = u_t(ih,m\tau) + \tfrac12 h u_{tt}(ih,m\tau),$$ but $$\Delta_t u(ih,m\tau) = u_t(ih,(m+\tfrac12)\tau) + \tfrac1{12} h^2 u_{ttt}(ih, (m+\tfrac12)\tau).$$ Both of these truncation errors are correct, despite having different orders.

When they expand about $(ih,(m+\tfrac12)\tau)$, they are computing the expansion $$Lu(ih,m\tau) = \mathcal{L}u(ih,(m+\tfrac12)\tau) + Eu(ih,(m+\tfrac12)\tau).$$ Since $u$ is an exact solution of $\mathcal{L}u=0$, $\mathcal{L}u$ vanishes at all points, including in between grid points, at $(i, m+\tfrac12)$. This only means that the truncation error $Eu$ in the approximate equation $Lu=0$, or $\mathcal{L}u=-Eu$, is evaluated slightly to the side of the grid points, which would not significantly affect the global error $\mathcal{L}^{-1}Eu$.

What would happen had they expanded around $(i,m)$ instead, as you mentioned about $\Delta_t$? Then they would have gotten the expansion (compare with $\Delta_t$ above) $$Lu(ih,m\tau) = \mathcal{L}u(ih,m\tau) + E_1 u(ih,m\tau),$$ where $E_1 = O(h)$ is of a lower order than $E = O(h^2)$. Both truncation errors are correct. This is because $E_1$ is too pessimistic for this specific case of $u$ being a solution of $\mathcal{L}u=0$, and it is still technically correct as any function that is $O(h^2)$ is also $O(h)$. The difference between $E_1$ and $E$ is $$\mathcal{L}u^{m+1/2} - \mathcal{L}u^{m},$$ which would indeed be $O(h)$ for an arbitrary function $u$, but which vanishes for a solution $\mathcal{L}u=0$. If you write out $E_1$ in full, and apply $\mathcal{L}u=0$, you should eventually get $O(h^2)$ too.

I'm not sure what book to recommend, but LeVeque's Finite Difference Methods I think is quite good. What they are doing is quite conventional, so dicussed in basically any book on FD methods.