Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Interpolation
- implicit none
- real,dimension(4):: x,y
- integer:: n ,i, j
- real:: xp ,sum, p
- data x /3.2, 2.7, 1.0, 4.8/
- data y /2.0, 17.8, 14.2, 38.3/
- n=4
- xp=3.5
- do i=1,n
- p=1
- do j=1,n
- if (i.eq.j) cycle
- p= p * ((xp-x(j)) / (x(i)-x(j)))
- enddo
- sum=sum+p*y(i)
- enddo
- write(*,1)"value of f(x) for point",xp,"=",sum
- 1 format(2x,a,f5.3,a,1x,f10.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement