Skip to content

Instantly share code, notes, and snippets.

@ianliu
Last active December 14, 2015 23:09
Show Gist options
  • Save ianliu/5163861 to your computer and use it in GitHub Desktop.
Save ianliu/5163861 to your computer and use it in GitHub Desktop.
Interpolador de ???
PROGRAM interpol
Implicit none
double precision :: Y, X = 8.95
double precision :: s1, s2, p
integer :: n = 6, i, j
double precision,allocatable,dimension(:) :: xx, ff, ww
allocate(xx(n))
allocate(ff(n))
allocate(ww(n))
xx = (/ 1.4, 2.3, 4.0, 5.9, 10.0, 10.1 /)
do i = 1, n
ff(i) = xx(i)**2
ww(i) = 1.0
enddo
do i = 1, n
do j = 1, n
if (i == j) cycle
ww(i) = ww(i) / (xx(i) - xx(j))
enddo
enddo
s1 = 0.0
s2 = 0.0
do i = 1, n
p = ww(i) / (X - xx(i))
s1 = s1 + p
s2 = s2 + p * ff(i)
enddo
Y = s2 / s1
print*, Y, X*X
END PROGRAM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment