|
|
|
Interpolation
Interpolation is a technique to find the value of a dependent variable on the basis of a given set of data or both the variables. In other words on the basis of given set of date (xi,yi) for I=0,1,2,3 ………n, the tachnique to find y for any given value x is called interpolation or extrapolation. These two terms differ only in concept. If x0 A number of technique have been defined in Numerical Analysis for interpolation or extrapolation.
Fortran Program for Interpolation :
C PROGRAM FOR NEWTON FORMULA FOR INTERPOLATION INTEGER N REAL XP,FP,SUM,PI,X,F,A,D DIMENSION X(10),F(10),A(10),D(10,10) WRITE(*,*)'INPUT NUMBER OF DATA POINTS' READ(*,*) N WRITE(*,*)'INPUT VALUE OF X AND F(X) ONE SET ON EACH LINE' DO 10 I=1,N READ(*,*) X(I),F(I) 10 CONTINUE C CONSTRUCT DIFFERENCE TABLE D DO 20 I=1,N D(I,1)=F(I) 20 CONTINUE DO 40 J=2,N DO 30 I=1,N-J+1 D(I,J)=(D(I+1,J-1)-D(I,J-1))/(X(I+J-1)-X(I)) 30 CONTINUE 40 CONTINUE C SET THE COEFFICIENT OF INTERPOLATING POLYNOMIAL DO 50 J=1,N A(J)=D(1,J) 50 CONTINUE
C COMPUTE INTERPOLATION VALUE WRITE(*,*)'INPUT XP WHERE INTERPOLATION IS REQUIRED' READ(*,*) XP SUM=A(1) DO 70 I=2,N PI=1.0 DO 60 J=1,I-1 PI=PI*(XP-X(J)) 60 CONTINUE SUM=SUM+A(I)*PI 70 CONTINUE FP=SUM
C WRITE RESULT WRITE(*,*) WRITE(*,*) 'NEWTON INTERPOLATION' WRITE(*,*) WRITE(*,*)'Interpolated Function Value' WRITE(*,*) 'at X=',XP,'is',FP WRITE(*,*) STOP END
OUTPUT:
INTERPOLATION NEWTON FORMULA
D:\FORTRAN\BINB>NWTINT INPUT NUMBER OF DATA POINTS 3 INPUT VALUE OF X AND F(X) ONE SET ON EACH LINE 2 1.4142 3 1.7321 4 2.0 INPUT XP WHERE INTERPOLATION IS REQUIRED 2.5
NEWTON INTERPOLATION
Interpolated Function Value at X= 2.500000is 1.579400
Stop - Program terminated.
|
No responses found. Be the first to respond and make money from revenue sharing program.
|