ccccccccccccccccccccccccc     Program 3.1     cccccccccccccccccccccccccc
c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c                                                                      c
c Please Note:                                                         c
c                                                                      c
c (1) This computer program is part of the book, "An Introduction to   c
c     Computational Physics," written by Tao Pang and published and    c
c     copyrighted by Cambridge University Press in 1997.               c
c                                                                      c
c (2) No warranties, express or implied, are made for this program.    c
c                                                                      c
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
      PROGRAM ONE_D_MOTION2
C
C Simplest predictor-corector algorithm applied to a particle
C in one dimension under an elastic force.
C
      PARAMETER (N = 101,IN= 5)
      REAL T(N),V(N),X(N)
C
      PI  = 4.0*ATAN(1.0)
      DT  =2.0*PI/100
      X(1)=0.0
      T(1)=0.0
      V(1)=1.0
C
      DO     100 I = 1, N-1
        T(I+1) = I*DT
C
C Predictor for position and velocity
C
        X(I+1) = X(I) + V(I)*DT
        V(I+1) = V(I) - X(I)*DT
C
C Corrector for position and velocity
C
        X(I+1) = X(I) + (V(I)+V(I+1))*DT/2.
        V(I+1) = V(I) - (X(I)+X(I+1))*DT/2.
  100 CONTINUE
      WRITE(6,999) (T(I),X(I),V(I),I=1,N,IN)
      STOP
  999 FORMAT (3F14.8)
      END
