ccccccccccccccccccccccccc     Program 6.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 BENCH
C
C This program solves the problem of a person sitting on a
C bench as described in the text. 
C
      PARAMETER (N = 99)
      DIMENSION B(N),X(N),Y(N),W(N),U(N)
C
      XL  = 3.0
      H   = XL/(N+1)
      H2  = H*H
      Y0  = 1.0E09*0.03**3*0.20/3.0
      X0  = 0.25
      RHO = 3.0
      G   = 9.8
      F0  = 200.0
      D   = 2.0
      E   =-1.0
      E0  = 1.0/EXP(1.0)
C
C Find elements in L and U
C
      W(1) =  D
      U(1) =  E/D
      DO    100 I = 2, N
        W(I) = D-E*U(I-1)
        U(I) = E/W(I)
  100 CONTINUE
C
C Assign the array B
C
      DO    200 I = 1, N
        XD   =  H*I
        B(I) = -H2*RHO*G
        IF (ABS(XD-XL/2.0).LT.X0) THEN
          B(I) = B(I)-H2*F0
     *          *(EXP(-((XD-XL/2)/X0)**2)-E0)
        ELSE
        ENDIF
        B(I) = B(I)/Y0
  200 CONTINUE
C
C Find the solution of the curvature
C
      Y(1) = B(1)/W(1)
      DO   300 I = 2, N
        Y(I) = (B(I)+Y(I-1))/W(I)
  300 CONTINUE
C
      X(N) = Y(N)
      DO   400 I = N-1,1,-1
        X(I) = Y(I)-U(I)*X(I+1)
  400 CONTINUE
      WRITE(6,9999) (H*I,100*X(I),I=1,N)
      STOP
 9999 FORMAT(2F20.10)
      END
