Chapter:

backward-difference-table

1. BACKWARD DIFFERENCE TABLE USING C PROGRAMMING

TITLE: 

TO GENERATE THE BACKWARD DIFFERENCE TABLE USING C PROGRAMMING

OBJECTIVES:

  • To be able to follow the algorithm of Newton's Backward Interpolation method to generate backward difference table.

  • To build some programming concepts by solving practical problems.

 TOOLS REQUIRED:

  • Computer workstation

  • Program software (as necessary)

 THEORY:

While interpolating intermediate value of dependent variable for equi-spaced data of independent variable, at the end of the table, Newton's Backward Interpolation formula is used. 

 ALGORITHM:

  1. Start

  2. Read the number of data n and the datas.

  3. Set i=1

  4. Set j=n-1

  5. Calculate y [j][i]=y [j][i-1]-y [j-1][i-1]

  6. J=j-1

  7. Goto step 5 if j > i-1

  8. Set i=i+1

  9. Goto step 4 if i < n

  10. Display the table 

  11. Stop

C-PROGRAM:   


#include #include void main() { float x[20], y[20][20]; int i,j, n; clrscr(); printf("Enter number of data?\n"); scanf("%d", &n); printf("Enter data:\n"); for(i = 0; i < n ; i++) { printf("x[%d]=", i); scanf("%f", &x[i]); printf("y[%d]=", i); scanf("%f", &y[i][0]); } /* Generating Backward Difference Table */ for(i = 1; i < n; i++) { for(j = n-1; j > i-1; j--) { y[j][i] = y[j][i-1] - y[j-1][i-1]; } } /* Displaying Forward Difference Table */ printf("\nBACKWARD DIFFERENCE TABLE\n\n"); for(i = 0; i < n; i++) { printf("%0.2f", x[i]); for(j = 0; j <= i ; j++) { printf("\t%0.2f", y[i][j]); } printf("\n"); } getch(); }

OUTPUT:

Enter number of data?
4
Enter data:
x[0]=0
y[0]=1
x[1]=1
y[1]=2
x[2]=2
y[2]=1
x[3]=3
y[3]=10

BACKWARD DIFFERENCE TABLE

0.00    1.00
1.00    2.00    1.00
2.00    1.00    -1.00   -2.00
3.00    10.00   9.00    10.00   12.00

CONCLUSION:

Thus the Backward difference table was generated  by using C Programming language.

Show More