Re: Recommendation for numerical differentiation formulas?




In article <1152885890.796128.65800@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
1940LaSalle@xxxxxxxxx writes:

Peter Spellucci wrote:
In article <1152734860.671170.151780@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
1940LaSalle@xxxxxxxxx writes:
>Here's the situation: I have a series of data in a spread***; the
>independent variables are spaced equally. I need to determine the
>first derivative at each of the values of the independent variable,
>including the endpoints, within the spread***, and would prefer to do
>
>it automatically, rather than do a new regression for every case study.
>
>
>Could someone please (1) recommend a numerical differentiation scheme,
>and (2) mention the source with explicit formulas (ideally, formulas
>suitable for spread*** use)?
>
>
>Thanks.
>
this is a special situation insofar as you want the derivative for all
points in the table. there exist special schemes for this, and here
is a good one: (compact difference scheme of order 6)

alpha*u(i-1)+u(i)+alpha*u(i+1) = (beta/(2*h))*(f(i+1)-f(i-1))
+(gamma/(4*h))*(f(i+2)-f(i-2))
for i=2,...,n-1. here f(i)=f(x(i)) , x(i+1)-x(i)=h for all i
u(i) is the approximation for f'(x(i)).
alpha=1/3, beta=14/9, gamma=1/9;
this is a linear system of equations with tridigonal matrix, which can be solved
efficiently.
you miss here approximations for the first i=0 and last i=n+1 point. for these
endpoints you must use secail one sided formulas, for example
f'(x(0))=(1/(2*h))*(-3*f(0)+4*f(1)-f(2)) error const*h^2
f'(x(0))=(1/12*h))*(-25*f(0)+48*f(1)-36*f(2)+16*f(3)-3*f(4)) error const*h^4

for the right endpoint you complete flip these formulas .

hth
peter

This looks promising. If I understand the scheme, the right side of
the first equation yields a vector that is generated by the tabulated
values and the constants of beta and gamma. At the same time, the left
side is a tridiagonal matrix where the non-zero entries are all equal
to alpha, which we also know going in. Now, let's say the table has a
total of j values (and therefore I want j first derivatives): if I
understand things properly, j=i+2. Last but not least, when you say
"completely flip", referring to the one-sided formulas, that means that
the constants take the opposite sign; that is, for the j-th point:

f'(x(j))=(1/12*h)*[(25*f(j-4))+(-48*f(j-3))+(36*f(j-2))+(-16*f(j-1))+(3*f(j))]

Correct?

Thanks.


no, flip in a geometric sense right to left. means

f'(x(n+1))=(1/(12*h))
*(-25*f(x(n+1)+48*f(x(n))-36*f(x(n-1))+16*f(x(n-2))-3*f(x(n-3)))

you need these special one sided formulae only for the first data point
(I named it x(0)) and the last one x(n+1) because these are not covered by
the 3 point compact scheme. all other derivatives come out from the
tridiagonal solve, and you are right: the right hand side is made up from the
table and looking at the indices you see: f(x(0)) up to f(x(n+1)) are needed
there and give you u(1) up to u(n) which correspond to f'(x(1)) up to f'(x(n))
good luck
peter
.