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 3.5
c
c     Example of Newton's Method on a polynomial of degree n
c
c     Given starting point z
c     Coefficients in the polynomial:
c     a(0) is the constant term and a(n) is the coefficient of z**n
c
c
c     file: ex6s35.f
c
      dimension a(0:4)
      data a/-2.0,-5.0,7.0,-4.0,1.0/
      data n/4/
c
      print *
      print *,' Newton''s method on a given polynomial'
      print *,' Section 3.5, Kincaid-Cheney'
      print *
c
      print *,'   j        alpha            beta               z'
      z = 0.0
      call horner(n,a,z)
      stop
      end
c
      subroutine horner(n,a,z)
      dimension a(0:n)
      data epsi/.5e-5/
      do 3 j=1,8
         alpha = a(n)
         beta = 0.0
         do 2 k=n-1,0,-1
            beta = alpha + z*beta
            alpha = a(k) + z*alpha
 2       continue   
         z1 = z - alpha/beta
         if (abs(z1-z) .lt. epsi) stop
         z = z1
         print 4,j,alpha,beta,z
 3    continue
c     
 4    format(1x,i3,2x,3(e15.8,2x))
      return
      end
