c
c     Second Edition
c     Numerical Analysis:
c     The Mathematics of Scientific Computing
c     D.R. Kincaid & E.W. Cheney
c     Brooks/Cole Publ., 1996
c     ISBN 0-534-33892-5
c     COPYRIGHT (c) 1996
c
c     Section 6.1
c
c     Computing coefficients in the Newton Form of a polynomial
c
c
c     file: coef.f
c
      parameter (n=3)
      dimension x(0:n),y(0:n),c(0:n)
      data (x(i),i=0,n) /5.0,-7.0,-6.0,0.0/
      data (y(i),i=0,n) /1.0,-23.0,-54.0,-954.0/
c
      print *
      print *,' Coefficients in the Newton form of a polynomial'
      print *,' Section 6.1, Kincaid-Cheney'
      print *
c
      c(0) = y(0)
      print 4,0,c(0)
      do 3 k=1,n
         d = x(k) - x(k-1)
         u = c(k-1)
         do 2 i=k-2,0,-1
            u = u*(x(k) - x(i)) + c(i)
            d = d*(x(k) - x(i))
 2       continue
         c(k) = (y(k) - u)/d
         print 4,k,c(k)
 3    continue
c
 4    format (1x,'c(',i1,') =',2x,e13.6)
      stop
      end
