function [area,error]=trapint(polynomial,upper_limit,lower_limit,resolution)
% Trapezoidal Numerical Integration Method
% Duane Hill
% Spring 1999 -- ECE 5130 Computational Methods for Electromagnetics
%
% Usage:
% polynomial -- array of coefficients of polynomial to be integrated
% upper_limit -- upper limit of definite integral
% lower_limit -- lower limit of definite integral
% resolution -- number of points in integral
%
% Returns:
% area -- area under the curve
% error -- error term


% BEGIN
% 
% Variable Declaration
% A -- Area under curve; initially set to 0
% f0 -- first point
% f1 -- second point
% numpoints -- number of points between a and b with given resolution
% funct -- array of points at vertices of trapezoids
%           when evaluated by function
% increment -- increment step;  = (b-a)/numpoints
%
% deriv -- array of derivatives corresponding to points

% Initialization
area=0;
f0=lower_limit;
numpoints = 10;

% Calculate points array
increment=(upper_limit-lower_limit)/numpoints;
funct=zeros(numpoints,1);
for i =1:numpoints+1
   funct(i)=polyval(polynomial,f0);
   f0=f0+increment;
end

% Calculate Area
for i=1:numpoints
   f0=funct(i);
   f1=funct(i+1);
   area=area+(f0+f1)/2*increment;
end

% Calculate the Error

