function xint = gauss4pts05(f, a, b, varargin)
% 1D Gauss-Legendre quadrature using 4 points.
% INPUT:
% f = integrand function (a string) must be in an m-file
% a = lower limit of integration
% b = upper limit of integration
% Local variables:
% r = positive roots of Gauss-Legendre quadrature 
% w = wts of Gauss-Legendre quadrature
% xint = value of the integral
% OUTPUT:
% xint = value of the 4-pt Gauss-Legendre quadrature
% K. Ming Leung, 08/11/03


% 4-pt roots and weights:
r30 = sqrt(30); r3070 = 70*r30; 
r = [ sqrt(525-r3070)/35 sqrt(525+r3070)/35 ];
w = [ (18+r30)/36 (18-r30)/36 ];

A = (b-a)/2;    % parameter A for current segment 
B = (b+a)/2;    % parameter B for current segment
Ar = A*r;
xint = A*sum(w.*(feval(f,B+Ar,varargin{:})+feval(f,B-Ar,varargin{:})));
