%This function utilizes the Trapezoid rule for numerical integration over a
%specified number of subdomains of size n over the range of a to b for an
%arbitrary univariate function f(x).  Written by Philip Shaw, Fordham
%University, 2018.
function[In]=NCint(fx,a,b,n)
nlength=(b-a)/n;%size of intervals for cumulative integration
bgrid=a:nlength:b; %create sub-domains for b
for i=1:length(bgrid)-1
    a=bgrid(i); %lower bound of integration
    b=bgrid(i+1); %upper bound of subdomain
    I(i,1)=NC(fx,a,b); %perform numerical integration
end
In=sum(I); %sum over all points of integration