# I don't understand how to correctly calculate truncation error

I am looking at the finite difference methods to solve simple $u_t=a(x,t)u_{xx}$.

There are explicit, implicit, Crank Nicolson.
The latter is said to be more accurate since the local truncation error is of second order provided all expansions are done around point $t^{n+0.5}$. However, local truncation error basically tells us how well the difference equation approximates the p.d.e. Thus, is I do expansion of CN scheme around any other point than I don't have second order anymore.
Question1 How I can trust the results of the scheme if there is only a single point where second order occurs?

On the other hand if I have explicit scheme, regardless around which point I do Taylor I keep having first order, so I get why it is first order but what I don't understand is:
Question2 Why is CN supposed to give global error at the point on the grid of second order when the local error of second order is estimated at the point which is not even on the mesh?

Thanks!
EDIT: Any scheme can be written as $\frac{u^{n+1}-u^n}{\tau}=L_hu^{\theta}$. So, regardless for which $\theta$ we have RHS=$u_{xx}(x_i,t^{\theta})+(h^2)...$ So it really boils down to approximation of the first derivative on the left hand side. And here we have choice. We can take $\theta=1$ and have implicit scheme with a derivative approximated at the point $t^{n+1}$, we can take the midpoint and have a derivative being approximated at that point with higher accuracy. However, the point is not on the grid! What I don't understand is that we expand around the point which is not on the grid but measure the error at the point which is on the grid and where the expansion of the difference equation gives only first order. I am confused about it.

• When you say "measure the error at the point which is on the grid and where the expansion of the difference equation gives only first order" I think you might be mistaken. Why do you claim that the expansion only gives first order? – Matthew Emmett Jun 14 '12 at 17:09
• @MatthewEmmett: because if i do Taylor around the point on the grid x_i, t^{n+1} for CN scheme i get first order in time because of approximating u_t there and second in x. When i write the fd scheme, i write a difference equation, it just a combination of points and its values, so i am supposed to say how well the difference equation approximates the pde. So implicit or explicit method approximate only with first order, if i do Taylor that holds around any point. However, for CN difference equation i see different approximation accuracy, midpoint second order and first in t at other points. – Kamil Jun 15 '12 at 0:17

I will simplify and take $a$ to be constant. We know that the scheme can be written \begin{eqnarray*} u_{i}^{n+1} & = & u_{i}^{n}+\frac{a\Delta t}{2}\left(F_{i}^{n+1}+F_{i}^{n}\right)\\ F_{i}^{k} & \approx & u_{xx}\left(x_{i},t_{k}\right) \end{eqnarray*} assuming that we can approximate $u_{xx}$ to high enough order (which is probably done using the usual three point discretization). We want to find $\left|u\left(x_{i},t_{n+1}\right)-u_{i}^{n+1}\right|$. We Taylor expand about a point on the grid \begin{eqnarray*} u\left(x_{i},t_{n+1}\right) & = & u_{i}^{n}+\Delta t\frac{\partial u}{\partial t}+\frac{\Delta t^{2}}{2}\frac{\partial^{2}u}{\partial t^{2}}+\frac{\Delta t^{2}}{6}\frac{\partial^{3}u}{\partial t^{3}}+\cdots\\ F\left(x_{i},t_{n+1}\right) & = & F_{i}^{n}+\Delta t\frac{\partial F}{\partial t}+\frac{\Delta t^{2}}{2}\frac{\partial^{2}F}{\partial t^{2}}+\frac{\Delta t^{2}}{6}\frac{\partial^{3}F}{\partial t^{3}}+\cdots \end{eqnarray*} then \begin{eqnarray*} u\left(x_{i},t_{n+1}\right)-u_{i}^{n+1} & = & u_{i}^{n}+\Delta t\frac{\partial u}{\partial t}+\frac{\Delta t^{2}}{2}\frac{\partial^{2}u}{\partial t^{2}}+\frac{\Delta t^{2}}{6}\frac{\partial^{3}u}{\partial t^{3}}+\cdots\\ & & -u_{i}^{n}+\frac{a\Delta t}{2}\left(2F_{i}^{n}+\Delta t\frac{\partial F}{\partial t}+\frac{\Delta t^{2}}{2}\frac{\partial^{2}F}{\partial t^{2}}+\frac{\Delta t^{2}}{6}\frac{\partial^{3}F}{\partial t^{3}}+\cdots\right)\\ & = & \Delta t\left[u_{t}+au_{xx}\right]_{i}^{n}+\frac{\Delta t^{2}}{2}\frac{\partial^{2}u}{\partial t^{2}}+\frac{\Delta t^{2}}{6}\frac{\partial^{3}u}{\partial t^{3}}+\cdots\\ & & +\frac{a\Delta t}{2}\left(\Delta t\frac{\partial F}{\partial t}+\frac{\Delta t^{2}}{2}\frac{\partial^{2}F}{\partial t^{2}}+\frac{\Delta t^{2}}{6}\frac{\partial^{3}F}{\partial t^{3}}+\cdots\right) \end{eqnarray*} So we have the $u_t + au_{xx}$ term which is of order $\Delta t^2$ since it is the PDE at the previous iteration and the other terms have $\Delta t^2$ at least.
• thanks for your answer. I see second order at any point. However, if I take $a=a(x,t)$ then I am supposed to have a scheme:$$u_{i}^{n+1} = u_{i}^{n}+\frac{a_i(t_{n+1/2})\Delta t}{2}\left(F_{i}^{n+1}+F_{i}^{n}\right)$$ which doesn't affect much of what is written as we can do Taylor and see that $a_i(t_{n+1/2}=a_i(t_{n}+dt/2a_t(t_n))$. But then I could take the scheme any value $\bar{t}$ of $a_i(\bar{t})$ in the scheme and still would have second order? Where does the affect of the time dependent coefficient shows up and why it is insisted to be estimated at the middle point? – Kamil Jun 15 '12 at 15:18
• I think a better way to implement is to let $F_i^k \approx a u_{xx}$ which leads to using $a_i^{n+1}$ and $a_i^n$. That is analogous to how I solve an elliptic problem using cell-centered finite differences (which through some magic are equivalent to finite elements). Then if $a_i^{n+1/2}$ is close enough to both of those then you will get the right order. The algebra in the analysis is a little easier if you use the midpoint. Either way, the analysis depends on the smoothness of $a$ or $a u_{xx}$. – Ken Jun 15 '12 at 23:28
• To Ken:actually, what you have computed is the global error, that is how to values are different(the actual and the numerical solution). What I am still having trouble with is the "local truncation error", that is if I plug the actual function into finite differences and see the remainder. Doesn't seem to be second order in time if the expansion is done around the same point $t_n$. However it is if Taylor is done in the midpoint I do have second order in time! – Kamil Jun 19 '12 at 20:51
• Am I wrong, or if we used a backward Euler method $$u_{i}^{n+1}=u_{i}^{n}+a\Delta t\ F_{i}^{n+1}$$ by using your expansion and reasoning we would have the same exact result, while we know that backward Euler is first order accurate. What am I missing? – Millemila Jul 21 '15 at 10:44