HP Forums

Full Version: Higher order derivatives of unequally spaced data
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I found on the Internet several documents and power points that describe how to estimate the first and second derivatives of unequally spaced points based on quadratic Lagrangian polynomials.

I posted on my web site (click here to download) a short paper that presents first, second, third, and fourth derivatives based on cubic and quartic Lagrange polynomials. I used some free online tools to help me formulate the equations for these derivative estimates. The paper includes the pseudo-code for these methods along with source code in Excel VBA, Matlab, and Python.

These derivatives are helpful in estimating the rate of changes in physical of chemical process where the physical/chemical property is measured at irregular intervals.

For derivatives, we may remove 1 term of Lagrange polynomial.

(f(x))' = (f(x) - c)', for constant c

Example, with 3 points:

\( f(x)
≈ f(x_1)\left({(x-x_2)(x-x_3) \over (x_1-x_2)(x_1-x_3)}\right)
+ f(x_2)\left({(x-x_1)(x-x_3) \over (x_2-x_1)(x_2-x_3)}\right)
+ f(x_3)\left({(x-x_1)(x-x_2) \over (x_3-x_1)(x_3-x_2)}\right)

Let \(c = f(x_2)\), we eliminated middle term:

\( f'(x)
≈ \Big(f(x_1) - f(x_2)\Big) \left({(x-x_2)+(x-x_3) \over (x_1-x_2)(x_1-x_3)}\right)
+ \Big(f(x_3) - f(x_2)\Big) \left({(x-x_1)+(x-x_2) \over (x_3-x_1)(x_3-x_2)}\right)

Simplify with Divided Differences Notation:

\(\begin{align} f'(x)
&≈ {f[x_1,x_2] \over x_3-x_1} (x_2+x_3-2x)
+ {f[x_2,x_3] \over x_3-x_1} (2x-x_1-x_2) \\
&= {f[x_1,x_2] \over x_3-x_1} (x_2+x_3-2x)
+ \left(f[x_1,x_2,x_3] + {f[x_1,x_2] \over x_3-x_1}\right) (2x-x_1-x_2) \\
&= f[x_1,x_2] + f[x_1,x_2,x_3] \, (2x-x_1-x_2)

We can confirm above, with 3-points Divided-difference formula

\(f(x) ≈ f(x_1) + (x-x_1) \Big(f[x_1,x_2] + (x-x_2)\,f[x_1,x_2,x_3] \Big) \)

Differentiate with respect to x, we get back the same f'(x)
Thanks Albert! I may updated my paper to include a version of algorithms and source codes that are based on Newton divided-difference polynomials.

Hi All,

I have updated my original paper to include higher order derivatives of unequally spaced data using Newton's divided-difference interpolation polynomials. The update also includes source code functions in Excel VBA, Matlab, and Python.

To access the updated paper click here.


Reference URL's