INTERPOLATION DEMONSTRATION
!———————————————————————-- SUBROUTINE newtonForm(arr, row, str) IMPLICIT NONE REAL, DIMENSION(4,2) :: arr REAL, DIMENSION(4,5) :: mydata REAL, DIMENSION(5) :: yint REAL :: xterm INTEGER :: row, i, j CHARACTER(5) :: str mydata(1:4, 1:5) = 0 yint(1:5) = 0 !Store x values mydata(1:4,1) = arr(1:4,1) !Store y values mydata(1:4,2) = arr(1:4,2) DO j = 3,5,1 DO i = 1,(6-j),1 mydata(i, j) = (mydata(i+1, j-1) - mydata(i, j-1)) / (mydata(i+j-2,1) - mydata(i,1)) ENDDO ENDDO xterm = 1 yint(1) = mydata(1,2) IF (str == ’upper’) THEN DO i = 1,4,1 xterm = xterm * (upper(row,1) - mydata(i,1)) upper(row,3) = yint(1) + mydata(1,i+1) * xterm yint(i+1) = upper(row,2) ENDDO ELSEIF (str == ’lower’) THEN DO i = 1,4,1 xterm = xterm * (lower(row,1) - mydata(i,1)) lower(row,3) = yint(1) + mydata(1,i+1) * xterm yint(i+1) = lower(row,2) ENDDO ENDIF END SUBROUTINE newtonForm !———————————————————————-- END PROGRAM newtonPoly
← Previous Page
← Previous Page