17

Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

Embed Size (px)

Citation preview

Page 1: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010
Page 2: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

Numerical IntegrationPertemuan 7

Matakuliah : S0262-Analisis NumerikTahun : 2010

Page 3: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

Material Outline

• Numerical Integration– Trapezoidal rule– Simpson method

Page 4: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

4

NUMERICAL INTEGRATION

To integrate a function with respect to certain variable in certain interval to yield a numerical value

In which:

)()( xfxF

)()()( aFbFdxxfJb

a

Page 5: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

5

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

Page 6: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

6

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 sub-intervals 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(xn-1),

f(b).

The approximation of the Integral J by the Trapezoidal Rule can be written as :

Page 7: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

7

The approximation of the Integral J by the Trapezoidal Rule can be written as :

……..

Y= f(x)

Y

xa bx1 x2

;2;

)()(2)(2)(2)(2

)(

21

121

haxhax

bfxfxfxfafh

dxxfJ n

b

a

Page 8: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

8

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 numerical approximation of J using Trapezoidal Rule.

Page 9: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

9

The Error in Trapezoidal Rule:

The interval (lower and upper bounds) of the error can be written as:

 

K M2s K M2

b

In which:

n= the number of the sub-interval

K= (b-a)3/(12 n2)

M2s and M2

b are the minimum and maximum values of the 2nd

derivative of the integrand f in interval [a-b], respectively.

Page 10: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

10

Example 1:Use a trapezoidal rule to solve the following definite integral, use the number of sub- intervalsn= 10. Determine the the lower and upper boundary of the error.

1

0

2 )200252,0( dxxx

Solution: f(x)=0,2+25 x – 200 x2; n=10h=(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

Page 11: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

11

Example 1: Continue The interval of the error

Solution: f(x)=0,2+25 x – 200 x2; n=10h=(b-a)/10=0,1

f”(x)=-400; K= (b-a)3/(12 n2)=1/(1200)=0,000833

M2s =M2

b=-400Error== -0,3333

verify this answer

Page 12: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

12

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 sub-intervals 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 sub-intervals 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., axx2=a+2h, etc.

xox2 f(x) dx =xo

x2 L2(x) dx h(f0/3+4f1/3+f2/3) fk=f(xk)

Page 13: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

13

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:

……..

Y= f(x)

Y

xa bx1 x2

;2;

)()(4)(2)(4)(3

)(

21

1210

haxhax

bxfxfxfxfaxfh

dxxfJ nn

b

a

SIMPSON METHOD

Page 14: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

14

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 M4

b

where:

C= (b-a)5/(180 n4)

M4s and M4

b are the minimum and maximum values of

the forth derivative of the integrand f in the interval [a-b].

Page 15: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

15

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 )200252,0( dxxx

Solution: f(x)=0,2+25 x – 200 x2; n=10h=(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

Page 16: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

16

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

]42424[

3

1.0

)()(4)(2)(4)(3

)(

10984320

1210

fffffff

bxfxfxfxfaxfh

dxxfJ nn

b

a

The error=0, because the integrand is a 2nd order polynomial (verify)

Page 17: Numerical Integration Pertemuan 7 Matakuliah: S0262-Analisis Numerik Tahun: 2010

17

Exercise: Use Simpson method to solve the following definite integral numerically. Use the number of the sub-intervals n= 6. Find also the interval of error.

Solution:

9.0

0

5432 )400900675200252,0( dxxxxxx