To evaluate an integral using trapezoids or Simpson's rule, we can use Mathematica's capabilities to our advantage.  Suppose we want to integrate f(x)=(x^3) over the interval [1,4] using n=20.  First, we will use trapezoids.  The semicolons at the end of the statements below just keep Mathematica from printing the results on the screen, and allow me to put more than one command in a single cell.

leftend = 1; rightend =4; num = 20;
width = (rightend - leftend)/num;
x[i_] := leftend + i*width;
f[x_] := x^3;
trapestimate = (Sum[2 f[x[i]], {i,1,num-1}]+f[leftend]+f[rightend])(width/2)

Let's look at a decimal.

N[trapestimate]

What is the actual value?

Integrate[x^3,{x,1,4}]

N[%]

Now for Simpson's.  I'll use a second sum to add in the additional terms.

leftend =1; rightend =4; num = 20;
width = (rightend - leftend)/num;
x[i_] := leftend + i*width;
f[x_] :=x^3;
simpestimate = (Sum[2 f[x[i]], {i,1,num-1}]+Sum[2f[x[i]],{i,1,num-1,2}]+f[leftend]+f[rightend])(width/3)

Wow.  An exact answer!  How did that happen?

N[%]