      program RK
      implicit real*8 (a-h,k,o-z)
      parameter (N=10)
      dimension x(0:N),y(0:N)
      
      x(0)= 0d0
      x(N)= 1d0
      h=(x(N)-x(0))/N
      print*,'N   =',N
      print*,'x(0)=',x(0)
      print*,'x(N)=',x(N)
      print*,'h   =',h
      print*
      
      do i=0,N
         x(i)=i*h+x(0)
      enddo
      
      y(0)=1d0
      print '(3x,''i'',14x,''x'',14x,''y'',11x,''y_an'')'
      print '(i4,3f15.10)',0,0d0,y(0),1d0
      do i=0,N-1
         k1=h*f(x(i),y(i))
         k2=h*f(x(i)+h,y(i)+k1)
         y(i+1)=y(i)+(k1+k2)/2
         print '(i4,3f15.10)',i+1,x(i+1),y(i+1)
     &        ,2d0*dexp(x(i+1))-x(i+1)-1d0
      enddo
      
      pause
      end
      
      function f(x,y)
      implicit real*8 (a-h,o-z)
      f=x+y
      return
      end
