%composite trapezoid rule npt points
function A=ctraprule(fh,a,b,npt)
h=(b-a)/(npt-1);
x=a;
sum=0;
for i=2:npt-1
    x=x+h;
    sum=sum+fh(x);
end
sum=sum+(fh(a)+fh(b))/2;
A=h*sum;
end