166SWC, 7.7 - Example 7: Simpson's (Parabolic) Rule and Error Bounds Discussion

Recall the Mathematica commands for approximation of
b
∫
a
f(x)x
with
M
n
or
T
n
:
In[]:=
MidpointSum[f_,a_,b_,n_]:=
n
∑
i=1
f[a+(2*i-1)*(b-a)/(2*n)]*(b-a)/n
In[]:=
Trapezoid[f_,a_,b_,n_]:=
n
∑
i=1
(1/2)(f[a+(i-1)*(b-a)/n]+f[a+i*(b-a)/n])*(b-a)/n

1. Construct a command 'Simpson[f_,a_,b_,n_]' that will perform Simpson's rule and compute
S
n
.
Note that n must be even and Δx=(b-a)/n.

2.Testthiscommandontheintegral​​
1
∫
0
sin(x)xwithn=6andcomparetotheresultswefoundforapproximationsforthisintegralvia
𝐿
n
,
𝑅
n
,
𝑀
n
and
𝑇
n
inExample1.

3. Find an upper bound for using Simpson’s Rule to estimate
1
∫
0
sin(
2
x
)x
with even positive integer n. Test this out with n = 10. Here are some ideas that may be useful:

To define the function
sin(
2
x
) with Mathematica, enter the command:
In[]:=
f[x_]:=Sin[x^2]
Here is how to find the fourth derivative of f:
f''''[x]
Out[]=
6(-4
2
x
Cos[
2
x
]-2Sin[
2
x
])+2x(-8xCos[
2
x
]-2x(2Cos[
2
x
]-4
2
x
Sin[
2
x
]))
If this is too complicated, you can use the 'Simplify' command:
Simplify[%]
Out[]=
-48
2
x
Cos[
2
x
]+4(-3+4
4
x
)Sin[
2
x
]
Here is one way to graph f''''[x]:
Plot[f''''[x],{x,0,1},Frame->True]
Out[]=

4.Findthesmallestevenpositiveintegernsothat​​I-
S
n
<0.001for
2
∫
-1
-
2
x
e
x.ComparethistowhatwefoundinExamples5and6.