% Evaluation of Integral with Gauss-Legendre Quadrature
% Based upon LegendrePoly function
% Text - Approximate int(exp(x^2),x=1.0 .. 1.5)
%      - Value to seven places = 0.1093643

Exact=0.1093643;
a=1.0;
b=1.5;
n=3;

% Get nodes
t=roots(LegendrePoly(n));
x=((b-a)*t+a+b)/2;

% Get Coeffs
% Use modified Vandermonde matrix routine - vander2()
A=vander2(t,2*n);
for j=1:2*n
   B(j)=(1^(j)-(-1)^(j))/j;
end
c=(B/A')';

% Quadrature
F=quadfun(x);
Q=sum(F.*c)*(b-a)/2;
display(['Result = ', num2str(Q), ' Error = ', num2str(abs(Q-Exact)) ]);





