5
4. NUMERICAL INTEGRATION: ) x ( f f k k b a I dx ) x ( f 0 x a n x b Trapezoidal Rule: h ] f f ... f f f [ I n n 2 1 2 1 1 2 1 0 1 x 2 x .. ) x ( f x 0 x n x 0 f 1 f . . . k 1 k x x h x Area of a single trapezoid = ) x x ( * 2 f f 0 1 1 0 h n x x h 0 n There are various numerical methods to calculate the definite integrals. The integral gives the area under the curve defined by the function f(x). We use the function values and increment value between the successive points on the x axis in order to calculate the integral.

4. NUMERICAL INTEGRATION: Trapezoidal Rule: Area of a single trapezoid = h There are various numerical methods to calculate the definite integrals. The

Embed Size (px)

Citation preview

Page 1: 4. NUMERICAL INTEGRATION: Trapezoidal Rule: Area of a single trapezoid = h There are various numerical methods to calculate the definite integrals. The

4. NUMERICAL INTEGRATION:

)x(ff kk

b

a

Idx)x(f0xa

nxb

Trapezoidal Rule:

h]ff...fff[I nn 2

1

2

11210

1x2x ...

)x(f

x

0x nx

0f1f

..

.

k1k xxhx

Area of a single trapezoid =

)xx(*2

ff01

10

h

n

xxh 0n

There are various numerical methods to calculate the definite integrals. The integral gives the area under the curve defined by the function f(x). We use the function values and increment value between the successive points on the x axis in order to calculate the integral.

Page 2: 4. NUMERICAL INTEGRATION: Trapezoidal Rule: Area of a single trapezoid = h There are various numerical methods to calculate the definite integrals. The
Page 3: 4. NUMERICAL INTEGRATION: Trapezoidal Rule: Area of a single trapezoid = h There are various numerical methods to calculate the definite integrals. The
Page 4: 4. NUMERICAL INTEGRATION: Trapezoidal Rule: Area of a single trapezoid = h There are various numerical methods to calculate the definite integrals. The

In Simpson’s rule, number of section n must be even!

Simpson’s Rule:

34224 21222210

h]fff...fff[I nnm n=2*m

Page 5: 4. NUMERICAL INTEGRATION: Trapezoidal Rule: Area of a single trapezoid = h There are various numerical methods to calculate the definite integrals. The

Example:

1

0

x ?dxe2

k x Exp(-x^2)

0 0 1

1 0.25 0.939

2 0.50 0.779

3 0.75 0.570

4 1 0.368

Trapezoidal Rule gives: 0.743

Simpson’s Rule gives: 0.747

Numerical Integration using Matlab:

clc; clearsyms xf=exp(-x^2)y=int(f,0,1)vpa(y,5)

>> vpa(int('exp(-x^2)',0,1))

743.0I

2

368.0570.0779.0939.0

2

125.0I

747.0I

368.0570.0*4779.0*2939.0*413

25.0I

4n 25.0

4

01

n

xx

n

abhx 0n