Monday, February 21, 2022

FORTRAN code: Lagrange's interpolation

 Source code:



c Lagrange's interpolation

dimension x(1000), f(1000)

write(*,*)'x,n'

read(*,*)a,n


write(*,*)'xi, fi'

read(*,*)(x(i),i=1,n)

write(*,*)'f'

read(*,*)(f(i),i=1,n)

c prod=(a-x(j))/(x(i)-x(j))

sum=0

prod=1

do i=1, n

do j=1, n

c prod=(a-x(j))/(x(i)-x(j))

if(j.NE.i) then

        prod=(a-x(j))/(x(i)-x(j))

sum=sum+f(i)*prod

endif

enddo

enddo

write(*,*)'ans',sum

stop

end

No comments:

Post a Comment

FORTRAN Program: Centigrade to Fahrenheit conversion and vice-versa

 c Centigrade to Fahrenheit conversion and vice-versa c Designed by anonymous. real c,f 33 write(*,*)'Please select the conversi...

Popular Posts