This presentation explores the concept of the difference coefficient through the construction of a forward difference table for polynomial interpolation. It provides a foundational understanding of interpolation methods used in numerical analysis, particularly focusing on Newton’s forward interpol...
This presentation explores the concept of the difference coefficient through the construction of a forward difference table for polynomial interpolation. It provides a foundational understanding of interpolation methods used in numerical analysis, particularly focusing on Newton’s forward interpolation technique. The slides explain the theoretical basis, types of interpolation, and the algorithmic steps involved in computing difference coefficients. A Fortran-based program demonstrates how to implement the method computationally, accompanied by a discussion of its limitations and potential sources of error. This presentation is ideal for students and professionals interested in computational physics and numerical methods.
Size: 1.21 MB
Language: en
Added: May 08, 2025
Slides: 16 pages
Slide Content
[ MPL – 203 ] COMPUTATIONAL PHYSICS AND PROGRAMMING LABORATORY DIFFERENCE COEFFICIENT BY :- SANDEEP YADAV SANDEEP SINGH
OBJECTIVE FIND THE DIFFERENCE COEFFICIENT BY CONSTRUCTING THE FORWARD DIFFERENCE TABLE INTERPOLATING THE FUNCTION FOR A GIVEN VALUE OF X
WHY INTERPOLATION We will frequently have occasions to estimate intermediate values between precise data points. The function we use to interpolate must pass through the actual data points - this makes interpolation more restrictive than fitting. The most common method for this purpose we use polynomial interpolation, where an ( n -1) th order polynomial is solved that passes through n data points :
TYPES OF INTERPOLATION NEWTON’S INTERPOLATION, NEWTON INTERPOLATION FOR EQUAL INTERVAL If our datapoints maintain the continuity in terms of equal interval in independent variables we may use this method. NEWTON DIVIDED DIFFERENCE METHOD If our datapoints doesn’t have consistency in terms of interval then we use this method. LAGRANGE INTERPOLATION It can be used to find the value of the function even when the arguments are not equally spaced. It can also be used to find out the value of the independent variables. SPLINE INTERPOLATION It is preferred to use in case of lower degree polynomials as it commits less error. AND MANY MORE…………………….
WHY NEWTON’S INTERPOLATION For any given finite set of data points, there is only one polynomial of least possible degree that passes through all of them. The degree of a newton ’ s interpolating polynomial can be increased by adding more terms and points without discarding existing ones.
THEORY AND FORMULA USED For n number of data sets we will obtain a polynomial of order (n-1). Here all the coefficients is known as difference coefficient. We are obtaining these coefficients from the newtons difference table.
THEORY CONTINUED…
CALCULATIONS……………
ALGORITHM Create a function to obtain the factorial Start the program Declare all the necessary variables Read the total number of datapoints as (n) Create a table having dimension (n, n+1) Take the value of x and f(x) from the user as an input Run do loop and find the difference Display the forward difference table To interpolate for a particular x, it must lie between lower and upper x value Run the do loop and hence interpolate the value at x Print the result and stop the program
PROGRAMMING RECURSIVE FUNCTION FACTORIAL(X) RESULT(Y) INTEGER :: X, Y IF (X .LT. 1) THEN Y = 1 ELSE Y = X * FACTORIAL(X-1) END IF END FUNCTION FACTORIAL
PROGRAMMING CONTINUE… PROGRAM DIFFERENTIAL IMPLICIT NONE ! DECLARING THE VARIABLES REAL, DIMENSION(:,:), ALLOCATABLE :: TABLE REAL :: X, H, TEMP, RES INTEGER :: N, I, J, FACTORIAL ! CREATING THE TABLE ! ASSIGNING THE DIMENSIONS WRITE(*,*) "ENTER THE NUMBER OF DATAPOINTS YOU WANT TO ENTER:" ; READ(*,*) N ALLOCATE(TABLE(N,N+1)) ! FEEDING THE DATAPOINTS DO I = 1, N WRITE(*,*) "ENTER X, F(X)"; READ(*,*) TABLE(I, 1), TABLE(I, 2) END DO ! FEEDING THE DIFFERENCES DO I = 2, N+1 DO J = 1, N-I+1 TABLE(J, I+1) = TABLE(J+1, I) - TABLE(J, I) END DO END DO
PROGRAMMING CONTINUE……… ! DISPLAYING THE TABLE DO I = 1, N WRITE(*,*) (TABLE(I, J), J = 1, N-I+2) END DO ! FINDING THE INTERPOLATION AT A GIVEN POINT WRITE(*,*) "TAKE THE VALUE OF X: "; READ(*,*) X H = TABLE(2, 1) - TABLE(1, 1) RES = TABLE(1, 2) DO I = 1, N-1 TEMP = 1.0 DO J = 1, I TEMP = TEMP * (X - TABLE(J, 1)) END DO RES = RES + (TABLE(1, I+2)*TEMP)/(FACTORIAL(I)*H**I) END DO WRITE(*,*) "THE DIFFERENTIAL COEFFICIENT IS FOUND TO BE ", RES DEALLOCATE(TABLE) END PROGRAM DIFFERENTIAL
PROGRAMMING OUTPUT (RESULTS)
VERDICT THERE ARE MANY SHORT COMMINGS IN THIS INTERPOLATION METHOD The interpolation is not accurate if there is sudden rise or fall in the curve. If there are less number of datapoints then, our interpolation becomes more inaccurate. It is suitable if we interpolate near the top of a set of tabulated values. It is only used in those cases where there is no uncertainty in our datapoints, which is practically impossible.
VERDICT POSSIBLE ERRORS In forward difference table since there is a possibility of local error due to the rounding off the floating digits therefore in each stages it accumulate error. Since over iterations those local errors piles up and result a global error. There is a chance of truncation error is we truncate our series in between.