Unit 3 Interpolation: Viral Shah (S/W Projects in C++) Shri Sunshine Group of
Unit 3 Interpolation: Viral Shah (S/W Projects in C++) Shri Sunshine Group of
Construction of Forward Difference Table Observation X & Y are stored in 1Dimensional array of size N. A 2 Dimensional array i.e. D is taken to store the forward differences of size N*N. Step 1 [Input No.of Observations]
Read n
Step 3[Construct Forward difference Table: - Calculate the forward difference & store it in d]
For j=1 to n-1 by 1 do For i=1 to n-j by 1 do If j=1 then Set dij=y(i+1) yi Else Set dij=d(i+1)(j-1) d(i)(j-1) Endif Endfor Endfor
Step 5[Stop]
End
Construction of Backward Difference Table Observation X & Y are stored in 1d array of size N. A 2d array D is taken to store the backward differences of size N*N. Step 1[Read No.of Observations]
Read n
Step 3[Backward difference Table: - Calculate the backward differences & store it in d]
For j=1 to n-1 by 1 do For i=j+1 to n by 1 do If j=1 then Set dij=y(i) y(i-1) Else Set dij=d (i)(j-1) d (i-1)(j-1) Endif Endfor Endfor
Step 5 [Stop]
End
Newton Forward Interpolation Observation X & Y are stored in 1d array of size N. A 2d array D is taken to store the forward differences of size N*N.NEW is 1d array for store the first row of F.D.T Step 1[Read no. of data points and read the value of Xp(Value for find Y)]
Read n, xp
Step 5 [Forward difference Table: - Calculate the forward difference table & store it in d]
For j=1 to n-1 by 1 do For i=1 to n-j by 1 do If j=1 then Set dij=y(i+1) y(i) Else Set dij=d (i+1)(j-1) d(i) (j-1) Endif Endfor Endfor
Set temp=1 Set fact =1 For j=1 to i by 1 do Set temp=temp*(p-(j-1)) Set fact=fact*(j) Endfor Set yp=yp+(newi*temp)/fact Endfor
Step 10 [Stop]
End
Newton Backward Interpolation Observation X & Y are stored in 1d array of size N. A 2d array D is taken to store the backward differences of size N*N.NEW is 1d array for store the first row of B.D.T Step 1[Read no. of data points and read the value of Xp(Value for find Y)]
Read n, xp
Step 5[Backward difference Table: - Calculate the backward difference table & store it in d]
For j=1 to n-1 by 1 do For i=j+1 to n by 1 do If j=1 then Set dij=yi yi-1 Else Set dij=d (i)(j-1) d(i-1)(j-1) Endif Endfor 4 Viral Shah (S/W PROJECTS IN C++) SHRI SUNSHINE GROUP OF
INSTITUTIONS,RAJKOT
Endfor
Step 10 [Stop]
End
Lagranges Interpolation Method In order to find interpolation value using langrage's methods. We use to store the observation in single dimension array say x & y of size n. Step 1 [Read number of observation]
Read n
Step 6 [Stop]
End