function IT = trap_func(f,a,b,n)
% Function to calculate an estimate of the integral of f(x) on [a,b]
% using the trapezoidal rule with n sub-intervals

h = (b-a)/n;

% Numerical Integral
IT=0;
for i=1:n
    IT = IT+(f(a+(i-1)*h) + f(a+i*h))*h/2;
end