Professional Documents
Culture Documents
Theorem (Trapezoidal Rule) Consider y = f (x) over [x0 , x1 ], where x1 = x0 + h. The trapezoidal
rule is
h
TR (f, h) = 2
(f (x0 ) + f (x1 )).
This is an numerical approximation to the integral of f (x) over [x0 , x1 ] and we have the expression
1x
∫x0 f (x) ⅆx ≈ TR (f, h).
Theorem (Composite Trapezoidal Rule) Consider y = f (x) over [a, b]. Suppose that the interval
b-a
[a, b] is subdivided into m subintervals {[xk-1 , xk ]}mk=1 of equal width h = m
by using the
equally spaced nodes xk = x0 + k h for k = 1, 2, ..., m. The composite trapezoidal rule for m
subintervals is
h
T (f, h) = 2
(f (a) + f (b)) + h ∑mk=1 f (xk ).
This is an numerical approximation to the integral of f (x) over [a, b] and we write
b
∫a f (x) ⅆx ≈ T (f, h).
2
Example 1. Numerically approximate the integral ∫0 2 + Cos2 x ⅆx by using the trape-
zoidal rule with m = 1, 2, 4, 8, and 16 subintervals.
Solution 1.
f[x_] = 2 + Cos2 x ;
coseno
Out[4]= 3.46
2-0
1
In[2]:= t1 = f[0] + f[2.]
2
Out[2]= 4.04864
2-0
2
In[3]:= t2 = f[0] + 2 f[1] + f[2.]
2
Out[3]= 3.60817
2-0
4 1 3
In[5]:= t4 = f[0] + 2 f + 2 f[1] + 2 f + f[2.]
2 2 2
Out[5]= 3.4971
2-0
8 1 1 3 5 3 7
In[6]:= t8 = f[0] + 2 f + 2 f + 2 f + 2 f[1] + 2 f + 2 f + 2 f + f[2.]
2 4 2 4 4 2 4
Out[6]= 3.46928
2-0
16 1 1 3 1 5 3 7
In[7]:= t16 = f[0] + 2 f + 2 f + 2 f + 2 f + 2 f + 2 f + 2 f + 2 f[1] +
2 8 4 8 2 8 4 8
9 5 11 3 13 7 15
2 f + 2 f + 2 f + 2 f + 2 f + 2 f + 2 f + f[2.]
8 4 8 2 8 4 8
Out[7]= 3.46232
h
SR (f, h) = 3
(f (x0 ) + 4 f (x1 ) + f (x2 )).
This is an numerical approximation to the integral of f (x) over [x0 , x2 ] and we have the expression
2x
∫x0 f (x) ⅆx ≈ SR (f, h).
Corollary (Simpson's Rule: Remainder term) Suppose that [a, b] is subdivided into 2 m subintervals
b-a
{[xk-1 , xk ]}2k=1
m of width h =
2m
. The composite Simpson's rule
h 2h 4h
S (f, h) = 3
(f (a) + f (b)) + 3
∑m-1
k=1 f (x2 k ) + 3
∑mk=1 f (x2 k-1 ).
b
∫a f (x) ⅆx = S (f, h) + ES (f, h).
Furthermore, if f (x) ∈ C4 [a, b], then there exists a value c with a < c < b so that the error term
ES (f, h) has the form
(b - a) f4 (c)
ES (f, h) = - 180
h4 .
Solution 1.
f[x_] = 2 + Cos2 x ;
coseno
f[x_] = 2 + Cos2 x ;
coseno
2-0
2
In[8]:= s1 = f[0] + 4 f[1] + f[2.]
3
Out[8]= 3.46135
2-0
4 1 3
In[9]:= s2 = f[0] + 4 f + 2 f[1] + 4 f + f[2.]
3 2 2
Out[9]= 3.46008
2-0
8 1 1 3 5 3 7
In[10]:= s4 = f[0] + 4 f + 2 f + 4 f + 2 f[1] + 4 f + 2 f + 4 f + f[2.]
3 4 2 4 4 2 4
Out[10]= 3.46
2-0
16 1 1 3 1 5 3 7
s8 = f[0] + 4 f + 2 f + 4 f + 2 f + 4 f + 2 f + 4 f + 2 f[1] +
3 8 4 8 2 8 4 8
9 5 11 3 13 7 15
4 f + 2 f + 4 f + 2 f + 4 f + 2 f + 4 f + f[2]
8 4 8 2 8 4 8