ORIGINALLY CODED BY DANIEL YORGOV
(Modified by T.Olson, Feb.2008)

Clear[f, x, a, b, n, fun, exact, LFT, RGHT, TRAP, MID, 
        SIMP];
f[x_] := Sqrt[x];
a = 1;
b = 4;
nsubdivisions = 50;

    
exact[
          fun_] := (∫_a^b) fun[x] \[DifferentialD]x;
LFT[fun_, 
          n_] := (((b - a))/n) (∑_(i = 1)^n) f[
              a + (i - 1)*(((b - a))/n)];
RGHT[fun_, 
          n_] := (((b - a))/n) (∑_(i = 1)^n) f[
              a + i*(((b - a))/n)];
TRAP[fun_, n_] := (LFT[fun, n] + RGHT[fun, n])/2;
MID[fun_, 
          n_] := (((b - a))/n) (∑_(i = 1)^n) f[
              a + (2  i - 1)*(((b - a))/(2  n))];
SIMP[fun_, n_] := (2*MID[fun, n] + TRAP[fun, n])/3;

Print["Integrating ", f[x], " over  ", a, "<x<", 
        b];
Print["  exact value: ", N[exact[f], 10]];
Print["    LEFT(", nsubdivisions, ")= ", 
        N[LFT[f, nsubdivisions], 10], "     (error: ", 
        N[LFT[f, nsubdivisions] - exact[f], 
          10], ")"];
Print["   RIGHT(", nsubdivisions, ")= ", 
        N[RGHT[f, nsubdivisions], 10], "     (error: ", 
        N[RGHT[f, nsubdivisions] - exact[f], 10], ")"];
Print["    TRAP(", nsubdivisions, ")= ", 
        N[TRAP[f, nsubdivisions], 10], "     (error: ", 
        N[TRAP[f, nsubdivisions] - exact[f], 
          10], ")"];
Print["     MID(", nsubdivisions, ")= ", 
        N[MID[f, nsubdivisions], 10], "     (error: ", 
        N[MID[f, nsubdivisions] - exact[f], 10], ")"];

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

ORIGINALLY CODED BY DANIEL YORGOV
(Modified by T.Olson, Feb.2008)

f[x_] := Sqrt[x];
exact = (∫_1^4) f[x] \[DifferentialD]x;
n = 250;
LFT = (((4 - 1))/n) (∑_(i = 1)^n) f[
              1 + (i - 1)*(((4 - 1))/n)];
RGHT = (((4 - 1))/n) (∑_(i = 1)^n) f[
              1 + i*(((4 - 1))/n)];
TRAP = (LFT + RGHT)/2;
MID = (((4 - 1))/n) (∑_(i = 1)^n) f[
              1 + (2  i - 1)*(((4 - 1))/(2  n))];
SIMP = (2*MID + TRAP)/3;

Print["exact value:", N[exact, 10]];
Print["LEFT(", n, ")= ", N[LFT, 10], "    (error: ", 
        N[LFT - exact, 10], ")"];
Print["RIGHT(", n, ")= ", N[RGHT, 10], "    (error: ", 
        N[RGHT - exact, 10], ")"];
Print["TRAP(", n, ")= ", N[TRAP, 10], "    (error: ", 
        N[TRAP - exact, 10], ")"];
Print["MID(", n, ")= ", N[MID, 10], "    (error: ", 
        N[MID - exact, 10], ")"];

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

ERR5 = 2.4375 - 2.3982375

ERR50 = 2.4375 - 2.3982375

ERR50/ERR5