MATH/CMPSC 455 Introduction to Numerical Analysis I Numerical Integration NUMERICAL INTEGRATION Mathematical Problem: b ò f (x )dx a Example: Example: 113 4 ò 1x dx = 3 x |1 =

Download Report

Transcript MATH/CMPSC 455 Introduction to Numerical Analysis I Numerical Integration NUMERICAL INTEGRATION Mathematical Problem: b ò f (x )dx a Example: Example: 113 4 ò 1x dx = 3 x |1 =

MATH/CMPSC 455
Introduction to
Numerical Analysis I
Numerical Integration
NUMERICAL INTEGRATION
Mathematical Problem:
b
ò f (x )dx
a
Example:
Example:
3
1
4
1
2
3 4
ò 1x dx = 3 x |1 = 3 - 3 = 21.
4
4
òe
1
x2
dx = ?
By calculus, find F that F ' = f , then use
b
ò f (x )dx = F(b) - F(a)
a
Numerical Integration: replace f by another
function g that approximates f well and is easily
integral, then we have
b
b
a
a
ò f (x )dx » ò g (x )dx .
NEWTON-COTES FORMULAS
Idea: use polynomial interpolation to find the
approximation function g (x )
Step 1: Select nodes x 0 ,x 1 , ,x n in [a,b]
Step 2: Use Lagrange form of polynomial
interpolation to find the approximation function
n
p(x ) = åf (x i )l i (x )
i =1
Step 3:
n
ò f (x )dx » ò p(x )dx = åf (x )ò l (x )dx .
b
b
a
a
b
i
i =0
a i
TRAPEZOID RULE
Use two nodes: x 0 = a and x 1 = b
b -a
ò af (x )dx » 2 (f (a) + f (b)).
b
a
b
SIMPSON’S RULE
a +b
Use three nodes: x 0 = a,x 1 =
,x 2 = b.
2
b -a
a +b
ò af (x )dx » 6 (f (a) + 4f ( 2 ) + f (b))
b
a
b
Example: Apply the Trapezoid Rule and Simpson’s
Rule to approximate
ò
b
a
3
x dx
Example: Apply the Trapezoid Rule and Simpson’s
Rule to approximate
ò
2
1
ln x dx
Error of the trapezoid rule:
b -a
(b - a)2
E = ò f (x )dx (f (a) + f (b)) = f ''(h ),
a
2
12
b
h Î[a,b]
The trapezoid rule is exact for all polynomial of
degree less than or equal to 1.
Error of the Simpson’s rule:
b -a
a +b
f (4) (x ) b - a 5
E = ò f (x )dx (f (a) + 4f (
) + f (b)) = (
),
a
6
2
90
2
b
x Î[a,b]
The Simpson’s rule is exact for all polynomial of
degree less than or equal to 3.
THE COMPOSITE TRAPEZOID RULE
Why? ?
The high order polynomial interpolations are unbounded!
Step 1: Partition the interval [a,b] into n subintervals
by introducing points a = x 0 < x 1 < x 2 < < x n = b.
Step 2: Use the trapezoid rule on each subinterval
ò
hi
f (x )dx » (f (x i ) + f (x i +1 )),
2
x i +1
xi
hi = x i +1 - x i
Step 3: Sum over all subintervals
n-1
n-1
b
x i +1
hi
f (x )dx Ȍ (f (x i ) + f (x i +1 ))
ò af (x )dx = å
ò
xi
2
i =0
i =0
THE COMPOSITE SIMPSON’S RULE
n-1
h
S n = å(f (x i ) + 4f (x 1 ) + f (x i +1 ))
i+
6 i =0
2
n-1
n-1
h
h
2h
= (f (x 0 ) + f (x n )) + åf (x i ) +
f (x 1 )
å
i+
6
3 i =1
3 i =0
2
b -a
h = x i +1 - x i =
n
ERROR OF COMPOSITE RULES
Error of the composite trapezoid rule:
h
(b - a)f ¢¢(h ) 2
(f (x i ) + f (x i +1 )) = h
ò af (x )dx - 2 å
12
i =0
n-1
b
Error of the composite Simpson’s rule:
(b - a)f (4) (h ) 4
ò af (x )dx - S n = 2880 h
b
Example: Apply the composite Trapezoid Rule and
Simpson’s Rule ( 4 subintervals ) to approximate
ò
2
1
ln x dx