# Analytical way of describing centred difference coefficients

I am trying to find an analytical way to describe the finite difference coefficients of various degrees of accuracy of centred difference schemes that approximate the second derivative. For example, a second order approximation is:

$$\frac{\partial^2}{\partial x^2} p(x) = \frac{p(x-h) - 2 p(x) + p(h+1)}{2h} + O(x^2)$$

so the first set of coefficients is $\{\frac{1}{2}, -1, \frac{1}{2} \}$. Likewise, you can extend this method to higher orders. I made a table of the first 8 sets of coefficients:

The only way I know to derive these is to use Lagrangian interpolation, and then solve a system of $n + 1$ equations (where $n$ is the order of accuracy). However, this doesn't really get you any closer to an analytical way of describing it. There might be another, more analytical approach (Taylor series expansions?), or a formula that computes this for arbitrary orders, but I don't know it.

I am fully aware of the possibility that such an analytical representation may not exist, but I'd be interested to know if there is a way to prove that.

• What is a "centred difference scheme"? What exactly are the coefficients you list above? What would you like to get? Feb 1, 2014 at 12:01
• Thanks for the comment, I elaborated a bit more on that. Sorry to assume. Feb 1, 2014 at 22:10

An interesting and synthetic way to get the weights for a finite difference approximation of the $m$-derivative of a function, given its values at $n+1$ equally spaced vertices, is given by the Fornberg formula.

Take the $n$ coefficients of the Taylor series expansion around $x=1$ of the function

$$x^s log(x)^m$$

where $s h$ is the distance, from the leftmost vertex of the stencil, of the point at which you want approximate the derivative and $h$ is the grid spacing; if you want a centered approximation $s = n/2$; $s$ need not to be a whole number.

In Mathematica you can implement the formula with the following one-line:

FiniteDifferenceWeights[m_Integer /; IntegerQ[m], (* derivative order *)
n_Integer /; IntegerQ[n], (* stencil width *)
s_ /; NumericQ[s],        (* point of evaluation  *)
h_: 1] :=                 (* grid spacing *)
Block[{x}, CoefficientList[Normal[Series[x^s Log[x]^m, {x, 1, n}]/h^m], x]]


directly adapted from the Fornberg formula to be a more robust function definition and to accept the mesh width $h$.

For example, to get a sixth-order centred difference approximation of the second derivate, at a grid spacing of 1:

> FiniteDifferenceWeights[2, 6, 3, 1]

{1/90, -3/20, 3/2, -49/18, 3/2, -3/20, 1/90}


Maybe you can start from here to prove what you need.

Fornberg, B. "Fast Generation of Weights in Finite Difference Formulas." In Recent Developments in Numerical Methods and Software for ODEs/DAEs/PDEs. World Scientific, 1992.

• This is a fantastic answer, thank you ever so much! I took the liberty to add some comments and an example to code, as this it is not immediately obvious how to use it for those not proficient with Mathematica. Jul 27, 2014 at 11:21
• @Yellow But I don't completely agree with the fact that $n$ is always the approximation order. If I'm not wrong, if the unknown function is smooth enough the order of accuracy should be $n-m+1$ if $s \neq n/2$ and $n-m+2$ if $s=n/2$... Jul 27, 2014 at 18:26