# Centered finite difference coefficients on uniform grids

Setup
Establish uniform weights formula as given in Fornberg, B. "Calculation of Weights in Finite Difference Formulas." SIAM Review 40, no. 3 (1998): 685-691 and discussed within http : // reference.wolfram.com/mathematica/tutorial/NDSolvePDE.html.
In[273]:=

UFDWeights m_, n_, s_

:

CoefficientList Normal Series xs Log x

m

, x, 1, n

hm , x

Compute centered differences and rescale coefficients according to their least common multiple.
In[274]:=

CDCoefficients m_, n_ : With weights UFDWeights m, n, n lcm hm , weights hm lcm

2

, With

lcm

Apply LCM, Denominator weights hm

,

First derivative
In[275]:= Out[275]= In[276]:= Out[276]= In[277]:= Out[277]= In[278]:= Out[278]=

CDCoefficients 1, 2 2 h, 1, 0, 1

CDCoefficients 1, 4 12 h, 1, 8, 0, 8, 1

CDCoefficients 1, 6 60 h, 1, 9, 45, 0, 45, 9, 1

CDCoefficients 1, 8 840 h, 3, 32, 168, 672, 0, 672, 168, 32, 3

Second derivative
In[279]:= Out[279]= In[280]:= Out[280]= In[281]:= Out[281]= In[282]:= Out[282]=

CDCoefficients 2, 2 h2 , 1, 2, 1

CDCoefficients 2, 4 12 h2 , 1, 16, 30, 16, 1

CDCoefficients 2, 6 180 h2 , 2, 27, 270, 490, 270, 27, 2

CDCoefficients 2, 8 5040 h2 , 9, 128, 1008, 8064, 14 350, 8064, 1008, 128, 9