

function [ Int,E1,exact] = hw2(n, interval, type,m)
tic
switch type
    case 1
        f = str2func('g1');
         interval = [-4,4];
         exact=0.043662222222213;
    case 2
        f = str2func('g2');
         exact=1.494267689296229;
    case 3
        f = str2func('g3');
        exact=12.162401581657875;
    case 4
        f = str2func('g4');
        interval = [-4,-2,0.2,1.70,3.5,4];
        exact=31.817025833333332;
end

%INTEGRAL separates the function in intervals of the same function
%0   for those piecewise functions
%   n is the number of the function
%   a and b are the intervals in which we are going to look for
%   a starts in the leftmost point. b ends in the righmost point
%   Requires a previous plot of the function to choose them by hand


Int=gauss(n,f,m);
E1=abs(Int-exact)% / abs(exact)
toc
end
