function z = trapz(fx,a,b,n)
    x = linspace(a,b,n);
    y = fx(x);
    y(1) = 0.5 * y(1);
    y(end) = 0.5 * y(end);
    h = (b-a)/n;
    z = sum(y) * h;
    
    