Find Derivatives by integration

The derivatives of a given function $f(x)$ at a set of equally spaced points $x_0,\cdots,x_n$ can be found by integration method.

$\displaystyle \int_{x_{i-1}}^{x_{i+1}} f'(x)\,dx=f(x_{i+1})-f(x_{i-1}),
\;\;\;\;\;(i=1,\cdots,n-1)$ (170)

On the other hand, the integral can also be found by Simpson's rule:

$\displaystyle \int_{x_{i-1}}^{x_{i+1}} f'(x)\,dx=\frac{h}{3}[f'(x_{i-1})+4f'(x_i)+f'(x_{i+1})],
\;\;\;\;\;(i=1,\cdots,n-1)$ (171)

Equating the right-hand sides of the two equations we get

$\displaystyle \frac{h}{3}[f'(x_{i-1})+4f'(x_i)+f'(x_{i+1})]=f(x_{i+1})-f(x_{i-1}),
\;\;\;\;\;(i=1,\cdots,n-1)$ (172)

$\displaystyle \left[\begin{array}{cccccc}
4 & 1 & & & & \\
1 & 4 & 1 & & & \\ ...
...\vdots\\ f(x_{n-1})-f(x_{n-3})\\ f(x_n)-f(x_{n-2})-hf'(x_n)/3\end{array}\right]$ (173)

where $f'(x_0)$ and $f'(x_n)$ can be approximated by

$\displaystyle f'(x_0)\approx\frac{f(x_2)-f({x_0})}{2h},\;\;\;\;\;\;
f'(x_n)\approx\frac{f(x_n)-f(x_{n-2})}{2h}$ (174)

Solving the linear equation system above, we get $f'(x_1),\cdots,f'(x_{n-1})$.