c
c     Second Edition
c     Numerical Analysis:
c     The Mathematics of Scientific Computing
c     D.R. Kincaid & E.W. Cheney
c     Brooks/Cole Publ., 1996
c     ISBN 0-534-33892-5
c     COPYRIGHT (c) 1996
c
c     Section 3.3
c
c     Example of Secant Method
c
c
c     file: ex1s33.f
c
      data  a/7.0/, b/8.0/, M/20/
      data epsi/1.0e-6/, delta/1.0e-6/
      fa = f(a)
      fb = f(b)
c
      print *
      print *,' Secant Method Example'
      print *,' Section 3.3, Kincaid-Cheney'
      print *
c
      print *,'    n        x(n)         f(x(n))'
      print 3,0,a,fa
      print 3,1,b,fb
c
      do 2 k = 2,M
         if (abs(fa) .le. abs(fb)) then
            tmp = a
            a = b
            b = tmp
            tmp = fa
            fa = fb
            fb = tmp
         endif
         s = (b - a)/(fb - fa)
         a = b
         fa = fb
         b = b - fb*s
         fb = f(b)
         print 3,k,b,fb
         if ((abs(fb) .lt. epsi) .or. (abs(a - b) .lt. delta)) stop
 2    continue
      print 3,M,b,f(b)
c
 3    format(2x,i3,2(2x,e13.6))   
      stop
      end
c
      function f(x)
      f = (((x + 4.0)*x + 6.0)*x + 9.0) - sinh(x)
      return
      end
