format long

% define the function F as a function handle
% to the function myF, which is defined in a
% separate m-file myF.m, that needs to be in the
% same directory as this script myIntegralNew.m
F=@myF;

% the integration interval
a=-2;
b=2;

% the number of intervals in the composite rule
n=8;

% invoke the Trapezoid and the Simpson rules...
resultTrapezoid = Trapezoid(a,b,n,F)
resultSimpson = Simpson(a,b,n,F)

% a highly accurate approximation
exact = 1.76416278196829

% the differences between your results and the highly accurate result;
% how do you compare... ?
% if you increase n above, the error should decrease
errorTrapezoid=exact-resultTrapezoid
errorSimpson=exact-resultSimpson
