Numerical Analysis Programs Using Fortran 90 - University of ...
Numerical Analysis Programs Using Fortran 90 - University of ...
Numerical Analysis Programs Using Fortran 90 - University of ...
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 = 0. 7 ,<br />
using divided difference formula, for these tabulated data.<br />
X 0 0.5 1 1.4 2 3.2 5.5<br />
F(x) -1.25 -3.5 6 2.32 1.5 1.27 5.6<br />
program Divided_Differences_Iterpolation<br />
dimension x(20),y(20),d(20,20)<br />
n=7<br />
xx=.7<br />
data (x(i), i=1,7) /0,.5,1,1.4,2,3.2,5.5/<br />
data (y(i), i=1,7)/-1.25,-3.5,6,2.32,1.5,1.27,5.6/<br />
s=y(1)<br />
do i=1,n-1<br />
do j=1,n-i<br />
y(j)=(y(j+1)-y(j))/(x(j+i)-x(j))<br />
d(i,j)=y(j)<br />
print*,d(i,j)<br />
enddo<br />
enddo<br />
do i=1,n-1<br />
p=1<br />
do j=1,i<br />
p=p*(xx-x(j))<br />
enddo<br />
s=s+d(i,1)*p<br />
enddo<br />
print*,'Interpolation <strong>of</strong>(',xx,')=',s<br />
end<br />
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br />
Interpolation <strong>of</strong> (0.7) =2.2<strong>90</strong>929<br />
20