% this has the integration for the trapezoidal rule, n can be an even
% or odd number.
% function [area,h,error] = trap(a,b,n)

function [area,h,error] = trap(a,b,n)

% interval length:
h = (b-a)/(n-1);

for i=1:n
% n mesh points, n-1 intervals:
  x(i) = a + (i-1)*h;
end

area = 0;

for i=1:n-1
  area = area + f(x(i))/2 + f(x(i+1))/2 ;
end
area = area*h;

error = (f_int(b)-f_int(a))-area;

