      program teach061
      implicit real*8 (a-h,o-z)
c
      n=100000
      pi=4*atan(1.0d0)
      g=9.8d0
      a=0.0d0
      T0=2*pi/sqrt(g)
      xmax=pi/2
      open(16,file='teach061.dat')
      write( *,'(a)') '# x0, T, T0, T-T0'
      write(16,'(a)') '# x0, T, T0, T-T0'
      do i=1,100
         x0=xmax/100*i
         b=x0
         call chuten(x0,a,b,n,T)
         T1=4.0d0/sqrt(g)*T
         write( *,800) real(x0),real(T1),real(T0),real(T1-T0)
         write(16,800) real(x0),real(T1),real(T0),real(T1-T0)
      enddo
 800  format(4(1x,1pe12.5))
      end
c **********************************************************************
      subroutine chuten(x0,a,b,n,sum)
c **********************************************************************
      implicit real*8 (a-h,o-z)
c
      sum = 0.0d0
      dx = (b - a)/n
      do i = 1, n
         x = a + (i - 0.5d0)*dx
         sum = sum + fv(x,x0)
      end do
      sum = sum*dx
C
      return
      end
c **********************************************************************
      function fv(x,x0)
c **********************************************************************
      implicit real*8 (a-h,o-z)
      fv=1.0d0/sqrt(2*(cos(x)-cos(x0)))
      end
