Monday, 20 December 2010

algorithm to implement the Newton Gregory forward interpolation

Algorithm:

Step1: START

Step2: Read n

Step3: for i=0 to (n-1) do read xi,yi

Step4: read x

Step5: h←xi-x0

Step6: p←(x-xo)/n

Step7: for j=0 to n-2 do ∆1yj←yj+1-∆i-1

Step8: k←n-2

Step9: for i=2 to (n-1)do  
Step9.1: k←k-1
Step9.2:for j=0 to k do ∆iyj←∆i-1 yj+1-∆i-1yj

Step10:  Sumy←y0

Step11: Pvalue←1

Step12: Fact value←1

Step13: for l=1 to (n-1) do
  Step13.1: Pvalue←pvalue x (p-(l-1))
  Step13.2: factvalue←factvaluex1
              Step13.3: term←(pvalue x ∆ly) / factvalue
  Step13.4: Sumy←Sumy+term

Step14: Print x,SUMY

Step15: STOP



Algorithm


Data structures using Java

No comments:

Post a Comment