      subroutine nderiv(h,y,z,ndim)
c     subroutine ddet5(h,y,z,ndim)
c      ssp routine modified by nawh 6/8/76
      implicit real*8 (a-h,o-z)
      real*8 y(ndim),z(ndim)
c        prepare differentiation loop
      hh=.08333333333333333d0/h
      yy=y(ndim-4)
      b=hh*(-25.d0*y(1)+48.d0*y(2)-36.d0*y(3)+16.d0*y(4)-3.d0*y(5))
      c=hh*(-3.d0*y(1)-10.d0*y(2)+18.d0*y(3)-6.d0*y(4)+y(5))
c
c        start differentiation loop
      do 3 i=5,ndim
      a=b
      b=c
      c=hh*(y(i-4)-y(i)+8.d0*(y(i-1)-y(i-3)))
    3 z(i-4)=a
c        end of differentiation loop
c
c        normal exit
      ier=0
     0a=hh*(-yy+6.d0*y(ndim-3)-18.d0*y(ndim-2)+10.d0*y(ndim-1)
     1      +3.d0*y(ndim))
     0z(ndim)=hh*(3.d0*yy-16.d0*y(ndim-3)+36.d0*y(ndim-2)
     1            -48.d0*y(ndim-1)+25.d0*y(ndim))
      z(ndim-1)=a
      z(ndim-2)=c
      z(ndim-3)=b
c
      return
      end
