Advertisement
Guest User

Untitled

a guest
Jan 21st, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program Interpolation
  2. implicit none
  3. real,dimension(4):: x,y
  4. integer:: n ,i, j
  5. real:: xp ,sum, p
  6.            
  7. data x /3.2, 2.7, 1.0, 4.8/
  8. data y /2.0, 17.8, 14.2, 38.3/
  9.            
  10. n=4
  11. xp=3.5
  12. do i=1,n
  13.    p=1
  14.     do j=1,n
  15.         if (i.eq.j) cycle
  16.             p= p * ((xp-x(j)) / (x(i)-x(j)))
  17.     enddo
  18.         sum=sum+p*y(i)
  19. enddo
  20.            
  21. write(*,1)"value of f(x) for point",xp,"=",sum
  22. 1 format(2x,a,f5.3,a,1x,f10.5)
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement