You are on page 1of 53

APPROXIMATE INTEGRATION

ELECTRONIC VERSION OF LECTURE

HoChiMinh City University of Technology


Faculty of Applied Science, Department of Applied Mathematics

HCMC — 2019.

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 1 / 34


OUTLINE

1 PROBLEMS

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 2 / 34


OUTLINE

1 PROBLEMS

2 TRAPEZOIDAL RULE

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 2 / 34


OUTLINE

1 PROBLEMS

2 TRAPEZOIDAL RULE

3 SIMPSON’S RULE

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 2 / 34


Problems

PROBLEMS

There are two situations in which it is impossible to


find the exact value of a definite integral.

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 3 / 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 1
2
antiderivative. For example e x d x,
Z 1p 0

1 + x 3 d x.
−1

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 3 / 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 1
2
antiderivative. For example e x d x,
Z 1p 0

1 + x 3 d x.
−1
2
The function is determined from a scientific
experiment through instrument readings or
collected data. There may be no formula for the
function.
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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 = x 0 , x 1 = x 0 + h, . . . , x k = x 0 + kh, . . . , x n = b.
Then we have
Z b n
X
f (x)d x ≈ f (x i∗ )∆x, (1)
a i =1

where x i∗ is any point in the i th subinterval [x i −1 , x i ].

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 4 / 34


Trapezoidal Rule Left endpoint approximation

If x i∗ is chosen to be the left endpoint of the interval,


then x i∗ = x i −1 and we have
Z b n
X
f (x)d x ≈ L n = f (x i −1 )∆x (2)
a i =1

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 5 / 34


Trapezoidal Rule Left endpoint approximation

If x i∗ is chosen to be the left endpoint of the interval,


then x i∗ = x i −1 and we have
Z b n
X
f (x)d x ≈ L n = f (x i −1 )∆x (2)
a i =1

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 5 / 34


Trapezoidal Rule Right endpoint approximation

If x i∗ is chosen to be the right endpoint of the


interval, then x i∗ = x i and we have
Z b n
X
f (x)d x ≈ R n = f (x i )∆x (3)
a i =1

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 6 / 34


Trapezoidal Rule Right endpoint approximation

If x i∗ is chosen to be the right endpoint of the


interval, then x i∗ = x i and we have
Z b n
X
f (x)d x ≈ R n = f (x i )∆x (3)
a i =1

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 6 / 34


Trapezoidal Rule Midpoint approximation

If x i∗ is chosen to be the midpoint of the interval,


x i −1 + x i
then x i∗ = and we have
2
Z b n ³x + x ´
i −1 i
∆x
X
f (x)d x ≈ M n = f (4)
a i =1 2

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 7 / 34


Trapezoidal Rule Midpoint approximation

If x i∗ is chosen to be the midpoint of the interval,


x i −1 + x i
then x i∗ = and we have
2
Z b n ³x + x ´
i −1 i
∆x
X
f (x)d x ≈ M n = f (4)
a i =1 2

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 7 / 34


Trapezoidal Rule Trapezoidal Rule

TRAPEZOIDAL RULE

Let y k = f (x k ), k = 0, 1, . . . , n
hh i
The k − t h trapezoid has area f (x k−1 ) + f (x k ) .
2

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 8 / 34


Trapezoidal Rule Trapezoidal Rule

TRAPEZOIDAL RULE

Let y k = f (x k ), k = 0, 1, . . . , n
hh i
The k − t h trapezoid has area f (x k−1 ) + f (x k ) .
2

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 8 / 34


Trapezoidal Rule Trapezoidal Rule

So the sum of these areas of n trapezoids is


Zb Zx1 Zx2 Zxn
f (x)d x = f (x)d x + f (x)d x + . . . + f (x)d x
a x0 x1 x n−1

y0 + y1 y1 + y2 y n−1 + y n
≈ Tn = h · +h · +...+h ·
2 2 2

h n−1
X h³ ´
Tn = (y k + y k+1 ) = y 0 + 2y 1 + 2y 2 + . . . + 2y n−1 + y n
2 k=0 2
(5)

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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)d x = appr oxi mat i on + er r or (6)
a

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 10 / 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)d x = appr oxi mat i on + er r or (6)
a

In general, we have
Z b Z b
ET = f (x)d x − Tn , EM = f (x)d x − M n
a a
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 10 / 34
Trapezoidal Rule Error Bounds

THEOREM 2.1
Suppose | f 00 (x)| É K , for a É x É b. If E T and E M are the
errors in the Trapezoidal and Midpoint Rules, then

K (b − a)3 K (b − a)3
|E T | É , |E M | É (7)
12n 2 24n 2

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 12 / 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= = , x 0 = 1, x k = 1 + , y k = f (x k ) = =
5 5 5 1 + k5 5 + k
h P
µ ¶
4 1 P4 5 5
I≈ (y k + y k+1 ) = +
2 k=0 10 k=0 5 + k 5 + (k + 1)
≈ 0.695635

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 12 / 34


Trapezoidal Rule Error Bounds

h³ ´
I≈ y 0 + 2y 1 + 2y 2 + 2y 3 + 2y 4 + y 5
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

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 14 / 34
Trapezoidal Rule Error Bounds

LEFT ENDPOINT

h i
I ≈ h f (x 0 ) + f (x 1 ) + f (x 2 ) + f (x 3 ) + f (x 4 )
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
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 15 / 34
Trapezoidal Rule Error Bounds

RIGHT ENDPOINT

h i
I ≈ h f (x 1 ) + f (x 2 ) + f (x 3 ) + f (x 4 ) + f (x 5 )
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
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 17 / 34
Trapezoidal Rule Error Bounds

EXAMPLE 2.2
UseZthe trapezoidal rule with n = 10 to estimate
1
dx
I= ·
0 1+x

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 18 / 34


Trapezoidal Rule Error Bounds

EXAMPLE 2.2
UseZthe trapezoidal rule with n = 10 to estimate
1
dx
I= ·
0 1+x

SOLUTION.
b −a 1−0 1 k
h= = = , x 0 = 0, x k = ,
n 10 10 10
1 10
y k = f (x k ) = =
k 10 + k
1+
10
h P
µ ¶
9 1 P9 10 10
I≈ (y k + y k+1 ) = +
2 k=0 20 k=0 10 + k 10 + (k + 1)
≈ 0.6938
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 18 / 34
Trapezoidal Rule Error Bounds

I≈
h³ ´
y 0 +2y 1 +2y 2 +2y 3 +2y 4 +2y 5 +2y 6 +2y 7 +2y 8 +2y 9 + y 10
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

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 20 / 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
¯ ¯
¯2¯
| f 00 (x)| = ¯¯ 3 ¯¯ É 2, ∀x ∈ [1, 2] ⇒ |E T | É < 0.0001
x 12n 2
1
⇒n> p ≈ 40.8 ⇒ n = 41.
0.0006

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 20 / 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
¯ ¯
¯2¯
| f 00 (x)| = ¯¯ 3 ¯¯ É 2, ∀x ∈ [1, 2] ⇒ |E T | É < 0.0001
x 12n 2
1
⇒n> p ≈ 40.8 ⇒ n = 41.
0.0006
2(2 − 1)3 1
|E M | É < 0.0001 ⇒ n > p ≈ 28.86 ⇒ n = 29.
24n 2 0.0012
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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 ZTrapezoidal Rule to approximate the integral
2.2 ³ ´
2 3
I= x f (x) + 4.4x d x
1.0

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 21 / 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 ZTrapezoidal Rule to approximate the integral
2.2 ³ ´
2 3
I= x f (x) + 4.4x d x
1.0

b − a 2.2 − 1.0
h= = = 0.2 ⇒ n = 6,
n n
x 0 = 1.0, x k = 1.0 + 0.2k, y k = x k f 2 (x k ) + 4.4x k3 .

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 21 / 34


Trapezoidal Rule Error Bounds

Therefore
h P5 h
I≈ (y k + y k+1 ) = (y 0 +2y 1 +2y 2 +2y 3 +2y 4 +2y 5 + y 6 ).
2 k=0 2
CASIO h = 0.2, we have
h
A = A+ × B × (X Y 2 + 4.4X 3 ) : X = X + h
2
X 1.0 1.2 1.4 1.6 1.8 2.0 2.2
Y 4 3.3 2.4 4.3 10.2 6.2 7.4
B 1 2 2 2 2 2 1
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
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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.

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 23 / 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
b−a
equal parts, each of width ∆x = h = by the
2n
subdivision points a = x 0 , x 1 = x 0 + h, . . . ,
x k = x 0 + kh, . . . , x 2n = b. Let y k = f (x k ), k = 0, 1, . . . , 2n

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 23 / 34


Simpson’s Rule

We know that the equation of the parabola through


P 0 , P 1 and P 2 is of the form y = A(x − x 1 )2 + B (x − x 1 ) +C
and so the area under the parabola from x 0 = x 1 − h to
x 2 = x 1 + h is
Z x2 h i Z h
2
A(x − x 1 ) + B (x − x 1 ) +C d x = (At 2 + B t +C )d t
x0 −h

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 24 / 34


Simpson’s Rule

Z h Z h
2
(At + B t +C )d t = 2 (At 2 +C )d t
−h 0
¸h
t3 h
·
= 2 A +C t = (2Ah 2 + 6C )
3 0 3

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 25 / 34


Simpson’s Rule

Z h Z h
2
(At + B t +C )d t = 2 (At 2 +C )d t
−h 0
¸h
t3 h
·
= 2 A +C t (2Ah 2 + 6C )
=
3 0 3
But, since the parabola passes through P 0 (x 0 , y 0 ),
P 1 (x 1 , y 1 ), and P 2 (x 2 , y 2 ), we have
y 0 = A(−h)2 + B (−h) +C = Ah 2 − Bh +C
y1 = C
y 2 = Ah 2 + Bh +C
and therefore y 0 + 4y 1 + y 2 = 2Ah 2 + 6C . Thus the area
h
under the parabola is (y 0 + 4y 1 + y 2 ).
3
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 25 / 34
Simpson’s Rule

Similarly, the region under the curve y = f (x) on each


hh i
interval [x k , x k+2 ] has area f (x k )+4 f (x k+1 )+ f (x k+2 ) .
3
So the sum of these areas of n regions is
Z b Z x2 Z x4 Z x2n
f (x)d x = f (x)d x + f (x)d x + . . . + f (x)d x
a x0 x2 x 2n−2

h h h
≈ (y 0 +4y 1 +y 2 )+ (y 2 +4y 3 +y 4 )+..+ (y 2n−2 +4y 2n−1 +y 2n )
3 3 3

h n−1
X
I≈ (y 2k + 4y 2k+1 + y 2k+2 ) (8)
3 k=0

h³ ´
= y 0 + 4y 1 + 2y 2 + 4y 3 + 2y 4 + . . . + 2y 2n−2 + 4y 2n−1 + y 2n
3
(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 26 / 34
Simpson’s Rule

ERROR BOUNDS

THEOREM 3.1
Suppose | f (4) (x)| É K , for a É x É b. If E S is the error
involved in using Simpson’s Rule, then

K (b − a)5
|E S | É (9)
2880n 4

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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.

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 28 / 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= = = , x 0 = 0, x k = ,
2n 20 20 20
1 20
y k = f (x k ) = k
= ·
1 + 20 20 + k

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 28 / 34


Simpson’s Rule

Therefore
h n−1
X
I≈ (y 2k + 4y 2k+1 + y 2k+2 ) =
3 k=0
9 µ ¶
1 X 20 20 20
= +4 + ≈ 0.6931
60 k=0 20 + 2k 2k + 21 2k + 22

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 29 / 34


Simpson’s Rule

Therefore
h n−1
X
I≈ (y 2k + 4y 2k+1 + y 2k+2 ) =
3 k=0
9 µ ¶
1 X 20 20 20
= +4 + ≈ 0.6931
60 k=0 20 + 2k 2k + 21 2k + 22

I≈ y 0 +4y 1 +2y 2 +4y 3 +2y 4 +4y 5 +2y 6 +4y 7 +2y 8 +4y 9 +2y 10 +
3
´
+4y 11 +2y 12 +4y 13 +2y 14 +4y 15 +2y 16 +4y 17 +2y 18 +4y 19 +y 20

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 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
Z 2.2 h i
I= x f 2 (x) + 2.2x 3 d x .
1.0

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 32 / 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
Z 2.2 h i
I= x f 2 (x) + 2.2x 3 d x .
1.0

b − a 2.2 − 1.0
h= = = 0.2 ⇒ 2n = 6,
2n 2n
x 0 = 1.0, x k = 1.0 + 0.2k.

y k = x k f 2 (x k ) + 2.2x k3 .

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 32 / 34


Simpson’s Rule

0.2
I≈ (y 0 + 4y 1 + 2y 2 + 4y 3 + 2y 4 + 4y 5 + y 6 )
3
CASIO.
0.2
A = A +B ∗ ∗ (X Y 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


(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 33 / 34
Simpson’s Rule

THANK YOU FOR YOUR ATTENTION

(HCMUT) APPROXIMATE INTEGRATION HCMC — 2019. 34 / 34

You might also like