function I = rule3_8(f, a, b, N)
if mod(N,3) ~= 0
fprintf('Error: N has to be divisible by 3\n');
end;
dx = (b - a) / N;
S = f(a) + f(b);
for i = 1 : N-1
yi = f(a + i * dx);
if mod(i, 3) ~= 0
S = S + 3 * yi;
else
S = S + 2 * yi;
end;
end
I = S * 3 / 8 * dx;