


      integer size
      parameter(size=10)
      real x(size),w(size)
      integer n
      integer i

      real a,b

      real xx
      real func

      real sum
      real exactsum      

      print*,' Enter a,b of interval '
      read*,a,b
      print*,' Enter n  (1-4) '     
      read*,n

      call gausslegendre(n,size,x,w)

      sum = 0.0
      do i =1,n
	xx = x(i)*(b-a)/2. + (b+a)/2.
        sum = sum + w(i) *func(xx)
      enddo
      sum = sum*(b-a)/2.

      print*,' Approx   exact   % error '
      print*,sum,exactsum(a,b),100*(1.0-sum/exactsum(a,b))


      end

CCCCCCCCCCCCCCCCCCCCCCCCCCCC

      real function func(x)
      implicit none
      real x

      func = x/(1.+x**2)

      return
      end

CCCCCCCCCCCCCCCCCCCCCCCCCC

      real function exactsum(a,b)
      implicit none
      real a,b

      exactsum = 0.5*log(1+b**2) - 0.5*log(1+a**2)

      return
      end

      
