Computing finite difference formulae on irregular grids is an O(2n^2) operation thanks algorithms developed by Bengt Fornberg. The Fortran code for the algorithm was supplied in his paper: Fornberg, Siam Rev., 40, pp 685-691, 1998.

A decent Matlab implementation is available here on the webpage of Randall J. LeVeque. The following picture may help with the nomenclature of the input arguments. The abscissa are provided as a vector

There is another matlab program available on the Scholarpedia article on this topic.

A decent Matlab implementation is available here on the webpage of Randall J. LeVeque. The following picture may help with the nomenclature of the input arguments. The abscissa are provided as a vector

**xbar**.There is another matlab program available on the Scholarpedia article on this topic.