• No results found

Numerical Integration

N/A
N/A
Protected

Academic year: 2022

Share "Numerical Integration"

Copied!
42
0
0

Loading.... (view fulltext now)

Full text

(1)

Numerical Integration

Trapezoidal Rule

Simpson’s Rule

(2)

Numerical Integration

Many definite integrals of interest can’t be evaluated analytically.

Probably the best-known example is the integral that gives the area under the standard bell-shaped curve, given by

dz e

x F

x

z 0

2 2

2 1 2

) 1

(

(3)

Numerical Integration

The integral is tabulated because it is a fact that there is no way to express the antiderivative of exp(-z2) in terms of elementary functions.

Because of cases like this we need methods to perform approximate integration; for other cases it may be more convenient to use a numerical method than a symbolic one.

Often we’re given values of f(x) at various points but not a formula for f and so have no choice but to use a

numerical method (for example, data from an

(4)

Numerical Integration

The Newton-Cotes formula Trapezoidal Rule

Simpson’s Rule Romberg Integration Gaussian Quadrature

(5)

Trapezoidal Rule

The trapezoidal rule is equivalent to approximating the area of the trapezoid under the straight line connecting f(a) and f(b).

f(a)

f(b)

(6)

Trapezoidal Rule

One way to improve the accuracy of the trapezoid rule is to divide the integration interval from a to b into a

number of segments (N).

The areas of individual segment can then be added to yield the integral for the entire interval.

There are N+1 equally spaced nodes x0, x1, …., xN

(7)

Trapezoidal Rule

Let, x0=a and xN=b

Assume

are equally spaced nodes

N a h b

N k

kh x

x

k 0

, 0 , 1 , 2 ,...,

(8)

Trapezoidal Rule

Therefore

with

N

N

x x x

x

x x b

a

f x dx f x dx f x dx f x dx

1 1

0

2

1

) ( ...

) ( )

( )

(

1

1

( )

k

( )

k k

k

x

x n

x

x

f x dx p x dx

(9)

Trapezoidal Rule

Let

with

k k

n

x f r f

p ( )

rh x

x

k

( dx hdr )

(10)

Trapezoidal Rule

1

1

( )

k

( )

k k

k

x

x n

x

x

f x dx p x dx

h x

x k k

k

k

dx f

r f

1

0

f r f dr

h

k k

(11)

Trapezoidal Rule

1

0 2

2

k

k

r f

rf

h h f

k

f

k

2 1

k k

k

f f

f

h

1

2 1

2 f

k

f

k 1

h

(12)

Trapezoidal Rule

N N

b

a h f f

f h f

f h f

dx x

f 0 1 1 2 1

... 2 2

) 2 (

N

N

f

f f

f h f

1 2

1

0

2 2 ... 2

2

1

1

0

2

) 2 (

N

i

i N

b

a

h f f f

dx x

f

(13)

Example

Approximate the following integral using the Trapezoidal rule with h=0.5 and h=0.25.

x dx x

4

1

4

(14)

Example

For h=0.5,

a

=1 and b=4

N b a

h

4 1

0 5 6

.

(15)

Example

2780 .

1 5

. 3 5

1339 .

1 0

. 3 4

9806 .

0 5

. 2 3

8165 .

0 0

. 2 2

6396 .

0 5

. 1 1

4472 .

0 0

. 1 0

) 4

( x

x x f x

i

i i i

i

(16)

Example

dx x

f x dx

x

4

1 4

1

( )

4

h f f f f f f f

2

0 6

2

1 2 3 4 5

8486 .

4 2 8614

. 2 1

5 . 0

8896 .

2

(17)

Example

For h=0.25,

a

=1 and b=4

N b a

h

4 1

0 25 12

.

(18)

Example

2 0 7 0 .

1 2 5

. 3 9

1 3 3 9 .

1 0 0

. 3 8

0 5 8 5 .

1 7 5

. 2 7

9 8 0 6 .

0 5 0

. 2 6

9 0 0 0 .

0 2 5

. 2 5

8 1 6 5 .

0 0 0

. 2 4

7 2 9 8 .

0 7 5

. 1 3

6 3 9 6 .

0 5 0

. 1 2

5 4 5 5 .

0 2 5

. 1 1

4 4 7 2 .

0 0 0

. 1 0

) 4

( x

x x f x

i

i i i

i

(19)

Example

dx x

f x dx

x

4

1 4

1

( )

4

h f f f

i

2

0 12

2

i 1 11

6364 .

10 2 8614

. 2 1

25 . 0

8918 .

2

(20)

Example

For h=0.5, N=6, the error is 0.0029 For h=0.25, N=12, the error is 0.0007

The error decreases as the number of segments (N) increases.

When h is reduced by a factor of ½ the successive errors are diminished by approximately ¼.

(21)

Exercise

Approximate the following integrals using the Trapezoidal rule with N=10.

(a) (b)

2

0

e

x

dx

2

x dx

1

3

1

(22)

Simpson’s Rule

The trapezoidal rule usually requires a large number of function evaluations to achieve an accurate answer.

Another way to obtain a more accurate estimate of an

integral is to use higher-order polynomials to connect the points.

(23)

Simpson’s Rule

Let

p x

2

f

k

r f

k

1 r r

2

f

k

2 1

( ) ( )

(24)

Simpson’s Rule

dx f

r r f

r f

dx x

f

x h

x k k k

x x

k

k k

k

2 2

) 1 2 (

) 1

2

(

dr f

r r f

r f

h

2 k k k

0

)

2

1 2 (

1

h rf r

f r r

k k

f

k

2 3 2

2

0 2

2

1

2 3 2

(25)

Simpson’s Rule

h 2 f

k

2 f

k

1 f

k

3

2

h 2 f

k

2 f

k

f

k

1 f

k

f

k

f

k

3 2

1 2 1

h f

k

f

k

f

k

3 4

1 2

(26)

Simpson’s Rule

Subdivide the interval [

a

,b] into N subintervals (N is even).

N

N

x x

x x x

x b

a

dx x

f

dx x

f dx

x f dx

x f

2

4

2 2

0

) ( ...

) ( )

( )

(

h f 4 f 2 f 4 f 2 f ... 4 f f

(27)

Simpson’s Rule

This equation is known as Simpson’s 1/3 rule.

Where N is even.

1 2 /

1 2 2

/

1

1 2

0

4 2

) 3 (

N

i

i N

i

i N

b

a

h f f f f

dx x

f

(28)

Simpson’s 3/8 Rule

Let,

k k

k

k

r f r r f r r r f

f x

p

3 2

( 1 )( 2 )

3

6 ) 1

1 2 (

) 1 (

3

3

( )

k 3

( )

k k

k

x x x

x

f x dx p x dx

(29)

Simpson’s 3/8 Rule

where N= 3, 6, 9, 12, ..…

This equation is called Simpson’s 3/8 rule because h is

1 3 /

1 3 3

/

1

1 3 2

3

0

3 2

8 ) 3

(

N

i

i N

i

i i

N b

a

h f f f f f

dx x

f

(30)

Example

Approximate the following integrals using the Simpson’s 1/3 rule with h=0.5 and h=0.25.

4

1

4 dx

x

x

(31)

Example

For h=0.5,

a

=1 and b=4

5 6 . 0

1 4

h a

N b

(N is even)

(32)

Example

2780 .

1 5

. 3 5

1339 .

1 0

. 3 4

9806 .

0 5

. 2 3

8165 .

0 0

. 2 2

6396 .

0 5

. 1 1

4472 .

0 0

. 1 0

) 4

( x

x x f f

x i

i i i

i i

(33)

Example

2

1 2 3

1

1 2 6

0 4

1

4 2

4 3

i

i i

i

f

f f

h f x dx

x

) 9504 .

1 ( 2 )

8982 .

2 ( 4 8614

. 3 1

5 . 0

8925 .

2

(34)

Example

For h=0.25,

a

=1 and b=4

(N is even)

25 12 . 0

1 4

h

a

N b

(35)

Example

2780 .

1 50

. 3 10

2070 .

1 25

. 3 9

1339 .

1 00

. 3 8

0585 .

1 75

. 2 7

9806 .

0 50

. 2 6

9000 .

0 25

. 2 5

8165 .

0 00

. 2 4

7298 .

0 75

. 1 3

6396 .

0 50

. 1 2

5455 .

0 25

. 1 1

4472 .

0 00

. 1 0

) 4

( x

x x f f

x i

i i i

i i

(36)

Example

5

1 2 6

1

1 2 12

0 4

1

4 2

4 3

i

i i

i

f

f f

h f x dx

x

) 8486 .

4 ( 2 )

7878 .

5 ( 4 8614

. 3 1

25 . 0

8925 .

2

(37)

Example

Approximate the following integrals using the Simpson’s 3/8 rule with h=0.25.

4

1

4 dx

x

x

(38)

Example

For h=0.25,

a

=1 and b=4

25 12 . 0

1 4

h

a

N b

(39)

Example

2780 .

1 50

. 3 10

2070 .

1 25

. 3 9

1339 .

1 00

. 3 8

0586 .

1 75

. 2 7

9806 .

0 50

. 2 6

9000 .

0 25

. 2 5

8165 .

0 00

. 2 4

7298 .

0 75

. 1 3

6396 .

0 50

. 1 2

5455 .

0 25

. 1 1

4472 .

0 00

. 1 0

) 4

( x

x x f f

x i

i i i

i i

(40)

Example

4

1

3

1 3 1

3 2

3 12

0 4

1

3 2

8 3

4

i i

i i

i

f f

f f

h f x dx

x

) 9174 .

2 ( 2 )

7191 .

7 ( 3 8614

. 8 1

) 25 . 0 ( 3

8925 .

2

(41)

Simpson’s Rule

Simpson’s 1/3 rule is usually the method of preference because it attains third-order accuracy with three points rather than the four points required for the 3/8 version.

(42)

Exercise

Approximate the following integral

using

a) The Simpson’s 1/3 rule b) The Simpson’s 3/8 rule with N=12.

dx x

3

0 3

1

1

References

Related documents

2 Percentage endorsement rates for items from the DISCO PDA measure stratified by group ( “substantial” PDA features, “some” PDA features and the rest of the sample).. N

Enrollado de jamón Ibérico de bellota relleno de rúcula y almendras tostadas sobre cama de tapenade 550 RD$ • Ibérico acorn ham rolls stuffed with arugula and toasted almonds on

 Reflections  on  aesthetic

This finding is in line with the managerial influence hypothesis and the busy board hypothesis because in companies with a high number of direct links, the

Economic impact assessments are the most commonly used form of measuring the economic benefits of cultural sector organisations, so a second case study that used this method has

Recording Data for New or Revised Course (Record only new or changed course information.) Course prefix (3 letters) Course Number (3 Digits) Effective Term (Example:

The Department of Health, Physical Education, Recreation and Dance offers a Master of Science in Education in Health and Physical Education and a Master of Science in

CREW (with expansion and 11960-EXP ONLY, down position, unlabeled): Pilot and copilot have ac- cess to aircraft radios, and hear Music input to PM1200.. Passengers do not