Document 15070658

advertisement
Matakuliah
Tahun
: S0262-Analisis Numerik
: 2010
Numerical Integration
Pertemuan 7
Material Outline
• Numerical Integration
– Trapezoidal rule
– Simpson method
 NUMERICAL INTEGRATION
To integrate a function with respect to certain
variable in certain interval to yield a
numerical value
b
J   f ( x)dx  F (b)  F (a)
a
In which:
F ( x)  f ( x)
4
 NUMERICAL INTEGRATION
 Numerical Integration is very important to
engineers and scientists. This is because many real
life problems contain complicated functions that
the analytical solution is not available or extremely
hard to be solved.
 For such case, the numerical integration seems the
only option to find the approximation.
 In the following slides, 2 methods will be discussed
5
Trapezoidal Rule
 The simplest method of all.
 In this method, the interval [a-b] in which the numerical
integration will be sought is divided into several subintervals with the length=h  h= (b-a)/n, n= the number
of the sub intervals.
 If all sub-intervals is end points marked with a, x1, x2, x3,
…, xn-1, b, then the the values of the fuction (integran) f
for each point can be written as: f(a), f(x1), f(x2), f(x3),…, f(xn1), f(b).
 The approximation of the Integral J by the Trapezoidal Rule can be
written as :
6
Y
Y= f(x)
……..
a
x1
x2
b
x
 The approximation of the Integral J by the Trapezoidal Rule
can be written as :
h
J   f ( x)dx   f (a)  2 f ( x1 )  2 f ( x2 )   2 f ( xn1 )  f (b)
a
2
x1  a  h; x2  a  2h;
b
7
The Error in Trapezoidal Rule:
The error in Numerical Integration using Trapezoidal
Rule depends on the form of the integrand. If the
integrand is a linear function the error produced is zero.
It can be said that the error in Trapezoidal Rule is
linearly dependent with second derivative of the
integrand f.
In general the error can be written as:
= Ja-J
where: J is the true value, Ja is the
approximation of J using Trapezoidal Rule.
numerical
8
The Error in Trapezoidal Rule:
The interval (lower and upper bounds) of the error can be written
as:
K M2s    K M2b
In which:
n= the number of the sub-interval
K= (b-a)3/(12 n2)
M2s and M2b are the minimum and maximum values of the 2nd
derivative of the integrand f in interval [a-b], respectively.
9
Example 1:Use a trapezoidal rule to solve the
following definite integral, use the number
of sub- intervalsn= 10. Determine the
the lower and upper boundary of the error.
1
 (0,2  25x  200 x
2
0
)dx
Solution: f(x)=0,2+25 x – 200 x2; n=10h=(b-a)/10=0,1
n
0
1
2
3
4
5
6
7
8
9
10
xn
0
0,1
0,2
0,3
0,4
0,5
0,6
0,7
0,8
0,9
1
fn
0,2
0,7
-2,8
-10,3
-21,8
-37,3
-56,8
-80,3
-107,8
-139,3
-174,8
J=-54,3
10
Example 1: Continue  The interval of the error
Solution: f(x)=0,2+25 x – 200 x2; n=10h=(b-a)/10=0,1
f”(x)=-400; K= (b-a)3/(12 n2)=1/(1200)=0,000833
M2s =M2b=-400Error== -0,3333
verify this answer
11
SIMPSON METHOD
 Simpson method is one of the methods that widely used because
its simplicity and accuracy.
 In this method, interval [a, b] has to be evenly divided into n subintervals with the length (h) of each sub-interval. The number of
the sub-intervals has to be even number  n=2m (m=1,2,3,….) 
h= (b-a)/2m.
 As in the trapezoidal rule, we named all the end points of the subintervals as follow: x0=a, x1, x2, x3, …, xn-1, xn=2m=b
 In this method, the integrand is replaced by 2nd order Lagrange
polynomial:
i.e., axx2=a+2h, etc.
 xox2 f(x) dx =xox2 L2(x) dx  h(f0/3+4f1/3+f2/3) fk=f(xk)
12
SIMPSON METHOD
Y
Y= f(x)
……..
a
x1 x2
b
x
 The approximation of the integral J dengan by Simpson
Method is found by applying 2nd order Lagrange polynomial
in the whole interval and yield the following formula:
h
J   f ( x)dx   f ( x0 a)  4 f ( x1 )  2 f ( x2 )   4 f ( xn1 )  f ( xn  b)
a
3
x1  a  h; x2  a  2h;
b
13
Discrepancy (Error) in Simpson Method:
Because the integrand was approximated by the 2nd order
Lagrange which is the same as parabolic function, then the
integral will produce error=0 if the original integrand is in 2nd
order polynomial. Then the error interval of the following method
can be written as:
C M4s    C M4b
where:
C= (b-a)5/(180 n4)
M4s and M4b are the minimum and maximum values of
the forth derivative of the integrand f in the interval [ab].
14
Example 1: Use Simpson method to solve the following
definite integral numerically. Use the number
of the sub-intervals n= 10. Find also the
interval of error.
1
 (0,2  25x  200 x
2
0
)dx
Solution: f(x)=0,2+25 x – 200 x2; n=10h=(b-a)/10=0,1
n
0
1
2
3
4
5
6
7
8
9
10
xn
0
0,1
0,2
0,3
0,4
0,5
0,6
0,7
0,8
0,9
1
fn
0,2
0,7
-2,8
-10,3
-21,8
-37,3
-56,8
-80,3
-107,8
-139,3
-174,8
15
Example 1: Cont
Solution:
n
0
1
2
3
4
5
6
7
8
9
10
xn
0
0,1
0,2
0,3
0,4
0,5
0,6
0,7
0,8
0,9
1
fn
0,2
0,7
-2,8
-10,3
-21,8
-37,3
-56,8
-80,3
-107,8
-139,3
-174,8
h
J   f ( x)dx   f ( x0 a)  4 f ( x1 )  2 f ( x2 )   4 f ( xn 1 )  f ( xn  b)
a
3
0.1
 [ f 0  4 f 2  2 f 3  4 f 4    2 f8  4 f 9  f10 ]
3

b
The error=0, because the integrand is a 2nd order
polynomial (verify)
16
Exercise: Use Simpson method to solve the following definite
integral numerically. Use the number of the subintervals n= 6. Find also the interval of error.

0.9
0
(0,2  25x  200 x 2  675x3  900 x 4  400 x5 )dx
Solution:
17
Download