# discretization error for the explicit scheme for heat equation

I am a little confused about the truncation error and what it actually means. So, For example I have an explicit approximation to the heat equation $$\frac{u_{j}^{i+1}-u_{j}^{i}}{\delta t}=\frac{u_{j-1}^{i}-2u_{j}^{i}+u_{j+1}^{i}}{\delta x^2}$$ Now, I pick a point $(x_j,t_i)$ and do the Taylor approximation of each grid node function in the above equation. Then I choose $(x_j,t_{i+1})$ and do the same exercise and local truncation error is exactly the same. Intuitively, I would expect the local disretization(or truncation) error be a little larger in the second case because the second $x$ derivative is approximated with a distance $\delta t$ but it is not. So does it mean that since this scheme involves 4 grid nodes, if I pick any of them and do that Taylor expansion I will get exact same local error? Perhaps I am confused what is the meaning of the local truncation error in FDM.

local truncation error arises when we neglect higher order terms which are assumed to be of negligible effect -- but then again the threshold is set depending on the task at hand. As for your question, you have a heat equation in 1D (a very typical parabolic PDE) that you intend to solve via finite differences. $$u_t = u_{xx}$$ What you decided to use to approximate the above Partial Differential Equation is a typical forward (Euler) in time central in space scheme (FTCS). So in other words, you did the following: $$u_t \approx \frac{u_i^{n+1}-u_i^n}{\delta t}$$ $$u_{xx} \approx \frac{u_{i-1}^n-2u_i^{n}+u_{i+1}^n}{\delta x^2}$$

Next is an accuracy investigation. To accomplish this we Taylor expand each of the terms excluding about which we expand -- in our case to facilitate our work, let's go for $u_i^n \approx u(x,t)$ .

$$\frac{\partial u}{\partial t} \Bigg |_x \approx u(t+\delta t) = u(t) + u'(t)\delta t + \frac{1}{2}u''(t)\delta t^2 + \frac{1}{6}u'''(t)\delta t^3 + \mathcal{O}(\delta t^4)$$

$$\frac{\partial u}{\partial x} \Bigg |_t \approx u(x+\delta x) = u(x) + u'(x)\delta x + \frac{1}{2}u''(x)\delta x^2 + \frac{1}{6}u'''(x)\delta x^3 + \frac{1}{24}u^{iv}(x)\delta x^4 + \mathcal{O}(\delta x^5)$$

$$\frac{\partial u}{\partial x} \Bigg |_t \approx u(x-\delta x) = u(x) - u'(x)\delta x + \frac{1}{2}u''(x)\delta x^2 - \frac{1}{6}u'''(x)\delta x^3 + \frac{1}{24}u^{iv}(x)\delta x^4+ \mathcal{O}(\delta x^5)$$

Now substituting in the above expression/scheme, we get:

$$u_t = u'(t) + \frac{1}{2}u''(t)\delta t + (hot)... \rightarrow u_t \approx u'(t) + \mathcal{O}(\delta t)$$

$$u_{xx} = u''(x) + \frac{1}{12}u^{iv}(x)\delta x^2 + (hot)... \rightarrow u_{xx} \approx u''(x) + \mathcal{O}(\delta x^2)$$

where $hot$ is an abbreviation for Higher Order Terms and $\mathcal{O}$ is the truncation/neglected terms. Therefore, as can be seen, this particular scheme is considered order one accurate in time and 2 in space due to its truncated terms.

If you still would like to dig deeper, which I encourage you, then consider investigating the difference between the local truncation error and the global truncation error. While you are at it, might as well check out the Von Neumann stability condition analysis!

The spatial discretization and time discretization is treated differently. The Taylor approximation is used to determine the order of the spatial discretization. This creates an equation of the form

$\frac{du}{dt} = A u$

where A is the matrix representing the finite difference operator. Then we use methods such as the Von Neumann method to determine stability etc.

You are correct in assuming that the error will be different for the two cases, and this will come out in the Von Neumann analysis.

• I don't think it is only for spatial discretization. I can use Taylor for time as well. This is all before anyone talks about stability. And I don't think I did a mistake, local error is the same in both cases. – Kamil Jul 7 '16 at 14:31
• I am not saying that Taylor series cannot be used for analysis. I am saying its done this way to make it easier to analyze. In @Inquisitor101'2 answer, you can see that with FDM what we get is $u′′(x)+O(δx^2), u′(t)+O(δt)$. So independently it is first order in time and second order in space but how do you relate the two. Its the relationship you are after, and that is where Von Neumann analysis would yield you the answer. – Vikram Jul 10 '16 at 8:10

I think a high level discussion of the terms is more necessary here than a calculation.

Your result is correct. The truncation error is the rough amount of error per step. One equivalent way of defining it is "if I had the exact solution at time $t$, how far off will I be from the exact solution at time $t+\Delta t$?". The actual amount changes each time due to differences in values/derivatives, but its rough value (the order of magnitude, the order of error), stays about the same. Thus you can think of the local truncation error as "the amount of error I am introducing in any step", meaning the step you choose the calculate it at is arbitrary (assuming that your function is sufficiently smooth).

You might as then, what does this mean for the amount of error I truly have? The error at $t+\Delta t$ is obviously larger than at $t$. For this idea we have the global error. A truly astonishing theorem is the Lax-Equivalence Theorem which says that, when you have stability, the global error is directly related to the local truncation error, giving you a way to know what your total error will be by knowing your truncation error estimates.

So in conclusion: local truncation error is a rough estimate for the error introduced per step, while the global error is the error of the approximation at a given point.

• So if this error is per step, should not I add them up to get the global error? For example, linear interpolation is second order locally, but first order globally. I make similar argument, if fdm is second order locally, then it should be first order globally, i.e. at final time t=T? Why the arguments are not equivalent? Or in other words, why can't Lax theorem be applied in the interpolation case? – Kamil Sep 5 '16 at 18:10
• It is the same if you have stability. And the result is the same: the global order will be one less. If you cast it all into the language of functional analysis, you can see that the analysis and the results are essentially the same in each case. – Chris Rackauckas Sep 5 '16 at 18:14
• For the fdm, the global error is the same as the truncation error, I can show it numerically by subdivision of mesh. So the error at any time is proportional to the truncation error and doesn't decrease it, so I am not sure what you mean in terms of say, Crank Nicolson. – Kamil Sep 5 '16 at 19:24
• Depends on how you define the truncation error. There are two definitions that tend to float around: the error in the approximation of the step or the error in the approximation of $f$ (the derivative). In one definition they are the global and local truncation error orders end up the same, in the other they differ by one. Go through the calculations once and you'll see why. – Chris Rackauckas Sep 5 '16 at 19:30
• Note that usually a quick way to find out which convention a book is using is to see how they talk about the local truncation error in general, i.e. $\mathcal{O}(h^{p+1})$ vs $\mathcal{O}(h^p)$, where $p$ ends up as the global error and the theorem is stated with the $+1$ or no $+1$ so that it matches up accordingly. This is a quick way to pick up a book and know how they're defining it. – Chris Rackauckas Sep 5 '16 at 19:35

Suppose $v$ is exact solution and $u$ is numerical solution. You have a scheme

$$L_j(u^{i+1},u^i) := \frac{u_{j}^{i+1}-u_{j}^{i}}{\delta t} - \frac{u_{j-1}^{i}-2u_{j}^{i}+u_{j+1}^{i}}{\delta x^2} = 0$$

Now in general

$$L_j(v^{i+1},v^i) \ne 0$$

So we define the above quantity as the "local truncation error"

$$\tau_j^i := L_j(v^{i+1},v^i)$$

Assuming the exact solution $v$ is sufficiently smooth, you can do a Taylor expansion in space and time and show that

$$\tau_j^i := L_j(v^{i+1},v^i) = O(\delta t) + O(\delta x^2)$$

Since $\tau_j^i \to 0$ as $\delta t, \delta x \to 0$, we say that the scheme is consistent.

Subtracting the two equations, we get $$L_j(v^{i+1},v^i) - L_j(u^{i+1},u^i) = L_j(e^{i+1},e^i) = \tau_j^i$$ where $$e = v - u$$ is the error. The error satisfies the scheme but with a rhs equal to the local truncation error. In one time step, the error changes according to $$e_j^{i+1} = e_j^i + \frac{\delta t}{\delta x^2}(e_{j-1}^{i}-2e_{j}^{i}+e_{j+1}^{i}) + \delta t \cdot \tau_j^i$$ If further you have some stability, you can use the above error equation and estimate the error in terms of $\delta t, \delta x$ and some other data in the problem.