Algorithm for Newton’s Forward Difference Formula
Step 01.Start of the program
Step 02.Input number of terms n
Step 03.Input the array ax
Step 04.Input the array ay
Step 05.h=ax[1] – ax[0]
Step 06.for i=0; i<n-1; i++
Step 07.diff[i] [1]=ay[i + 1] – ay[i]
Step 08.End Loop i
Step 09.for j=2; j<=4; j++
Step 10.for i = 0; i <n – j; i++
Step 11.diff[i][j]=diff [i + 1] [j – 1]-diff [i][j – 1]
Step 12.End Loop i
Step 13.End Loop j
Step 14.i=0
Step 15.Repeat Step 16 until ax[i]<x
Step 16.i=i + 1
Step 17.i=i – 1;
INTERPOLATION 245
Step 18.p=(x – ax [i])/h
Step 19.y1=p*diff[i – 1][1]
Step 20.y2=p*(p+1)∗diff [i – 1][2]/2
Step 21.y3=(p+1)*p*(p-1)*diff[i –2 ][3]/6
Step 22.y4=(p+2)*(p+1)*p*(p – 1)*diff[i – 3][4]/24
Step 23.y=ay[i]+y1+y2+y3+y4
Step 24.Print output x, y
Step 25.End of program.
Переглядів: 186 |