Docsity

Numerical Methods Notes: Numerical Integration and ODE Solutions, Study notes of Engineering Mathematics

Toggle sidebar
bg1
MODULE IV: NUMERICAL DIFFERENTIATION & INTEGRATION
AND SOLUTIONS TO ORDINARY DIFFERENTIAL EQUATIONS (ODE)
Numerical Integration
The process of evaluating a definite integral from a set of tabulated values of integrand
๐‘“(๐‘ฅ) is called numerical integration.
1. Trapezoidal Rule
Let ๐ผ= โˆซ๐‘“(๐‘ฅ)โ€‰๐‘‘๐‘ฅ
๐‘
๐‘Ž where ๐‘“(๐‘ฅ) takes the values ๐‘ฆโ‚€, ๐‘ฆโ‚,๐‘ฆโ‚‚, . .. ,๐‘ฆโ‚™ for ๐‘ฅ = ๐‘ฅโ‚€, ๐‘ฅโ‚,. . ., ๐‘ฅโ‚™.
โˆซ๐‘“(๐‘ฅ)โ€‰๐‘‘๐‘ฅ=
๐‘
๐‘Žโˆซ ๐‘“(๐‘ฅ)โ€‰๐‘‘๐‘ฅ=
๐‘ฅ0+๐‘›โ„Ž
๐‘ฅ0โ„Ž
2[(๐‘ฆ0+๐‘ฆ๐‘›)+2(๐‘ฆ1+๐‘ฆ2+โ‹ฏ+๐‘ฆ๐‘›โˆ’1)]
2. Simpson's ๐Ÿ
๐Ÿ‘๐’“๐’… Rule
โˆซ๐‘“(๐‘ฅ)โ€‰๐‘‘๐‘ฅ=
๐‘
๐‘Žโ„Ž
3[(๐‘ฆ0+๐‘ฆ๐‘›)+4(๐‘ฆ1+๐‘ฆ3+๐‘ฆ5+โ‹ฏ+๐‘ฆ๐‘›โˆ’1)
+2(๐‘ฆ2+๐‘ฆ4+๐‘ฆ6+โ‹ฏ+๐‘ฆ๐‘›โˆ’2)]
Number of subintervals must be even.
3. Simpson's ๐Ÿ‘
๐Ÿ–๐’•๐’‰ Rule
โˆซ๐‘“(๐‘ฅ)โ€‰๐‘‘๐‘ฅ=
๐‘
๐‘Ž3โ„Ž
8[(๐‘ฆ0+๐‘ฆ๐‘›)+3(๐‘ฆ1+๐‘ฆ2+๐‘ฆ4+๐‘ฆ5+๐‘ฆ7+๐‘ฆ8+โ‹ฏ+๐‘ฆ๐‘›โˆ’1)
+2(๐‘ฆ3+๐‘ฆ6+๐‘ฆ9+โ‹ฏ+๐‘ฆ๐‘›โˆ’3)]
Number of subintervals must be multiples of 3.
Example 1: Evaluate โˆซ ๐‘‘๐‘ฅ
1+๐‘ฅ2
6
0 using:
(i) Trapezoidal rule (ii) Simpson's 1/3rd rule (iii) Simpson's 3/8th rule
Solution: Divide the interval (0,6) into six parts of width โ„Ž=1.
The value of ๐‘“(๐‘ฅ)=1
1+๐‘ฅ2 is given by:
๐‘ฅ
0
1
2
3
4
5
6
๐‘“(๐‘ฅ)
1
0.5
0.2
0.1
0.05884
0.0385
0.027
(i) Trapezoidal Rule:
โˆซ๐‘‘๐‘ฅ
1+๐‘ฅ2
6
0=โ„Ž
2[(๐‘ฆ0+๐‘ฆ6)+2(๐‘ฆ1+๐‘ฆ2+๐‘ฆ3+๐‘ฆ4+๐‘ฆ5)]
= 1
2[(1+0.027)+2(0.5+0.2+0.1+0.05884+0.0385)]=1.41084
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Numerical Methods Notes: Numerical Integration and ODE Solutions and more Study notes Engineering Mathematics in PDF only on Docsity!

MODULE IV: NUMERICAL DIFFERENTIATION & INTEGRATION

AND SOLUTIONS TO ORDINARY DIFFERENTIAL EQUATIONS (ODE)

Numerical Integration

The process of evaluating a definite integral from a set of tabulated values of integrand

๐‘“(๐‘ฅ) is called numerical integration.

  1. Trapezoidal Rule

Let ๐ผ = โˆซ ๐‘“(๐‘ฅ) ๐‘‘๐‘ฅ

๐‘

๐‘Ž

where ๐‘“(๐‘ฅ) takes the values ๐‘ฆโ‚€, ๐‘ฆโ‚, ๐‘ฆโ‚‚,... , ๐‘ฆ โ‚™ for ๐‘ฅ = ๐‘ฅโ‚€, ๐‘ฅโ‚,... , ๐‘ฅ โ‚™.

๐‘

๐‘Ž

๐‘ฅ 0

+๐‘›โ„Ž

๐‘ฅ 0

[(๐‘ฆ

0

๐‘›

1

2

๐‘›โˆ’ 1

)]

  1. Simpson's

๐Ÿ

๐Ÿ‘

๐’“๐’…

Rule

๐‘

๐‘Ž

[

0

๐‘›

1

3

5

๐‘›โˆ’ 1

2

4

6

๐‘›โˆ’ 2

]

Number of subintervals must be even.

  1. Simpson's

๐Ÿ‘

๐Ÿ–

๐’•๐’‰

Rule

๐‘

๐‘Ž

[

0

๐‘›

1

2

4

5

7

8

๐‘›โˆ’ 1

3

6

9

๐‘›โˆ’ 3

]

Number of subintervals must be multiples of 3.

Example 1: Evaluate โˆซ

๐‘‘๐‘ฅ

1 +๐‘ฅ

2

6

0

using:

(i) Trapezoidal rule (ii) Simpson's 1/3rd rule (iii) Simpson's 3/8th rule

Solution: Divide the interval ( 0 , 6 ) into six parts of width โ„Ž = 1.

The value of ๐‘“

1

1 +๐‘ฅ

2

is given by:

(i) Trapezoidal Rule:

2

6

0

[(๐‘ฆ

0

6

1

2

3

4

5

)]

[( 1 + 0. 027 ) + 2 ( 0. 5 + 0. 2 + 0. 1 + 0. 05884 + 0. 0385 )] = 1. 41084

(ii) Simpson's 1/

rd

Rule:

2

6

0

[(๐‘ฆ

0

6

1

3

5

2

4

)]

[( 1 + 0. 027 ) + 4 ( 0. 5 + 0. 1 + 0. 0385 ) + 2 ( 0. 2 + 0. 05884 )] = 1. 3662

(iii) Simpson's 3/

th

Rule:

2

6

0

[(๐‘ฆ

0

6

1

2

4

5

3

)]

[( 1 + 0. 027 ) + 3 ( 0. 5 + 0. 2 + 0. 05884 + 0. 0385 ) + 2 ( 0. 1 )] = 1. 3571

Example 2: Use trapezoidal rule to estimate the integral โˆซ ๐‘’

๐‘ฅ

2

2

0

๐‘‘๐‘ฅ taking 10

subintervals.

Solution: Let ๐‘ฆ = ๐‘’

๐‘ฅ

2

, โ„Ž = 0. 2 and ๐‘› = 10

๐‘ฅ

2

๐‘ฅ

2

๐‘ฅ

2

2

0

[(๐‘ฆ

0

10

1

2

3

4

5

6

7

8

9

)]

Example 3: Use (๐‘–) Trapezoidal (๐‘–๐‘–) Simpson's 1/3rd rule for โˆซ ๐‘’

โˆ’๐‘ฅ

2

  1. 6

0

๐‘‘๐‘ฅ with h=0.1 (or

by taking 7 ordinates)

Solution:

(i) Trapezoidal Rule:

โˆ’๐‘ฅ

2

  1. 6

0

[(๐‘ฆ

0

6

1

2

3

4

5

)] = 0. 5344

(ii) Simpson's 1/

rd

Rule:

โˆ’๐‘ฅ

2

  1. 6

0

โ„Ž

3

[(๐‘ฆ

0

6

1

3

5

2

4

)]=0.

Numerical Solution of Ordinary Differential Equations

  1. Euler's Method

Consider the equation

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

= ๐‘“(๐‘ฅ, ๐‘ฆ) given ๐‘ฆ(๐‘ฅ

0

0

. To find an approximate value of y

corresponding to ๐‘ฅ, by Eulerโ€™s method we have:

๐‘–

๐‘–โˆ’ 1

๐‘–โˆ’ 1

๐‘–โˆ’ 1

i.e., ๐‘›๐‘’๐‘ค ๐‘ฆ = ๐‘œ๐‘™๐‘‘ ๐‘ฆ + โ„Ž (๐‘‘๐‘ฆ/๐‘‘๐‘ฅ)

Example 1: Using Euler's method, find ๐‘ฆ( 1 ) given

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

Solution: Divide the interval ( 0 , 1 ) into 10 subintervals with โ„Ž = 0. 1

The approximate value of ๐‘ฆ( 1 ) is 3.18.

Example 2: Given

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

๐‘ฆโˆ’๐‘ฅ

๐‘ฆ+๐‘ฅ

, ๐‘ฆ( 0 ) = 1 , find ๐‘ฆ( 0. 1 )

Solution: Divide the interval ( 0 , 0. 1 ) into 5 subintervals with โ„Ž = 0. 02

Thus ๐‘ฆ( 0. 1 ) โ‰ˆ 1. 0928

  1. Modified Euler's Method

By Eulerโ€™s Method:

๐‘–

๐‘–โˆ’ 1

๐‘–โˆ’ 1

๐‘–โˆ’ 1

i.e., for first iteration: ๐‘ฆ 1

0

0

0

By Modified Eulerโ€™s Method:

1

is computed initially by Eulerโ€™s formula above and ๐‘“(๐‘ฅ

0

0

) is replaced by

๐‘“

( ๐‘ฅ

0

๐‘ฆ

0

) +๐‘“

( ๐‘ฅ

1

๐‘ฆ

1

)

2

to obtain first modification ๐‘ฆ

1

( 1 )

i.e. ๐‘ฆ

1

( 1 )

0

+ โ„Ž [

๐‘“(๐‘ฅ

0

,๐‘ฆ

0

)+๐‘“(๐‘ฅ

1

,๐‘ฆ

1

)

2

]

Second modification is given by:

1

( 2 )

0

+ โ„Ž [

0

0

1

1

( 1 )

]

๐‘กโ„Ž

modification is given by:

1

(๐‘›)

0

+ โ„Ž [

0 ,

0

1

1

(๐‘›โˆ’ 1 )

]

The procedure is terminated when successive modification does not show any change.

Same procedure is repeated to find ๐‘ฆ 2

3

, and so onโ€ฆ

๐‘กโ„Ž

modification of ๐‘ฆ

๐‘˜

is given by:

๐‘˜

(๐‘›)

๐‘˜โˆ’ 1

+ โ„Ž [

๐‘˜โˆ’ 1

๐‘˜โˆ’ 1

๐‘˜

๐‘˜

( ๐‘›โˆ’ 1

)

]

Example 1: Using modified Eulerโ€™s method find ๐‘ฆ( 0. 2 ) and ๐‘ฆ( 0. 4 ) for ๐‘ฆ

โ€ฒ

๐‘ฅ

๐‘ฆ( 0 ) = 0. Let โ„Ž = 0. 2

Solution: Given ๐‘ฆ

โ€ฒ

๐‘ฅ

0

0

i) To find ๐‘ฆ( 0. 2 )

By Eulerโ€™s Method: ๐‘ฆ

1

0

0

0

= 0. 2468 + 0. 2 [

] = 0. 6031

Fifth modification of ๐‘ฆ

2

2

( 4

)

1

+ โ„Ž [

1

1

2

2

( 4

)

]

= 0. 2468 + 0. 2 [

] = 0. 6031

Thus ๐‘ฆ

2

Example 2: Solve the following by Eulerโ€™s modified method

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

= log(๐‘ฅ + ๐‘ฆ),

= 2 , find ๐‘ฆ

considering โ„Ž = 0. 2

Solution: Given ๐‘ฆ

โ€ฒ

= log(๐‘ฅ + ๐‘ฆ), ๐‘ฅ

0

0

By Eulerโ€™s Method: ๐‘ฆ 1

0

0

0

First modification of ๐‘ฆ 1

1

( 1 )

0

+ โ„Ž [

0

0

1

1

] = 2 + 0. 2 [

] = 2. 0655

Second modification of ๐‘ฆ

1

1

( 2 )

0

+ โ„Ž [

0

0

1

1

( 1

)

] = 2 + 0. 2 [

] = 2. 0656

Third modification of ๐‘ฆ 1

1

( 3 )

0

+ โ„Ž [

0

0

1

1

( 2

)

] = 2 + 0. 2 [

] = 2. 0656

Thus ๐‘ฆ 1

Exercise:

  1. Using modified Eulerโ€™s method, find an approximate value of ๐‘ฆ when ๐‘ฅ = 0. 3 given

that

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

= ๐‘ฅ + ๐‘ฆ and ๐‘ฆ( 0 ) = 1 Ans: y(0.3) โ‰ˆ 1.

  1. Runge-Kutta Method

Consider the differential equation

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

0

0

Let โ„Ž be increment in ๐‘ฅ and ๐‘˜ be the increment in ๐‘ฆ i.e.,

0

0

0

0

Then for finding the increment ๐‘˜ by Runge-Kutta method, calculate:

1

0

0

2

0

0

1

3

0

0

2

4

0

0

3

1

2

3

4

And ๐‘ฆ

1

0

The above method is also called fourth-order Runge Kutta method and is applicable to

linear or non-linear differential equation

Example 1: Apply Rune-Kutta fourth order method, to find an approximate value of

๐‘ฆ( 0. 2 ) given that

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

= ๐‘ฅ + ๐‘ฆ and ๐‘ฆ( 0 ) = 1.

Solution:

Given ๐‘ฅ 0

0

= 1 , โ„Ž = 0. 2. To find ๐‘˜:

1

0

0

= 0. 2 ร— ๐‘“( 0 , 1 ) = 0. 2 ร— 1 = 0. 2000

2

0

0

1

) = 0. 2 ร— ๐‘“( 0. 1 , 1. 1 ) = 0. 2 ร— 1. 2 = 0. 2400

3

0

0

2

) = 0. 2 ร— ๐‘“( 0. 1 , 1. 12 ) = 0. 2 ร— 1. 22 = 0. 2440

4

0

0

3

) = 0. 2 ร— ๐‘“( 0. 2 , 1. 244 ) = 0. 2888

1

2

3

4

Thus, ๐‘ฆ

0

Example 2: Using Runge-Kutta method of fourth order, solve

๐‘‘๐‘ฆ

๐‘‘๐‘ฅ

๐‘ฆ

2

โˆ’๐‘ฅ

2

๐‘ฆ

2

+๐‘ฅ

2

, with ๐‘ฆ( 0 ) = 1 ,

find ๐‘ฆ( 0. 2 ).

Solution:

Given ๐‘ฅ 0

0

= 1 , โ„Ž = 0. 2. To find ๐‘˜:

1

0

0

) = 0. 2 ร— ๐‘“( 0 , 1 ) = 0. 2000

2

0

0

1

) = 0. 2 ร— ๐‘“( 0. 1 , 1. 1 ) = 0. 19672