function [ Int,errorG2,exact] = trapezoid(interval,m,type)
a=interval(1);
b=interval(2);
step = (b-a)/m;
Int = 0;
switch type
    case 1
        f = str2func('g1');
         interval = [-4,4];
         exact=0.043662222222213;
    case 2
        f = str2func('g2');
         interval = [-4,4];
         exact=1.494267689296229;
    case 3
        f = str2func('g3');
        interval = [-4,4];
        exact=12.162401581657875;
    case 4
        f = str2func('g4');
        interval = [-4,-2,0.2,1.70,3.5,4];
        exact=31.817025833333332;
end

for i=1:m
    Int = Int + step*(1/2)*(f(a+(i-1)*step)+(f(a+i*step)));
        
end
    errorG2=(Int-exact);
end