23.10.2014 Views

Numerical Analysis Programs Using Fortran 90 - University of ...

Numerical Analysis Programs Using Fortran 90 - University of ...

Numerical Analysis Programs Using Fortran 90 - University of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Problem: Write a program to find the interpolated value for x =1. 93,<br />

using Newton backward method, for these tabulated data.<br />

X 1 1.2 1.4 1.6 1.8 2.0<br />

f 2.317 2.425 2.522 2.609 2.689 2.762<br />

program Newton_Backward_Iterpolation<br />

dimension x(20),y(20),d(20,20)<br />

n=6<br />

xx=1.93<br />

data (x(i), i=1,6) /1,1.2,1.4,1.6,1.8,2/<br />

data (y(i), i=1,6)/2.317,2.425,2.522,2.609,2.689,2.762/<br />

print*,(x(i), i=1,6)<br />

print*,(y(i), i=1,6)<br />

s=y(n)<br />

do i=1,n-1<br />

do j=1,n-i<br />

y(j)=y(j+1)-y(j)<br />

d(i,j)=y(j)<br />

enddo<br />

enddo<br />

r=(xx-x(n))/(x(2)-x(1))<br />

do i=1,n-1<br />

p=1<br />

do j=0,i-1<br />

p=p*(r+j)<br />

enddo<br />

f=1<br />

do j=1,i; f=f*j; enddo<br />

s=s+d(i,n-i)*p/f<br />

enddo<br />

print*,'Interpolation <strong>of</strong>(',xx,')=',s<br />

end<br />

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br />

Interpolation <strong>of</strong>(1.93)=2.737522<br />

16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!