APPROXIMATE INTEGRATION
ELECTRONIC VERSION OF LECTURE
Dr. Lê Xuân Đại
HoChiMinh City University of Technology
Faculty of Applied Science, Department of Applied Mathematics
Email:
[email protected] HCMC — 2017.
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 1 / 34
OUTLINE
1 PROBLEMS
2 TRAPEZOIDAL RULE
3 SIMPSON’S RULE
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 2 / 34
Problems
PROBLEMS
There are two situations in which it is impossible to
find the exact value of a definite integral.
1
It is difficult, or even impossible, to find an
Z Z 1 1p
2
antiderivative. For example ex dx, 1 + x3 dx.
0 −1
2
The function is determined from a scientific
experiment through instrument readings or
collected data. There may be no formula for the
function.
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 3 / 34
Trapezoidal Rule Riemann sum
RIEMANN SUM
Suppose the interval [a, b] is partitioned into n equal
b−a
parts, each of width ∆x = h = by the subdivision
n
points a = x0 , x1 = x0 + h, . . . , xk = x0 + kh, . . . , xn = b.
Then we have
Z b n
X
f (x)dx ≈ f (xi∗ )∆x, (1)
a i=1
where xi∗ is any point in the ith subinterval [xi−1 , xi ].
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 4 / 34
Trapezoidal Rule Left endpoint approximation
If xi∗ is chosen to be the left endpoint of the interval,
then xi∗ = xi−1 and we have
Z b n
X
f (x)dx ≈ Ln = f (xi−1 )∆x (2)
a i=1
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 5 / 34
Trapezoidal Rule Right endpoint approximation
If xi∗ is chosen to be the right endpoint of the
interval, then xi∗ = xi and we have
Z b n
X
f (x)dx ≈ Rn = f (xi )∆x (3)
a i=1
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 6 / 34
Trapezoidal Rule Midpoint approximation
If xi∗ is chosen to be the midpoint of the interval,
xi−1 + xi
then xi∗ = and we have
2
Z b n ³x + x ´
i−1 i
∆x
X
f (x)dx ≈ Mn = f (4)
a i=1 2
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 7 / 34
Trapezoidal Rule Trapezoidal Rule
TRAPEZOIDAL RULE
Let yk = f (xk ), k = 0, 1, . . . , n
hh i
The kth trapezoid has area f (xk−1 ) + f (xk ) .
2
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 8 / 34
Trapezoidal Rule Trapezoidal Rule
So the sum of these areas of n trapezoids is
Zb Zx1 Zx2 Zxn
f (x)dx = f (x)dx + f (x)dx + . . . + f (x)dx
a x0 x1 xn−1
y0 + y1 y1 + y2 yn−1 + yn
≈ Tn = h · +h· +...+h·
2 2 2
h h i
= · y0 + 2y1 + 2y2 + . . . + 2yn−1 + yn
2
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 9 / 34
Trapezoidal Rule Error Bounds
ERROR BOUNDS
DEFINITION 2.1
The error in using an approximation is defined to be
the amount that needs to be added to the
approximation to make it exact.
Z b
f (x)dx = approximation + error (5)
a
In general, we have
Z b Z b
ET = f (x)dx − Tn , EM = f (x)dx − Mn
a a
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 10 / 34
Trapezoidal Rule Error Bounds
THEOREM 2.1
Suppose |f 00 (x)| É K , for a É x É b. If ET and EM are the
errors in the Trapezoidal and Midpoint Rules, then
K (b − a)3 K (b − a)3
|ET | É , |EM | É (6)
12n2 24n2
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 11 / 34
Trapezoidal Rule Error Bounds
EXAMPLE 2.1
Use the Trapezoidal Rule and Left endpoint, Right
endpoint, Midpoint Rules with n = 5 to approximate
2
dx
Z
the integral ·
1 x
SOLUTION.
2−1 1 k 1 5
h= = , x0 = 1, xk = 1 + , yk = f (xk ) = =
5 5 5 1 + k5 5 + k
h P
µ ¶
4 1 P4 5 5
I≈ (yk + yk+1 ) = + ≈ 0.695635
2 k=0 20 k=0 5 + k 5 + (k + 1)
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 12 / 34
Trapezoidal Rule Error Bounds
h³ ´
I ≈ y0 + 2y1 + 2y2 + 2y3 + 2y4 + y5
2
CASIO.
0.2
A = A+ × B × (1 ÷ X ) : X = X + 0.2
2
CALC A=0, X=1, B=1=.
A=, X=, B=2=.
...,...,...
A=, X=2, B=1=.
Answer: I ≈ 0.695635
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 13 / 34
Trapezoidal Rule Error Bounds
MIDPOINT
h ³x + x ´ ³x + x ´ ³x + x ´
0 1 1 2 2 3
I ≈h f +f +f +
2 2 2
³x + x ´ ³x + x ´i
3 4 4 5
+f +f
2 2
CASIO.
A = A + 0.2 × (1 ÷ X ) : X = X + 0.2
CALC A=0, X=1.1.
A=, X=.
...,...,...
A=, X=1.9.
Answer: I ≈ 0.691908
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 14 / 34
Trapezoidal Rule Error Bounds
LEFT ENDPOINT
h i
I ≈ h f (x0 ) + f (x1 ) + f (x2 ) + f (x3 ) + f (x4 )
CASIO.
A = A + 0.2 × (1 ÷ X ) : X = X + 0.2
CALC A=0, X=1.
A=, X=.
...,...,...
A=, X=1.8.
Answer: I ≈ 0.745635
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 15 / 34
Trapezoidal Rule Error Bounds
RIGHT ENDPOINT
h i
I ≈ h f (x1 ) + f (x2 ) + f (x3 ) + f (x4 ) + f (x5 )
CASIO.
A = A + 0.2 × (1 ÷ X ) : X = X + 0.2
CALC A=0, X=1.2.
A=, X=.
...,...,...
A=, X=2.
Answer: I ≈ 0.645635
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 16 / 34
Trapezoidal Rule Error Bounds
2
dx
Z
Approximations to
1 x
n Ln Rn Tn Mn
5 0.745635 0.645635 0.695635 0.691908
10 0.718771 0.668771 0.693771 0.692835
20 0.705803 0.680803 0.693303 0.693069
2
dx
Z ¯2
The exact value = ln x¯ = ln 2.
¯
1 x 1
Corresponding errors
n EL ER ET EM
5 -0.052488 0.047512 -0.002488 0.001239
10 -0.025624 0.024376 -0.000624 0.000312
20 -0.012656 0.012344 -0.000156 0.000078
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 17 / 34
Trapezoidal Rule Error Bounds
EXAMPLE 2.2
UseZthe trapezoial rule with n = 10 to estimate
1
dx
I= ·
0 1+x
SOLUTION.
b−a 1−0 1 k
h= = = , x0 = 0, xk = ,
n 10 10 10
1 10
yk = f (xk ) = =
k 10 + k
1+
10
h P
µ ¶
9 1 P9 10 10
I≈ (yk + yk+1 ) = + ≈ 0.6938
2 k=0 20 k=0 10 + k 10 + (k + 1)
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 18 / 34
Trapezoidal Rule Error Bounds
h³ ´
I ≈ y0 +2y1 +2y2 +2y3 +2y4 +2y5 +2y6 +2y7 +2y8 +2y9 +y10
2
CASIO.
0.1
A = A+ × B × (1 ÷ (1 + X )) : X = X + 0.1
2
CALC A=0, X=0, B=1=.
A=, X=, B=2=.
...,...,...
A=, X=1, B=1=.
Answer: I ≈ 0.6938
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 19 / 34
Trapezoidal Rule Error Bounds
EXAMPLE 2.3
How large should we take n in order to guarantee that
the ZTrapezoidal and Midpoint Rule Approximations
2
dx
for are accurate to within 0.0001?
1 x
2
SOLUTION. f 00 (x) = 3 . So
x
2(2 − 1)3
¯ ¯
00
¯2¯
|f (x)| = ¯ 3 ¯ É 2, ∀x ∈ [1, 2] ⇒ |ET | É
¯ ¯ < 0.0001
x 12n2
1
⇒n> p ≈ 40.8 ⇒ n = 41.
0.0006
2(2 − 1)3 1
|EM | É < 0.0001 ⇒ n > p ≈ 28.86 ⇒ n = 29.
24n2 0.0012
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 20 / 34
Trapezoidal Rule Error Bounds
EXAMPLE 2.4
If the function f (x) is defined by table
x 1.0 1.2 1.4 1.6 1.8 2.0 2.2
then using
f (x) 4 3.3 2.4 4.3 10.2 6.2 7.4
the Trapezoidal Rule to approximate the integral
2.2
(xf 2 (x) + 4.4x3 )dx
R
I=
1.0
b − a 2.2 − 1.0
h= = = 0.2 ⇒ n = 6, x0 = 1.0, xk = 1.0 + 0.2k,
n n
yk = xk f 2 (xk ) + 4.4xk3 .
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 21 / 34
Trapezoidal Rule Error Bounds
Therefore
h P
5 h
I≈ (yk + yk+1 ) = (y0 + 2y1 + 2y2 + 2y3 + 2y4 + 2y5 + y6 ).
2 k=0 2
CASIO h = 0.2, we have
h
A = A+ × B × (XY 2 + 4.4X 3 ) : X = X + h
2
CALC A=0, X=1.0, Y=4, B=1=.
CALC A=, X=, Y=3.3, B=2=.
...,...,...
CALC A=, X=2.2, Y=7.4, B=1=.
Answer. I ≈ 101.4579
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 22 / 34
Simpson’s Rule
SIMPSON’S RULE
Another rule for approximate integration results
from using parabolas instead of straight line
segments to approximate a curve.
Suppose the interval [a, b] is partitioned into 2n equal
b−a
parts, each of width ∆x = h = by the subdivision
2n
points a = x0 , x1 = x0 + h, . . . , xk = x0 + kh, . . . , x2n = b. Let
yk = f (xk ), k = 0, 1, . . . , 2n
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 23 / 34
Simpson’s Rule
We know that the equation of the parabola through
P0 , P1 and P2 is of the form y = A(x − x1 )2 + B(x − x1 ) + C
and so the area under the parabola from x0 = x1 − h to
x2 = x1 + h is
Z x2 h i Z h
2
A(x − x1 ) + B(x − x1 ) + C dx = (At 2 + Bt + C)dt
x0 −h
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 24 / 34
Simpson’s Rule
Z h Z h
2
(At + Bt + C)dt = 2 (At 2 + C)dt =
−h 0
· 3 ¸h
x h
= 2 A + Cx = (2Ah2 + 6C)
3 0 3
But, since the parabola passes through P0 (x0 , y0 ),
P1 (x1 , y1 ), and P2 (x2 , y2 ), we have
y0 = A(−h)2 + B(−h) + C = Ah2 − Bh + C
y1 = C
y2 = Ah2 + Bh + C
and therefore y0 + 4y1 + y2 = 2Ah2 + 6C. Thus the area
h
under the parabola is (y0 + 4y1 + y2 ).
3
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 25 / 34
Simpson’s Rule
Similarly, the region under the curve y = f (x) on each
hh i
interval [xk , xk+2 ] has area f (xk ) + 4f (xk+1 ) + f (xk+2 ) .
3
So the sum of these areas of n regions is
Z b Z x2 Z x4 Z x2n
f (x)dx = f (x)dx + f (x)dx + . . . + f (x)dx
a x0 x2 x2n−2
h h h
≈ (y0 +4y1 +y2 )+ (y2 +4y3 +y4 )+..+ (y2n−2 +4y2n−1 +y2n ) =
3 3 3
h ³ ´
= y0 + 4y1 + 2y2 + 4y3 + 2y4 + . . . + 2y2n−2 + 4y2n−1 + y2n
3
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 26 / 34
Simpson’s Rule
ERROR BOUNDS
THEOREM 3.1
Suppose |f (4) (x)| É K , for a É x É b. If ES is the error
involved in using Simpson’s Rule, then
K (b − a)5
|ES | É (7)
2880n4
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 27 / 34
Simpson’s Rule
EXAMPLE 3.1
UseZSimpson’s rule with 2n = 20 to approximate
1
dx
I= and estimate the error involved in this
0 1+x
approximation.
SOLUTION.
b−a 1−0 1 k
h= = = , x0 = 0, xk = ,
2n 20 20 20
1 20
yk = f (xk ) = k
= ·
1 + 20 20 + k
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 28 / 34
Simpson’s Rule
Therefore
h n−1
X
I≈ (y2k + 4y2k+1 + y2k+2 ) =
3 k=0
9 µ ¶
1 X 20 20 20
= +4 + ≈ 0.6931
60 k=0 20 + 2k 2k + 21 2k + 22
h³
I ≈ y0 +4y1 +2y2 +4y3 +2y4 +4y5 +2y6 +4y7 +2y8 +4y9 +2y10 +
3
´
+4y11 +2y12 +4y13 +2y14 +4y15 +2y16 +4y17 +2y18 +4y19 +y20
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 29 / 34
Simpson’s Rule
CASIO.
B 1 1
A = A+ × :X =X+
6 × 10 X + 1 2 × 10
CALC A=0, B=1, X=0;
A=, B=4;X=;
A=, B=2;X=;
A=, B=4;X=;
A=, B=2;X=;
......
A=, B=1;X=1;
Answer. I ≈ 0.6931
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 30 / 34
Simpson’s Rule
1 4!
The fourth derivative of f (x) = is f (4) (x) =
1+x (1 + x)4
⇒ |f (4) (x)| É 4!, ∀x ∈ [0, 1].
So we see that the error is at most
4!(1 − 0)5
4
≈ 8.33−7
2880 × 10
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 31 / 34
Simpson’s Rule
EXAMPLE 3.2
Suppose the function f (x) is defined by table
x | 1.0 1.2 1.4 1.6 1.8 2.0 2.2
. Using
f (x) | 2 3.3 2.4 4.3 5.1 6.2 7.4
Simpson’s rule to approximate the integral
2.2
[xf 2 (x) + 2.2x3 ] dx.
R
I=
1.0
b − a 2.2 − 1.0
h= = = 0.2 ⇒ 2n = 6,
2n 2n
x0 = 1.0, xk = 1.0 + 0.2k.
yk = xk f 2 (xk ) + 2.2xk3 .
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 32 / 34
Simpson’s Rule
0.2
I≈ (y0 + 4y1 + 2y2 + 4y3 + 2y4 + 4y5 + y6 )
3
CASIO.
0.2
A = A+B∗ ∗ (XY 2 + 2.2X 3 ) : X = X + 0.2
3
CALC A=0, B, X, Y is given by table
X | 1.0 1.2 1.4 1.6 1.8 2.0 2.2
Y | 2 3.3 2.4 4.3 5.1 6.2 7.4
B | 1 4 2 4 2 4 1
Therefore I = 59.82501333 ≈ 59.8250
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 33 / 34
Simpson’s Rule
THANK YOU FOR YOUR ATTENTION
Dr. Lê Xuân Đại (HCMUT) APPROXIMATE INTEGRATION HCMC — 2017. 34 / 34