Computes the divided difference of a function (or vector of function evaluations) with respect to given centers.

divided_diff(f, z)

Arguments

f

Function, or vector of function evaluations at the centers.

z

Centers for the divided difference calculation.

Value

Divided difference of f with respect to centers z.

Details

The divided difference of a function \(f\) with respect to centers \(z_1, \ldots, z_{k+1}\) is defined recursively as: $$ f[z_1,\ldots,z_{k+1}] = \displaystyle \frac{f[z_2,\ldots,z_{k+1}] - f[z_1,\ldots,z_k]}{z_{k+1}-z_1}, $$ with base case \(f[z_1] = f(z_1)\) (that is, divided differencing with respect to a single point reduces to function evaluation).

A notable special case is when the centers are evenly-spaced, say, \(z_i = z+ih\), \(i=0,\ldots,k\) for some spacing \(h>0\), in which case the divided difference becomes a (scaled) forward difference, or equivalently a (scaled) backward difference, $$ k! \cdot f[z,\ldots,z+kh] = \displaystyle \frac{1}{h^k} (F^k_h f)(z) = \frac{1}{h^k} (B^k_h f)(z+kh), $$ where we use \(F^k_h\) and \(B^k_v\) to denote the forward and backward difference operators, respectively, of order \(k\) and with spacing \(h\).