      program newton_x5
C
C  illustrates Newton-Raphson root finding 
C  with function x^5-5
C
C  CWJ SDSU 3/2005
C
      implicit none

      real x

      integer i
      integer nsteps

      real func,dfunc

      print*,' enter number of steps '
      read*,nsteps
      print*,' enter starting x '
      read*,x

      do i = 1,nsteps
        x = x -func(x)/dfunc(x)
        print*,x
      enddo 

      end


      real function func(x)
      implicit none
      real x
 
      func = (exp(x)-exp(-x))/(exp(x)+exp(-x)) 
      return
      end

      real function dfunc(x)
      implicit none
      real x
 
      dfunc = 1./(exp(x)+exp(-x))**2 
      return
      end


