ccccccccccccccccccccccccc     Program 2.8     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 ROOT
C
C Main program to use the Secant Method to find the root of
C f(x)=exp(x)*ln(x)-x*x=0.
C
      DL = 1.0E-06
      A  = 1.0
      B  = 2.0
      DX = (B-A)/10.
      X0 = (A+B)/2.0
      CALL SECANT (DL,X0,DX,ISTEP)
      WRITE (6,999) ISTEP,X0,DX
      STOP
  999 FORMAT (I4,2F16.8)
      END
C
      SUBROUTINE SECANT (DL,X0,DX,ISTEP)
C
C Subroutine for the root of f(x)=0 with the secant method.
C
      ISTEP = 0
      X1 = X0 + DX
      DO    100  WHILE (ABS(DX).GT.DL)
        D  = F(X1) - F(X0)
        X2 = X1 - F(X1)*(X1-X0)/D
        X0 = X1
        X1 = X2
        DX = X1 - X0
        ISTEP = ISTEP + 1
  100 END DO
      RETURN
      END
C
      FUNCTION F(X)
        F = EXP(X)*ALOG(X) - X*X
      RETURN
      END
