You are on page 1of 42

2

www.motovasibelajar.com

LEARNING OUTCOMES
By the end of this lecture, students should be able to:
(1) Differentiate between trapezoidal rule and Simpsons rule.
(2) Summarize the formula for numerical integration.

(2) Solve integration problem numerically.

5.1 INTRODUCTION AND BACKGROUND


INTEGRATION The process of measuring the area under a
function plotted on a graph.
b

I f ( x )dx

Integrand

5.1 INTRODUCTION AND BACKGROUND

The integral of simple continuous function may be evaluated


analytically using calculus.
But for the complicated continuous function , analytical solutions
are often impractical, and sometimes impossible to obtain.
To overcome this, approximate methods (numerical methods)
must be employed.
5

5.1 INTRODUCTION AND BACKGROUND

A non computer approach to evaluate


integral is to divide the area under curve
into vertical segments, or strips, with a
height equal to the function value at the
midpoint of each strip.
Refer to the figure:
(a) a complicated continuous function
(b) table of discrete values of f(x)
generated from the function.
(c) Use of a numerical method (the strip
method) to estimate the integral on the
basis of the discrete points.

5.1 INTRODUCTION AND BACKGROUND

We will discuss the most common approaches for numerical integration


the Newton cotes formula.
Newton cotes replacing complicated function or tabulated data with a simple
polynomial(polynomial interpolation) that is easy to integrate.
b

I f ( x)dx f n ( x)dx
f n ( x) a0 a1 x

an 1 x n 1 an x n

where n is the order of the polynomial.


Trapezoidal, Simpsons 1/3 & Simpsons 3/8 rule.
For our purpose of study, we will use this formula for cases
where the data to be integrated is equally spaced.

5.1 INTRODUCTION AND BACKGROUND

Figure(a) shown a first order polynomial is used as an


approximation.

Figure (b), a parabola is employed for


the approximation.

Figure (c), the integral can also be approximated


using a series of polynomial applied piecewise
to the function or data over segments of constant
length.

5.2 THE TRAPEZOIDAL RULE

Trapezoidal rule was based on approximating the integrand by a


first order polynomial
Derived from Calculus
b

I f ( x ) dx f1 ( x ) dx

Derived from Geometry

Geometrically, the trapezoidal rule is equivalent to approximate


the area of the trapezoid under the straight line connecting f(a)
and f(b).

5.2 THE TRAPEZOIDAL RULE

1
width high
2
1
( a b) h
2

Area of trapezium

10

5.2 THE TRAPEZOIDAL RULE

SINGLE TRAPEZOIDAL RULE


Therefore, according to figure, the
integral estimate can be represented as

I width average height


f (a) f (b)
(b a)

Single application of trapezoidal rule:

Trapezoidal rule:
f (a ) f (b)
I (b a )
2
h
f (a ) f (b)
2

11

5.2 THE TRAPEZOIDAL RULE

COMPOSITE TRAPEZOIDAL RULE

divide into n
segments with equal
step size, h

xn

f ( x) dx

x0
x1

x2

f ( x) dx f ( x) dx
x0

I1 I 2

x1

xn

f ( x) dx

xn1

In

h
h
h

f ( x0 ) f ( x1 ) f ( x1 ) f ( x2 ) f ( x2 ) f ( x3 )
2
2
2

n 1
h

f ( x0 ) f ( xn ) 2 f ( xi )
2
i 1

f ( xn 1 ) f ( xn )
2

12

5.2 THE TRAPEZOIDAL RULE

Composite trapezoidal rule:


n 1
h

Trapezoidal rule: I f ( x0 ) f ( xn ) 2 f ( xi )
2
i 1

where
ba
h
n
step size

1st term/node

last term/node

number of strips/segments

13

5.2 THE TRAPEZOIDAL RULE

EXAMPLE 1
Evaluate

0.8

x 2 e x dx

by using trapezoidal rule.

14

5.2 THE TRAPEZOIDAL RULE

Solution:

f (a) f (b) h
Trapezoidal rule: I (b a)
f (a) f (b)
2
2
-single application of the Trapezoidal rule-

We have f ( x) x 2e x
x 0, f (0) 0
x 0.8, f (0.8) 0.8 .e 0.8 1.4243
2

0.8

h
f (a) f (b)
2
(0.8 0)
=
0 1.4243
2
0.5697

x 2 e x dx

15

5.2 THE TRAPEZOIDAL RULE

EXAMPLE 2
Evaluate

0.8

x 2 e x dx

by using trapezoidal rule with h = 0.2.

16

5.2 THE TRAPEZOIDAL RULE

Solution:

0.8

x 2 e x dx

n 1
h

Trapezoidal rule: I f ( x0 ) f ( xn ) 2 f ( xi )
2
i 1

-Composite Trapezoidal rule-

0.8

f(x0) , f(xn)

f(xi)

0.2

0.0489

0.4

0.2387

0.6

0.6560

0.8

1.4243

total

1.4243

0.9436

0.2
1.4243 (2)(0.9436)
2
0.3312

x 2 e x dx

17

5.2 THE TRAPEZOIDAL RULE

EXAMPLE 3
Evaluate

30

140000

2000ln
9.8t dt
140000 2100t

by using trapezoidal rule with 2 strips.

18

5.2 THE TRAPEZOIDAL RULE

Solution:
n 1
h

Trapezoidal rule: I f ( x0 ) f ( xn ) 2 f ( xi )
2
i 1

-Composite Trapezoidal rule-

30

140000

2000ln
9.8t dt
140000 2100t

f(x0) , f(xn)

177.2667

19

30

f(xi)
484.7455

30

901.6740

total

1078.9407

484.7455

140000
11

2000 ln
9.8t dt 1078.9407 (2)(484.7455)
2
140000 2100t
11266.3744

19

5.2 THE TRAPEZOIDAL RULE

Test your understanding.


EXERCISE 1

Evaluate

2 x 2 dx

(a) Using single trapezoidal rule


(b) Using trapezoidal rule with h 1.
EXERCISE 2
Evaluate

ln x dx using trapezium rule with 5 strips.

20

5.3 THE SIMPSONS RULE


Another way to obtain a more accurate estimate of an integral is to use higher
order polynomial to connects the points.
For example, if there is an extra point midway between f(a) and f(b):
the three point can be connected with a parabola
the four points can be connected with third order polynomial
The formulas that result from taking the integrals under such polynomials
are called Simpsons rules.

21

5.3.1y SIMPSONS 1/3rd RULE


Simpsons 1/3rd rule is an extension of Trapezoidal rule where the
integrand is approximated by a second order polynomial.
Second order polynomial (Quadratic curve) 3 points n = 2
Single application of Simpsons 1/3rd rule:
(b a)
rd
Simpson's 1/3 rule: I
f ( x0 ) 4 f ( x1 ) f ( x2 )
6
h
f ( x0 ) 4 f ( x1 ) f ( x2 )
3
where
ba ba
h

n
2

22

5.3.1 SIMPSONS 1/3rd RULE

E
F

a series of quadratic curves


f(x)

x=a

x=b

divided into even number of


strips (n)
x

Composite Simpsons 1/3rd rule:


h

Simpson's 1/3 rule:I f ( x0 ) f ( xn ) 4 f ( x1 ) f ( x3 ) ... f ( xn1 ) 2 f ( x2 ) f ( x4 ) ... f ( xn2 )


3
odd term
even term

odd nodes
evennodes

h
f ( x0 ) f ( xn ) 4 f ( xi ) 2 f ( xi )
3
i 1,3,..
i 2,4,..

where
ba
h
n

23

5.3.1 SIMPSONS 1/3rd RULE

EXAMPLE 1
Evaluate

0.8

x 2 e x dx

by using Simpsons 1/3rd rule.

24

5.3.1 SIMPSONS 1/3rd RULE

Solution:

0.8

x 2 e x dx

Simpson's 1/3rd rule: I


where h

h
f ( x0 ) 4 f ( x1 ) f ( x2 )
3

ba
2

0.8
0.4
2
we have two segment within three equally spaced points
[ x0, x1 ],[ x1 , x2 ]
h

x0 0, f (0) 0
x1 0.4, f (0.4) 0.2387
x2 0.8, f (0.8) 1.4243
h
f ( x0 ) 4 f ( x1 ) f ( x2 )
3
0.4
=
0 4 0.2387 1.4243 0.3172
3

25

5.3.1 SIMPSONS 1/3rd RULE

EXAMPLE 2
Evaluate

2.2

1.0

1 x 3 dx

by using Simpsons 1/3rd rule with h=0.2

26

5.3.1 SIMPSONS 1/3rd RULE

Solution:

odd nodes
even nodes

h
Simpson's 1/3 rule:I f ( x0 ) f ( xn ) 4 f ( xi ) 2 f ( xi )
3
i 1,3,..
i 2,4,..

where h

ba
n

f(x0) , f(xn)

1.0

1.4142

1.2

1.4

1.6

1.8

2.0

2.2

3.4129

total

4.8271

f(xn even)

f(xn odd)
1.6517

1.9349
2.2574
2.6138
3
4.5487

6.9091

27

5.3.1 SIMPSONS 1/3rd RULE

Solution (cont.):

2.2

1.0

f(x0) , f(xn)

1.0

1.4142

1.2

1.4

1.6

1.8

2.0

2.2

3.4129

total

4.8271

f(xn even)

f(xn odd)
1.6517

1.9349
2.2574
2.6138
3
4.5487

6.9091

0.2
1 x dx
4.8271 2(4.5487) 4(6.9091)
3
2.7707
3

28

5.3.1 SIMPSONS 1/3rd RULE

EXAMPLE 3
Evaluate

5 3cos x dx
2

(a) analytically
(b) using Simpsons 1/3rd rule with n=4
(c) Hence, calculate the true error, t.
[x is in radians]

29

5.3.1 SIMPSONS 1/3rd RULE

Solution:
(a) analytically

5 3cos x dx 5 x 3sin x 0

5(2) 3sin 2 5(0) 3sin 0


12.7279

30

5.3.1 SIMPSONS 1/3rd RULE

Solution:
(b) using Simpsons 1/3rd rule with n=4
i

f(x0) , f(xn)

0.5

1.0

1.5

2.0

3.7516

total

11.7516

ba 20
h

0.5
n
4
f(xn even)

f(xn odd)
7.6327

6.6209
5.2122
6.6209

12.8449

0.5
0 5 3cos x dx 3 11.7516 2 6.6209 4 12.8449
12.7288
2

31

5.3.1 SIMPSONS 1/3rd RULE

Solution:
(c) Hence, calculate the true error, t.

true value approximate value


t
100
true value
12.7279 12.7288

100
12.7279
0.0071%

32

5.3.1 SIMPSONS 1/3rd RULE

Test your understanding.


EXERCISE
The distance covered by a rocket from t=8 to t=30 is given by

140000

x 2000 ln

9
.
8
t
dt

140000 2100t

8
30

Use Simpsons 1/3rd rule to find the approximate value of x with n=4.
Answer: 11061.64

33

5.3.2y SIMPSONS 3/8 RULE


For Simpsons 3/8 rule, Newton cotes formula replaced the function
f(x) with polynomial order three.
Third order polynomial 4 points n = 3

Simpsons 3/8 rule:

3h
I f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
8
ba
where h
3
34

5.3.2 SIMPSONS 3/8 RULE

EXAMPLE 1
Evaluate

0.7

0.4

x 2 e x dx

by using Simpsons 3/8 rule.

35

5.3.2 SIMPSONS 3/8 RULE

Solution:

b a 0.7 0.4

0.1
3
3
we have three segments within four equally spaced points
[ x0, x1 ],[ x1 , x2 ],[ x2 , x3 ]
h

x0 0.4, f (0.4) 0.2387


x1 0.5, f (0.5) 0.4122
x2 0.6, f (0.6) 0.6560
x3 0.7, f (0.7) 0.9867
3h
I
f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
8
3(0.1)
=
0.2387 3 0.4122) 3(0.6560 0.9867
8
=0.1661

36

5.3.2 SIMPSONS 3/8 RULE

EXAMPLE 2
Evaluate

0.7

x 2 e x dx

by using Simpsons rule with h=0.1

37

5.3.2 SIMPSONS 3/8 RULE

Solution:
ba
b a 0.7 0
h
n

7
n
h
0.1
Simpsons 3/8 rule n = 3
Simpsons 1/3rd rule n even

0.7

x e dx
2

0.4

x e dx

0
use composite simpson's 1/3rd rule-

0.7

x 2e x dx

0.4
use simpson's 3/8 rule-

38

5.3.2 SIMPSONS 3/8 RULE

EXAMPLE 3
Evaluate

x2
e( x 1) dx
sin x

using Simpsons rule if = 2 and h = 0.1

39

CONCLUSION
INTEGRATION

TRAPEZOIDAL
RULE

SINGLE

h
I f (a) f (b)
2
where h b a
I

SIMPSONS 1/3RD
RULE

SIMPSONS 3/8
RULE

h
f ( x0 ) 4 f ( x1 ) f ( x2 )
3

where h

ba
2

COMPOSITE
n 1
h

I f ( x0 ) f ( xn ) 2 f ( xi )
2
i 1

where h

ba
n

I f ( x0 ) f ( xn ) 4 f ( x1 ) ... f ( xn 1 ) 2 f ( x2 ) ... f ( xn 2 )
3
odd term
even term

ba
where h
n

3h
f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 )
8

where h

ba
3

40

You might also like