Professional Documents
Culture Documents
43 Numerical Integration Problem 1 F X PDF
43 Numerical Integration Problem 1 F X PDF
43 Numerical Integration Problem 1 F X PDF
3 - Numerical Integration
Problem (1): Given a function fx continuous on a, b, approximate numerically the definite integral
b
a fx dx.
If we know an antiderivative Fx of fx, then by the Fundamental Theorem of Calculus we know
b
a fx dx Fb − Fa.
In cases where we we do not know Fx exactly, for example, fx e −x , fx cosx 2 , how can we
2
b
approximate fxdx numerically?
a
b
Problem (2): Given a set of pairs x i , y i mi0 where y i fx i and x i in a, b, approximate fxdx by
a
m
I m f ∑ c i fx i .
i0
b
We want to determine c i mi0 so that fxdx − I m f is as small as possible.
a
b b − a
Example fxdx 9 hfa h 3 hfb, h , 3h b − a. Find the degree of
a 4 4 3
precision
of this quadrature formula If 9 hfa h 3 hfb.
4 4
b
Consider fx 1, fx x, fx x 2 , . . . . It is known that a x k dx 1 b k1 − a k1 .
k1
k fx 1 b k1 − a k1 9 hfa h 3 hfb
k1 4 4
0 1 b−a 9 h 3 h 3h b − a
4 4
9 ha h 3 hb 3h 3a h b
1 x 1 b 2 − a 2 4 4 4
2 −
b a 3a b − a b b − a 2a 2b 1 b 2 − 1 a 2
4 4 2 2
2 x2 1 b3 − 1 a3 9 ha h 2 3 hb 2 1 b 3 − 1 a 3
3 3 4 4 3 3
3 x3 1 b4 − 1 a4 9 ha h 3 3 hb 3 − 1 ba 3 1 b 2 a 2 − 1 b 3 a 5 b 4 − 2 a 4
4 4 4 4 9 6 9 18 9
So the degree of precision is 2.
1
9 ha h 2 3 hb 2 1 b − a3a 2 6ah 3h 2 b 2
4 4 4
b − a 2
1 b − a 3a 2 2ab − a b2
4 3
1 b − a 3a 2 2ab − 2a 2 b − 2ab a b 2
2 2
4 3
1 b − a 4 a 2 4 ab 4 b 2
4 3 3 3
1 b − aa 2 ab b 2 1 b 3 − a 3
3 3
2. Numerical Quadrature:
Another way to determine c i ’s for If : find P k x where k ≤ n such that fx ≈ P k x and then
n
b b
a fxdx ≈ a P k xdx ∑ c i fx i .
i0
The interpolating polynomial P n x that agrees with fx at x i , y i , i 0, . . . , n will be a good choice to
approximate fx.
a. Using Lagrangian Interpolating Polynomials:
2
Let P n x ∑ i0 fx i L n,i x. Then
n
n n
f n1 c
fx ∑ fx i L n,i x x − x i
i0
n 1! i0
and
n
b b b
a fxdx ≈ ∑ fx i a L n,i xdx ci a L n,i xdx, i 0, 1, . . . , n
i0
#
#
n of Quadrature Formula If approx c
of
sub- error
pts
int.
1 fx 0 1 fx 1 3 ′′
1 2 1 h − h f c x 0 , x 1
2 2 12
5
2 3 2 h 1 fx 0 4 fx 1 1 fx 2 − h f 4 c x 0 , x 2
3 3 3 90
5
3 4 3 h 3 fx 0 9 fx 1 9 fx 2 3 fx 3 − 3h f 4 c x 0 , x 3
8 8 8 8 80
7
4 5 4 h 14 fx 0 64 fx 1 24 fx 2 64 fx 3 14 fx 4 − 8h f 6 c x 0 , x 4
45 45 45 45 45 945
c. n 1 −point open Newton - Cotes formulas:
x n b − h, x n1 b, h b − a , x i x i−1 h.
x −1 a, x 0 a h,
n2
The Midpoint formulas are open Newton - Cotes formulas.
# #
n Quadrature Formula If approx c
of of
error
pts sub-int.
0 3 2 2hfx 0 h 3 f ′′ c x −1 , x 1
3
1 4 3 h 3 fx 0 3 fx 1 3h 3 f ′′ c x −1 , x 2
2 2 4
2 5 4 h 8 fx 0 − 4 fx 1 8 fx 2 14h 5 |f 4 c| x −1 , x 3
3 3 3 45
3 6 5 h 55 fx 0 5 fx 5 fx 2 55 fx 3 95h 5 f 4 c x −1 , x 4
24 24 1 24 24 144
Example Use the (i)Trapezoidal Rule (closed 2-point), (ii) Simpson’s Rule (closed 3-point) (iii) open
/4
4-point and (iv) open 5-point Newton-Cotes formulas to approximate sinx 2 dx and
0
estimate the approximation errors, respectively.
Let fx sinx 2 .
(i) Trapezoidal Rule (closed 2-point):
h − 0 , x 0 0, x 1
4 4 4
If 1 f0 f 0 sin
2
0. 227 164
2 4 4 8 16
(ii) Simpson’s Rule (closed 3-point):
4
h 1 − 0 , x 0 0, x 1 , x 2
2 4 8 8 4
If 1 f0 4f f 0 4 sin sin
2 2
1 0. 156 147 238 2
3 8 8 4 3 8 64 16
(iii) open 4-point Newton-Cotes:
h 1 , x −1 0, x 0 , x1 0 2 , x2
3 4 12 12 12 6 4
If 3 fx 0 fx 1 sin sin
2 2
0. 133 211
2 12 8 12 6
(iv) open 5-point Newton-Cotes:
h 1 , x −1 0, x 0 , x 1 , x 2 3 , x 3
4 4 16 16 8 16 4
If 4h 2fx 0 − fx 1 2fx 2 4
2 2 2
2 sin − sin 2 sin 3
3 3 16 16 8 16
0. 158 022
True errors:
/4
(i) R int 0 sinx 2 dx − 0. 227 164 7. 000 933 25 10 −2
/4
(ii) R int 0 sinx 2 dx − 0. 156 147 238 2 1. 007 429 271 10 −3
/4
(iii) R int 0 sinx 2 dx − 0. 133 211 2. 394 366 7 10 −2
/4
(iv) R int 0 sinx 2 dx − 0. 158 022 8. 673 325 2 10 −4
Approximation errors:
′ ′′
fx sinx 2 , f x 2x cosx 2 , f x 2cosx 2 − 2x 2 sinx 2
′′′
f x 2−2x sinx 2 − 4x sinx 2 − 4x 3 cosx 2 gx −43x sinx 2 2x 3 cosx 2
f 4 x −43 sinx 2 6x 2 cosx 2 6x 2 cosx 2 − 4x 4 sinx 2 −43 − 4x 4 sinx 2 12x 2 cosx 2
y
2.0 y
25
20
1.5
15
1.0
10
5
0.5
0
0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7
x x
′′ 4
y f x , x in 0, 4 y f x , x is in 0, 4
5
′′ ′′
f x ≤ f 0 2,
f
4
x ≤ f
4
≤ 16 sin
2
4
− 48 cos
2
2
− 12 sin
2
4 4 4 4 4 4
27. 571 910 72 ≤ 28
3 ′′
(i) R int − h f c ≤ 2 3
8. 074 551 10 −2
12 12 4
(ii) R int − h f 4 c ≤ 1 28
5 5
2. 905 46 10 −3
90 90 8
(iii) R int 3 h 3 f ′′ c ≤ 3 2 3 2. 691 517 10 −2
4 4 12
(iv) R int 14h f c ≤ 14 28 5 2. 542 277 79 10 −3
5 4
45 45 16
3. Approximation Errors:
Weighted Mean Value Theorem for Integrals:
b
Suppose that F is continuous on a, b , gxdx exists, and gx does not change sign on a, b .
a
Then there exists a number c in a, b with
b b
a Fxgxdx Fc a gxdx.
The corresponding approximation error:
′′
Consider Fx f c, and gx x − ax − b. gx is a quadratic function which is zero at x a
and x b and gx 0 for x in a, b. So, gx does not change sign on a, b .
′′
b f c b
R trap a 2!
x − ax − bdx 1 f c x − ax − bdx
2
′′
a
b b
1 f c x − ax − a − hdx 1 f c x − a 2 − x − ah dx
′′ ′′
2 a 2 a
′′ b ′′
1 f c 1 x − a 3 − 1 x − a 2 h 1 f c 1 b − a 3 − 1 b − a 2 h
2 3 2 a 2 3 2
′′ ′′
1 f c 1 h 3 − 1 h 3 − 1 f ch 3
2 3 2 12
′′
a. If f x ≤ M for all x in a, b , then
R trap ≤ M h 3
12
may not be easy to use to derive the approximation error. To derive the approximation error for the
Trapezoidal Rule, we use the Weighted Mean Value Theorem which has a condition: gx does
not change sign on a, b. This condition is not always satisfied for i0 x − x i . For example, to
n
6
derive the approximation error for Simpson’s Rule (3 pairs of data, a 2nd degree Lagrangian
polynomial)
′′′
b c
R int a f
3!
x − x 0 x − x 1 x − x 2 dx
Here gx 1 x − x 0 x − x 1 x − x 2 which does change sign over the interval x 0 , x 2 .
3!
Observe that the sign of x − x i n1 does not change on the interval a, b. So by the Weighted
Mean-Value Theorem we know there exists a number c in a, b such that
n1
b c f n1 c̄ b
a f
n 1!
x − x i n1 dx
n 1!
a x − x i n1 dx
f n1 c̄ 1
b − x i n2 − a − x i n2
n 1! n2
For the approximation error for Simpson’s Rule: choose x i x 1 , and use x 0 , x 1 , x 2 :
x 0 a x 1 − h, x 2 b x 1 h, h b − a
2
Note that the interval a, b x 0 , x 2 is symmetric about x x 1 . So,
x2 x1 x2
x x − x 1 m dx x x − x 1 m dx x x − x 1 m dx
0 0 1
0 if m is odd
x2
2 x − x 1 m dx 2 x − x 1 m1 2 h m1 if m is even
x 1 m1 2 m1
Consider
b b
a fxdx ≈ a P 3 xdx
′ ′′ ′′′
x2 f x 1 f x 1 f x 1
x fx 1
1!
x − x 1
2!
x − x 1 2
3!
x − x 1 3 dx
0
′′
f x 1 2 h3
2hfx 1
2 3
7
′′
Approximate f x 1 by the difference formula:
′′ fx h − 2fx fx − h
f x − 1 f 4 c 1 h 2
h2 12
we have the numerical integral formula:
3 fx 2 − 2fx 1 fx 0
If 2hfx 1 h 2hfx 1 h fx 2 − 2fx 1 fx 0
3 h2 3
h fx 0 4fx 1 fx 2
3
and the approximation error:
4
x2 c 1
x f 3
R int x − x 1 4 dx − h 1 f 4 c 2 h 2
0 4! 3 12
4
c̄ 1
f 2 h 5 − h 5 f 4 c 2 f 4 c 1 − 1 h 5 − h 5 f 4 c
4! 5 36 60 36 90
where c is in x 0 , x 2 .
Exercises:
1. Approximate the value of each of the following integrals using the Trapezoidal rule. Verify that the
theoretical error bound holds in each case.
2
a. 1x dx
1
1
b. e −x dx
0
1
c. 1 dx
0 1 x2
1
d. tan −1 x dx
0
2. Approximate the value of each of the integrals given in Exercise 1. using the Simpson’s rule. Verify that
the theoretical error bound holds in each case.
3. Approximate the value of each of the integrals given in Exercise 1. using the Midpoint rule. Verify that
the theoretical error bound holds in each case.
5. Show that the open Newton-Cotes formula with n 1 has degree of precision equal to 1.
6. (a) Determine values for the coefficients A 0 , A 1 and A 2 so that the quadrature formula
1
If fxdx A 0 f − 1 A 1 f0 A 2 f 1
−1 2 2
has degree of precision at least 2.
(b) Determine the exact degree of precision for the quadrature rule obtained in (a).
7. (a) Determine values for the coefficients A 0 , A 1 and A 2 so that the quadrature formula
8
1
If −1 fxdx A 0 f −1
3
A1f 1
3
A 2 f1
has degree of precision at least 2.
(b) Determine the exact degree of precision for the quadrature rule obtained in (a).
8. (a) Determine values for the coefficients A 0 , A 1 and x 1 so that the quadrature formula
1
If −1 fxdx A 0 f−1 A 1 fx 1
has degree of precision at least 2.
(b) Determine the exact degree of precision for the quadrature rule obtained in (a).
b − a 3 ′′
9. Show that the error term for the midpoint rule is f c where c in a, b.
24