for any given finite sequence f and a given index n one can find Newtons divided differences formula
such that the formula satisfies f and also any arbitrary value at the n th index. That means your sequence is not going to give one single number but it can be any number for a different formula.
To check, try the following octave code:
function g=newton(f, in)
#f=input('Enter the sequence:');
lf=length(f);
#in=input('Enter the target index:');
if(in>0)
n=in-1;
else
break;
endif;
g=0;
while(length(f) && (n+length(f)>=lf))
g=g+f(1)*nchoosek(n,lf-length(f));
f=diff(f);
endwhile;
#disp(g)
such that the formula satisfies f and also any arbitrary value at the n th index. That means your sequence is not going to give one single number but it can be any number for a different formula.
To check, try the following octave code:
function g=newton(f, in)
#f=input('Enter the sequence:');
lf=length(f);
#in=input('Enter the target index:');
if(in>0)
n=in-1;
else
break;
endif;
g=0;
while(length(f) && (n+length(f)>=lf))
g=g+f(1)*nchoosek(n,lf-length(f));
f=diff(f);
endwhile;
#disp(g)
Example: newton([3 9 12 78 91 198], 1)
newton([3 9 12 78 91 198], 8)
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి