# Mathematica: The Command to Compute Error of Midpoint, Trapezoid, and Simpson's Rule

• Dec 3rd 2009, 08:40 AM
C.C.
Mathematica: The Command to Compute Error of Midpoint, Trapezoid, and Simpson's Rule
This is the Mathematica code I have been using, basically altered so that it will compute Simpson's Rule after I have defined my function:

a = 0.6;
b = 1.5;
n = 192;
Deltax = (b - a)/n;
Sn[i_] = a + i*Deltax;
Table[xi[i], {i, 0, n}]
Sum[f[Sn[2 n - 1]], {i, 1, n - 1}]*(4 Deltax/3) +
Sum[f[xSim[2 n]], {i, 2, n - 2}]*(2 Deltax/3) + (Deltax/3)*(f[0.6] +
f[1.5])
N[%]

Unfortunately, I have no idea how to edit it in a way that will compute a table of errors.

http://archives.math.utk.edu/visual.calculus/4/approx.2/index.html

That is the webpage I am referring to for the formula of the error values. This lab is due very soon, and help would be absolutely wonderful.

The questions to my assignment are:

(a) Using Mathematica, create a table of the Midpoint, Trapezoid and \
Simpson's Rule approximations (denote them Mn, Tn and Sn \
respectively) for each of the following n: 3, 6, 12, 24, 48, 96, \
192. You should be able to alter the code above to make these.

(b) Make a corresponding table that gives the errors of these values \
(denote them EMn, ETn, ESn). To compute the error you should use \
-0.1785791162767406 as the actual value.

I have already finished (a), but I am completely stuck on (b).