# Taylor series and finite differences

To formally analyse the error associated with a finite difference approximation for a derivative, one expands each possible term of the approximation in a Taylor series (TS) so that Dapprox = Taylor series. You then would take the difference between the approximation (LHS) and the derivative term from the TS (on RHS), and you are left with the 'error'. As h gets small, the biggest term of this series will dominate the error. You now have an explicit coefficient for E ~ O(h^{n}).

Replacing derivatives in differential equations with finite difference approximations replaces the original diff-eq problem with a system of algebraic equations. To analyse the error in this case, we need the concepts of "local truncation error" at each grid point, as well as some handle on the "global error" over the entire mesh.

# Local truncation error (LTE)

LTE is a measure of how well an analytical solution to a particular ODE satisfies the finite difference approximation of that ODE.

The concept of LTE is illustrated with the following example. Suppose we replace the 2nd derivative of the 1D Poisson equation,

with the centered (2nd order, as can be verified by above discussion) finite different approximation D2,

(written so to illustrate it as the finite difference version of the derivative of the derivative). Using this, and discretizing, we have

This is a system of equations over a 1D interval. As such, it can be written as a matrix equation,

where

is the solution vector from this finite-difference scheme.Now if we replace the approximate solution with the exact solution (U) in the discrete equation above, the left and right hand sides in general will not be exactly the same. This difference is the LTE, and can be written as,

Replacing terms with their Taylor series indicates,

Using the original ODE, this becomes,

# Global error

As we had the matrix formula for the finite difference system of equations,

,

analogously when we replace the approximate solution u with the true solution, U, we have to introduce the local truncation error,

Taking the difference of these equations, we have

This is a set of finite difference equations for the *global* error, E.

Using reverse logic, we can assume this system is an approximation to the ODE:

with boundary conditions E(0)=E(mx+1)=0 for the case of Dirchlet BCs (where value of u is supplied at boundary).

Integration of this equation is said to provide an estimate for the global error in your solution, which you'd like to be bound and decreasing for increasing h.

Going further with this analysis includes concepts of consistency, stability, and convergence, all covered in Leveque chapter 2 on Finite Difference Methods.

# A check that numerically solving Laplace's Eqn with f(x) = 6x gives the *exact* solution

I wanted to check if numerically solving

gives the exact solution. This is the same as saying

,

that is, the LTE is zero (i.e. discretization of the equation leads to the exact solution).

To check this I wrote out the form for the LTE, which is the same as given above but with f(xi) replaced with 6x(i). Using the exact solution in this formula gives,

The ODE is easy to solve by hand, and gives a general solution of,

As you can see, the truncation error requires 2nd derivatives and *higher*, and so the LTE is exactly zero as I wanted to verify.

**Note:**See TracWiki for help on using the wiki.