function [area, error] = trapezoidIntegrate(dx)
xMin = 0; % minimum x value
xMax = pi/2; % maximum x value
x = xMin:dx:xMax; % all x values

%1) Compute a y vector to be the sine of each element of the x vector.

%2) Plot x versus y

%3) Compute the approximate area under the curve as the sum of the 
%   trapezoids bounded by each adjacent pair of points and the x axis.
%   Essentially, you'll average the height (y) of the pair and multiply
%   by the width between them.  Finally, you'll sum these values.
%   Hint: Perform all of these operations using vectors so that you can
%   make use of Matlab's sum function.

exactArea = -cos(xMax) - -cos(xMin);
error = exactArea - area;
disp(sprintf('From %g to %g with step %g, the approximate area is %g.', xMin, xMax, dx, area))
disp(sprintf('The actual area is %g, so the error is %g\n', exactArea, error))
end
