Вы находитесь на странице: 1из 1

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_D := CoefficientList@Normal@Series@xs Log@xDm , 8x, 1, n<D  hm D, xD

Compute centered differences and rescale coefficients according to their least common multiple.

In[274]:= CDCoefficients@m_, n_D :=


With@8weights = UFDWeights@m, n, n  2D<, With@8lcm = Apply@LCM, Denominator@weights hm DD<,
8lcm hm , weights hm lcm<DD

First derivative
In[275]:= CDCoefficients@1, 2D

Out[275]= 82 h, 8- 1, 0, 1<<

In[276]:= CDCoefficients@1, 4D

Out[276]= 812 h, 81, - 8, 0, 8, - 1<<

In[277]:= CDCoefficients@1, 6D

Out[277]= 860 h, 8- 1, 9, - 45, 0, 45, - 9, 1<<

In[278]:= CDCoefficients@1, 8D

Out[278]= 8840 h, 83, - 32, 168, - 672, 0, 672, - 168, 32, - 3<<

Second derivative
In[279]:= CDCoefficients@2, 2D

Out[279]= 9h2 , 81, - 2, 1<=

In[280]:= CDCoefficients@2, 4D

Out[280]= 912 h2 , 8- 1, 16, - 30, 16, - 1<=

In[281]:= CDCoefficients@2, 6D

Out[281]= 9180 h2 , 82, - 27, 270, - 490, 270, - 27, 2<=

In[282]:= CDCoefficients@2, 8D

Out[282]= 95040 h2 , 8- 9, 128, - 1008, 8064, - 14 350, 8064, - 1008, 128, - 9<=

Вам также может понравиться