Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2018-02-11 20:48:31

George,Y
Member
Registered: 2006-03-12
Posts: 1,379

the Mythical formula to calculate Numerical Derivatives!

I come across this method when trying to calculate the derivative of an unknown curve which I have only sample points at equal grids.

The simplest way to calculate numerical derivative is three-point formula:

dy/dx = (y[1]-y[-1]) /2/dx
ddy/dx/dx = (y[1]+y[-1]-2*y[0]) /dx/dx

But I found this one on five points :

dy/dx = ( y[-2] -8*y[-1] +8*y[1] -y[2]) / (12*dx)

ddy/dx/dx = (-y[-2] +16*y[-1] -30*y[0]+ 16*y[1] -y[2])  / (12*dx^2)

It is surprisingly accurate when I test the derivative on exp(3) using exp(2) exp(2.5) exp(3) exp(3.5) exp(4)

the result of 1st numerical derivative and 2nd are
20.04243  &   20.07127

remember the correct answer are both exp(3) = 20.08554

Can anyone prove how this works?
4th polynomial?


X'(y-Xβ)=0

Offline

#2 2018-02-12 08:14:24

zetafunc
Moderator
Registered: 2014-05-21
Posts: 2,436
Website

Re: the Mythical formula to calculate Numerical Derivatives!

These coefficients are part of a more general phenomenon called the Savitzky-Golay filter in numerical analysis. In fact the traditional five-point 'stencil' reads:

where
. You can derive this result simply by playing around with the Taylor series for
with
. It's a little tedious, but you can see the derivation here: https://en.wikipedia.org/wiki/Five-poin … he_formula

There are analogous formulae for higher order derivatives too, and several published papers about the error term.

Offline

#3 2018-02-12 22:42:05

George,Y
Member
Registered: 2006-03-12
Posts: 1,379

Re: the Mythical formula to calculate Numerical Derivatives!

zetafunc wrote:

These coefficients are part of a more general phenomenon called the Savitzky-Golay filter in numerical analysis. In fact the traditional five-point 'stencil' reads:

where
. You can derive this result simply by playing around with the Taylor series for
with
. It's a little tedious, but you can see the derivation here: https://en.wikipedia.org/wiki/Five-poin … he_formula

There are analogous formulae for higher order derivatives too, and several published papers about the error term.

That is very informative, zeta. Thanks for the reply.

I wonder if there is a way to calculate the midpoint differentials by 4 points around it:

dy/dx ]x=0

ddy/dx/dx ]x=0

given y[-0.5], y[0.5], y[-1.5] & y[1.5]


X'(y-Xβ)=0

Offline

Board footer

Powered by FluxBB