110
A short note on Numerical Analysis II meant for self-taught students until face to face class will resume Complied by Hailu Muleta (Assistant Professor of Mathematics) April, 2020 Jimma, Ethiopia

A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

A short note on Numerical Analysis II meant for self-taught

students until face to face class will resume

Complied by

Hailu Muleta (Assistant Professor of Mathematics)

April, 2020

Jimma, Ethiopia

Page 2: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

2

Chapter One

Revision on Numerical Integration

This chapter is highly devoted to find the numerical integration for a

given set of data points. The topics covered here are

- Numerical Integration

- Newton-Cote’s quadrature formula

- Trapezoidal Rule

- Simpson’s one-third Rule

- Simpson’s three-eighths Rule

- Weddle’s rule

Consider the definite integral .

This integral represents the area between , the –axis and the lines & .

This integration is possible as far as is explicitly given and the function is integrable.

Now suppose set of (n+ 1) paired values are given. First as we did in the case of numerical

differentiation, we find by an interpolating polynomial and obtain which

can approximate the value for .

A General Quadrature Formula for Equidistant Spacing (Newton-Cote’s Formula)

For equally spaced intervals, we have Newton’s forward difference formula as

dxxfb

a

)(xfy x ax bx

)(xf

)(xf )(xPn dxxp

b

an

dxxpb

an

1...!3

21

!2

10

3

0

2

00

yuuu

yuu

yuyxy

Page 3: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

3

Here, is the interval of differencing.

Now, instead of , we will replace it by this interpolating polynomial of Newton.

Since

Thus,

. Where is interpolating polynomial of degree n.

This equation is called Newton-cote’s quadrature formula and is a general quadrature

formula.

By taking different values for n we get a number of special formulas. Here we try to look for

some values of n for which their practical application is very important in different disciplines of

science. Detail information and results are explained below.

hh

xxu ,0

)(xf )(xy

h

xxnu

h

xxuandnhxxn

000

dxxfdxxfnhx

x

x

x

n

0

00

dxxPnhx

xn

0

0

)(xPn

hduy

uuuy

uuyuy

n

00

3

0

2

00 ...!3

21

!2

1

duy

uuuy

uuyuyh

n

00

323

0

2

00 ...!3

23

!2

1

n

y

uuu

y

uu

yu

uyh

0

0

3

234

0

2

23

0

2

0 ...!3

4

!2

23

2

)2(...46

1

232

1

20

3234

0

223

0

2

0

ynn

ny

nny

nnyh

Page 4: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

4

Trapezoidal Rule

Put n = 1, in the quadrature formula

Since other differences do not exist if n = 1.

This is known as a trapezoidal rule.

Even though this method is very simple for calculation, the error in this case is significant.

Truncation Error in Trapezoidal Rule

In the neighborhood of , we can expand by Taylor series in powers of .

That is,

002

1.1

0

0

0

0

yyhdxxfdxxfhx

x

nhx

x

010

2

1yyyh

102

yyh

dxxfdxxfnx

x

nhx

x

0

0

0

dxxfdxxfdxxfnhx

hnx

hx

hx

nhx

x

0

0

0

0

0

0 1

2

...

nn yyh

yyh

yyh

121102

...22

1210 ...22

nn yyyyyh

0xx )(xfy 0xx

1...!2

''

0

2

0'

000

yxx

yxxyxy

Page 5: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

5

(2)

If is the equidistant length, then also

Area of the first trapezium = A0 say

Putting in (1), we get

Subtracting A0 from (2), we obtain

dxyxx

yxxyydxx

x

x

x

1

0

1

0

...!2

''

0

2

0'

000

1

0

...!3!2

''

0

3

0'

0

2

00

x

x

yxx

yxx

xy

...!3!2

''

0

3

01'

0

2

01010

y

xxy

xxxxy

...!3!2

''

0

3'

0

2

0 yh

yh

hy

h

10

1

0 2yy

hydx

x

x

1xx

...!2

''

0

2

01'

001011

yxx

yxxyyxy

...!2

''

0

2'

00 yh

hyy

...

!222

''

0

2'

000100 yh

hyyyh

yyh

A

...!2.22

''

0

3'

0

2

0 yh

yh

hy

...!2.2

1

!3

1''

0

3

0

1

0

yhAydx

x

x

Page 6: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

6

The error made in the first interval is

Similarly the error in the ith

interval

Hence, the total cumulative error E is

if the interval is and

The error in the trapezoidal rule is of order .

The accuracy of the result can be improved by increasing the number of intervals and

decreasing the value of .

Simpson’s One-Third Rule

Setting n = 2 in Newton-cotes quadrature formula, we have

since the other terms vanish (become zero).

...2

1 ''

0

3 yh

),( 10 xx ...2

1 ''

0

3 yh

''

1

3

2

1 iyh

''

1

''

2

''

1

''

0

3 ...2

1 nyyyyhE

,...,,max12

''2

''1

''0

3

yyyMwhereMnh

E

M

hab

12

2 ),( ba

n

abh

2h

h

0

2

002

4

3

8

2

142

2

yyyhdxxfx

x

0

2

010 13

122 yEyyyh

012010 2

3

1222 yyyyyyh

Page 7: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

7

Similarly, and

If n is an even integer, then the last integral will be

Adding all these integrals, if n is even positive integer, then are odd in

number; we have

Simpson’s Three-Eighths Rule

Putting n = 3 in Newton-cotes formula, we get

012

3

1

3

4

3

1yyyh

012 43

yyyh

432 43

4

2

yyyh

dxxfx

x 214

3

2

iii

x

xyyy

hdxxf

i

i

nnn

x

xyyy

hdxxf

n

n

12 432

nyyyyy ,...,,,, 3210

nx

nx

x

x

x

x

nx

xdxxfdxxfdxxfdxxf

20

4

20...)()(

2

nnn yyyyyyyyyh

12432210 4...443

1312420 ...4...23

nnn yyyyyyyyh

0

3

0

2

00 9274

81

6

1

2

9

2

1

2

93)(3

0yyyyhdxxf

x

x

0

3

0

2

010 18

31

4

9

2

93 yEyEyyyh

0123012010 33

8

32

4

9

2

9

2

93 yyyyyyyyyyh

0123 338

3yyyy

h

Page 8: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

8

If n is a multiple of 3,

This is Simpson’s three-eighths rule and is applicable only when n is a multiple of 3.

Weddle’s Rule

Putting n = 6 in Newton-cotes formula

Now replace the term by doing this, the error introduced is only

which is negligible when and are small.

Using and replacing all differences in terms of ’s,

we get

Similarly,

and

Adding all these integrals, we get

nhx

hnx

hx

x

hx

hx

nhx

xdxxfdxxfdxxfdxxf 0

)3(0

30

0

60

30

0

0

...)()(

nnnn yyyyyyyyyyyyh

12365433210 33...33338

3

nnnn yyyyyyyyyyyh

631254210 2...38

3

...36216324

6

11872

2

1186)( 0

3

0

2

00

60

0yyyyhdxxf

hx

x

0

6

0

5

0

4

0

3

0

2

00140

41

10

33

10

1232427186 yyyyyyyh

,140

42

140

410

6

0

6 ybyy 0

6

140y

h

h0

6 y

1 E y

6543210 56510

360

0

yyyyyyyh

dxxfhx

x

1211109876 56510

3120

60

yyyyyyyh

dxxfhx

hx

nnnnnnn yyyyyyyh

dxxfnhx

hnx

123456 56510

30)6(

0

Page 9: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

9

This equation is called Weddle’s rule.

Truncation Error in Simpson’s Formula

By Taylor expansion of in the neighborhood of , we obtain

Now let , by Simpson’s rule

Putting in (1), to get

Putting in (1), we have

nnnnnnn yyyyyyy

yyyyyyyyyyyyh

dxxfnhx

x

123456

1109876543210

5652...

565256510

30

0

)(xfy 0xx

1......!3!2

'''

0

3

0''

0

2

0'

000

yxx

yxx

yxxyy

dxy

xxy

xxy

xxyydx

x

x

x

x

2

0

2

0...

!3!2!1

'''

0

3

0''

0

2

0'

00

0

2

0

..!4!3!21

'''

0

4

0''

0

3

0'

0

2

00

x

x

yxx

yxx

yxx

xy

...!4!3!2

'''

0

4

02''

0

3

02'

0

2

02020

y

xxy

xxy

xxxxy

...!4

16

!3

8

!2

42 '''

0

2''

0

3'

0

2

0 yhyh

yh

hy

...15

4

3

2

3

422 4

0

5'''

0

4''

0

3'

0

2

0 yh

yh

yhyhhy

2101 43

area2

0

yyyh

ydxAx

x

1xx

...!2

''

021'

00101

yxx

yxxyy

...!3!2

'''

0

3''

0

2'

00 yh

yh

hyy

2xx

Page 10: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

10

Omitting the remaining terms involving and higher powers of .

This means that the error made in is

Similarly, the error made in and so on.

Hence the total error E is

, where M is the maximum value of

Since is the last paired value because we require odd number of ordinates to apply

Simpson’s one-third rule.

If the interval is , then , using this

Hence, the error in Simpson’s one-third rule is of the order .

Examples

...!3

8

!2

42 '''

0

3''

0

2'

002 yh

yh

hyyy

...22...

!3!24

3

''

0

2'

00

'''

0

3''

0

2'

0001 yhhyyyh

yh

hyyyh

A

...18

5

3

2

3

422 4

0

5'''

0

4''

0

3'

0

2

0 yhyhyhyhhy

...18

5

15

4 4

0

5

1

2

0

yhAydx

x

x

...90

4

0

5

yh 6h h

20 , xx ...90

4

0

5

yh

4

2

5

4290

, yh

isxx

...9

, 4

2

4

0

5

0 yyh

isxx n

Mnh

E90

5

4

22

4

2

4

0 ...,, nyyy

nn yx 22 ,

),( ba )2( nhab

M

habE

180

4

4h

Page 11: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

11

1. Evaluate by using

a) Trapezoidal rule

b) Simpson’s rule and verify your results by actual integration

Solution

Here and the interval length is 7-1 = 6 so we divide this interval into 6 equal parts

with

: 1 2 3 4 5 6 7

: 1 4 9 16 25 36 49

a) By Trapezoidal rule

b) By Simpson’s one-third rule

=

Since n = 6, we can also use Simpson’s three-eighth rule.

So

dxx7

1

2

2)( xxy

16

6h

x

y

6543271

7

1

2 22

yyyyyyyh

dxx

1153625169424912

1

6425371

7

1

2 (4)23

1yyyyyyydxx

36164425924913

1

114

4653271

7

1

2 238

3yyyyyyydxx

16236259434918

3

Page 12: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

12

=

2. Evaluate using Trapezoidal rule with , and hence

obtain an approximate value of .

Solution

: 0 0.2 0.4 0.6 0.8 1

: 1 0.961538461 0.862068965 0.735294117 0.609756097 0.5

=

But by actual integration

To compare this approximated value of with its actual value using calculator ,

the error is which is .

114

1143

342

3

17

3

1

3

3

7

1

37

1

2 x

dxx

,1

1

0 2 x

dx2.0h

21

1

xxyLet

x

y

432150

1

0 22

21yyyyyy

h

x

dx

6097566097.0735294117.0862068965.0961538461.025.012

2.0

80.78373152

4tan

1

1

0

11

0 2

xx

dx

783731528.04

134926112.3

43.14159265

1590.00666654 %6.0

Page 13: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

13

3. From the table below, find the area bounded by the curve and

the -axis from to

:

:

Solution

Let us compare the results obtained by different methods

i) By Trapezoidal rule

=

ii) By Simpson’s one-third rule

iii) By Simpson’s three-eighths rule

iv) By Weddle’s rule

As we can see from these rules the area is (correct to four decimal places)

x 47.7x 53.7x

x 7.53 7.52 7.51 7.50 7.49 7.48 7.47

y 2.08 2.06 2.03 2.01 1.98 1.95 1.93

06.203.201.298.195.1208.293.12

01.053.7

47.7 dxxf

0.12035

06.201.295.14403.298.1208.293.13

01.053.7

47.7 dxxf

70.12036666

01.2206.203.298.195.1308.293.18

)01.0(353.7

47.7 dxxf

1203375.0

08.2)06.2(503.201.2698.195.1593.110

)01.0(353.7

47.7 dxxf

12039.0

0.1203

Page 14: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

14

4. Evaluate the integral using the rules so far developed.

Solution

Since let us divide the interval into 6 equal parts, i.e.;

i) By Trapezoidal rule

=

ii) By Simpson’s one-third rule

iii) By Simpson’s three-eighths rule

iv) By Weddle’s Rule

2.5

4nxdxI

2.142.5 ab 2.06

2.1h

x xln x xln

61.64865862 5.2

21.60943791 5.0 11.48160454 4.4

81.56861591 4.8 51.43508452 4.2

31.52605630 4.6 11.38629436 4

)]609437912.1568615918.1526056303.1

481604541.1435084525.1(2648658626.1386294361.12

2.02.5

4

nxdx

91.82765513

)]609437912.1526056303.1435084525.1(

4)568615918.1481604541.1(2648658626.1386294361.13

2.02.5

4

nxdx

827847258.1

)526056303.1(2)609437912.1568615918.1(

3)481604541.1435084525.1(3648658626.1386294361.13

2.02.5

4

dxnx

827847258.1

Page 15: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

15

By actual integration,

Here Weddle’s rule best approximates the exact value.

5. Evaluate by Simpson’s one-third rule correct to five decimal places.

Solution

The interval

Since error where M = Max in the range

Now we require

Hence we take

648658626.1609437912.15568615918.1.1)526056303.1(6

526056303.16481604541.1435084525.15386294361.110

)2.0(32.5

4

dxnx

827847407.1

827847409.112.5

4

2.5

4 nxxnxdx

dxex

1

0

1 ab

,

180

4Mhab

E

)( xe

eh4

180

1

610E

64

10180

eh

1.0090207886.010180 4

16

eh

1.0h

Page 16: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

16

By the actual integration,

Correct to five decimal places which is the same as the exact value.

6. A curve passes through the points

and . Obtain the area bounded by the curve, the -axis, and .

Area =

sq. units

Volume =

= 64.1041981 cubic units.

7. A river is 80 meters wide. The depth ‘d’ in meters at a distance

meters from one bank is given by the following table.

: 0 10 20 30 40 50 60 70 80

: 0 4 7 9 12 25 14 8 3

Calculate the area of cross-section of the river using Simpson’s rule.

718282782.1

4213

1.0 9.07.05.03.01.08.06.04.02.01

0

eeeeeeeeeedxex

718281828.111

0

1

0 eedxe xx

71828.11

0 dxex

(2.5,2.8), (2.0,2.7), (1.5,2.4), (1,2), (3.5,2.6) (3,3),

(4,2.1) x 1x 4x

b

aydxydx

4

1

)6.28.24.2(437.221.223

5.0

7833.72.314.111.46

1

dxydxyb

a 4

1

22

2222222 6.28.24.2437.221.223

5.0

405.2044.8158.3241.86

x

x

d

Page 17: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

17

Solution

Area of cross-section =

= sq. meters

8. The table below gives the velocity of a moving particle at time second. Find the

distance (S) covered by the particle in 12 seconds and also the acceleration at

seconds.

: 0 2 4 6 8 10 12

: 4 6 16 34 60 94 136

Solution

We know that and

To get S

= meters

To find first form the difference table

t v

0 4

2 6

4 16

6 34

8 60

80

0ydx

)81594(4)14127(2303

10 710

v t

2t

t

v

dt

dsv

dt

dva

9434646016213643

212

0 vdtS

552

2

,

tdt

dvaa

v v2 v3

2

10

18

26

34

8

8

8

8

0

0

0

0

Page 18: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

18

10 94

12 136

Taking = 6

Exercise

1. Evaluate taking , using Trapezoidal rule. Can you use

Simpson’s rule? Justify your reasons.

2. Compute the value of correct to four decimal places

taking .

3. Find the value of from using Simpson’s one-third rule

with .

4. When a train is moving at steam is shut off and brakes are applied. The speed of the

train per second after seconds is given by

Time :

Speed :

Using Simpson’s rule, determine the distance moved by the train in seconds.

5. Evaluate a) dividing the range into four equal parts

0

3

0

2

0

2 3

1

2

11vvv

hdt

dv

t

0v

2sec/382

110

2

1m

2

1

21 x

dx2.0h

1

0

cossin dxxx

8.0h

3

1

2log

1

0

3

2

1dx

x

x

25.0h

.sec/30m

t

t 0 5 10 15 20 25 30 35 40

v 30 24 5.19 16 6.13 7.11 10 5.8 0.7

40

1

0

2

dxe x

42 8

Page 19: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

19

b) dividing the range into ten equal parts by

i) Trapezoidal rule and

ii) Simpson’s one-third rule

6. Evaluate taking .

7. Calculate taking .

8. Evaluate taking four strips.

9. Calculate taking 5 ordinates by Simpson’s rule.

10. Evaluate by Weddle’s rule, dividing the range into six

parts.

11. Evaluate dividing into six equal parts using Simpson’s rule,

Weddle’s rule and Trapezoidal rule.

2

0

sin

dxe x

6

h

0

3sin xdx6

h

7

3

2 log xdxx

7.0

5.0

dxxe x

5.0

021

dxx

dx

0

sindx

x

x

Page 20: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

20

Chapter Two

Curve Fitting

Fitting of curves to a set of numerical data is of considerable importance- theoretical as well as

practical. Theoretically it is useful in the study of correlation and regression. In practice it

enables us to represent the relationship between two variables by simple algebraic expressions

(polynomials, exponential or logarithmic functions or any). Besides, it may be used to estimate

the values of one variable which would correspond to the specified values of the other

variable(s).

This chapter covers how to fit a curve for a given set of data points using different methods and

it focuses on the following points:

Regression

- Linear regression

- quadratic regression

- polynomial regression

- multiple regression

- fitting an exponential curve

- curve fitting with Sinusoidal Functions

In most of the fields of engineering and science, we come across experiments which

involve many variables, and most of the time data is collected or given for discrete values

along a continuum; the relation between these variables can be discussed so easily and for

many of these variables it is very difficult to identify the relation unless we can model the

system mathematically. When the system is explained in terms of mathematical models we

have the following relationships about the variables:

1. The relationship between these variables is given in terms of

Page 21: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

21

mathematical rules, formulae if any, to determine the quantities of these variables. Actually

it is simple to use these rules for application.

2. The quantities/ variables are given so that we will be interested in finding the

relationships between these variables. This process is a little bit difficult because to write

one variable in terms of the other variables (called empirical equation). Most of the time

we may not be able to get an exact relation between these variables and we may get only

an approximate relation or curve.

This approximating curve is an empirical equation and the method of finding such an

approximating curve is called curve fitting.

Suppose , be sets of observations and the law relating and

can be determined by different mathematical systems that clearly explains the relationship

between these sets of observations . Actually, here we may have different approaches to

fit the given data, and one system may approximate better than the other system on the same given

set of data points.

Now we will see some of these different approaches:

REGRESSION

1. LINEAR REGRESSION

Suppose that the relationship is given

, . (1)

Equation (1) represents a family of straight lines for different values of the arbitrary constants ' '

and ' '. The problem now is to determine ' ' and ' ' so that the line (1) is the line of "best fit".

The term best fit is interpreted in accordance with the Legendre's principle of least squares which

consists of the deviations of the actual values as given by the line of best fit. As a matter of

ii yx , ni ,...,3,2,1 n x

y

n ii yx ,

ii bxay ni ,...,3,2,1

a

b a b

Page 22: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

22

chance all the points may lie on a straight line and in this case the line is a 'perfect fit' and the

sum of the squares of the deviations is zero.

Let be any point in the scatter diagram. Draw perpendicular to the x-axis meeting

the line in . The coordinates of are .

PiHi is called the error of estimates or the residual for .

According to the principle of least squares, we have to determine a and b so that

is the minimum.

Using the principle of maxima and minima what we have studied in calculus, the partial

derivatives of E with respect to and should vanish separately.

That is,

),( iii yxP MPi

bxay iH iH ii bxax ,

)( ii

iiii

bxay

MHMPHP

iy

n

i

n

i

iiii bxayHPE1 1

22)(

a b

n

i

ii bxaya

E

1

0)(2

ixbna

xbay

n

i

i

n

i

i

n

i

n

i

i

1

111

Page 23: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

23

.

Equations (i) and (ii) are called normal equations.

Solving for and from (i) and (ii), we get the values of and , and with these values of

and so obtained, equation (1) is the line of best fit to the given set of points ,

.

Now let us see some examples to illustrate the above discussion.

Example 1. By the method of least squares find the best fitting

straight line to the data given below:

: 5 10 15 20 25

: 15 19 23 26 30

Solution

Let the line of best be

The normal equations are

We calculate and form the table below

iixbxayx

bxayxb

E

n

i

i

n

i

i

n

i

ii

n

i

iii

1

2

11

1

0)(2

a b a b a

b ii yx ,

ni ,...,3,2,1

x

y

bxay

n

i

i

n

i

i xbay11

5

n

i

i

n

i

i

n

i

ii xbxayx1

2

11

xyxyx ,,, 2

Page 24: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

24

5 15 25 75

10 19 100 190

15 23 225 345

20 26 400 520

25 30 625 750

75 114 1375 1885

Using these values in the normal equations, we get

Solving for and we get a=12.3 and b=0.7 and thus the line of best fit is

Example 2. Find the best fitting straight line to the data given below

by the method of least squares and also estimate when

is 70.

: 71 68 73 69 67 65 66 67

: 69 72 70 70 68 67 68 64

Solution

First transform the values of and to

and the normal equations are

Calculations:

71 69 3 -1 9 -3

68 72 0 2 0 0

xyxyx 2

1885137575

114755

ba

ba

a b xy 7.03.12

y

x

x

y

x y 70 and 68 yYxX

XYXaXb

YaXb

2

8

YXYXx X y 2

Page 25: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

25

73 70 5 0 25 0

69 70 1 0 1 0

67 68 -1 -2 1 2

65 67 -3 -3 9 9

66 68 -2 -2 4 4

67 64 -1 -6 1 6

2 -12 50 18

Substituting these values in the normal equations, we get

Solving for and , we get

Thus the line of best fit is of the form

This implies

When

1. Quadratic Regression (Fitting Of Second Degree Parabola)

Let be the second degree parabola of best fit to set of points ,

.

Using the principle of least squares, we have to determine and so that

is minimum.

18250

1282

ab

ab

a b99

16a and

99

35b

99

16

99

35 XY

99

16)68(

99

3570 xy

99

4566

99

35 xy

87.7070 yx

2cxbxay n ii yx ,

ni ,...,3,2,1

,,ba c

2

1

2

n

i

iii cxbxayE

Page 26: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

26

Equating to zero the partial derivatives of E with respect to and separately, we get the

normal equations for estimating and as

…………………. (1)

Solving for and from (1), (2) and (3), we get with these values of and the

parabola of best fit.

Example 1 Fit a parabola of second degree to the following data

X: 0 1 2 3 4

Y: 1 1.8 1.3 2.5 6.3

Solution

X Y XY Y

0 1 0 0 0 0 0

1 1.8 1 1 1 1.8 1.8

2 1.3 4 8 16 2.6 5.2

,,ba c

,,ba c

021

2

n

i

iii cxbxaya

E

n

i

i

n

i

i

n

i

i xcxbnay1

2

11

021

2

i

n

i

iii xcxbxayb

E

)2....(....................1

3

1

2

11

n

i

i

n

i

i

n

i

i

n

i

ii xcxbxayx

02 2

1

2

i

n

i

iii xcxbxayc

E

)3...(....................1

4

1

3

1

2

1

2

n

i

i

n

i

i

n

i

ii

n

i

i xcxbxayx

,,ba c ,,ba c

2X 3X 4X 2X

Page 27: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

27

3 2.5 9 27 81 7.5 22.5

4 6.3 16 64 256 25.2 100.8

10 12.9 30 100 354 37.1 130.3

Substituting these values in the normal equations, we get

Solving for and , we get

, and

is the best fit.

Exercise

1. Find the best fitting parabola to the data given below by the

method of least squares and also estimate when is 70.

: 71 68 73 69 67 65 66 67

: 69 72 70 70 68 67 68 64

2. Polynomial Regression Fitting Of A Polynomial Of kth

Degree

If is the kth

degree polynomial of best fit to the set of points

; the constants are to be obtained so that

is minimum.

Thus the normal equations for estimating are obtained on equating to zero the

partial derivatives of E with respect to separately.

cba

cba

cba

354100303.130

10030101.37

301059.12

,,ba c

07.1,42.1 ba 55.0c

255.007142.1 xxy

y x

x

y

k

k xaxaxaay ...2

210

ii yx , ni ,...,3,2,1naaaa ,...,,, 210

n

i

k

ikiii xaxaxaayE1

22

210 ...

naaaa ,...,,, 210

naaaa ,...,,, 210

Page 28: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

28

Exercise

1. Find the polynomial of degree three that best fits the data given below by the method of

least squares and also estimate when is 70.

: 71 68 73 69 67 65 66 67

: 69 72 70 70 68 67 68 64

4. Multiple Regressions

There are different multiple regression forms. For the sake of discussion let us see the following

regression type.

Suppose we want to fit the set of data points by the relation

, here we need the points to be of the form .

We determine the values of and , from

k

ikiii xaxaxanaya

E...0 2

210

0

12

10

11

...0 k

kii

n

i

ii xaxaxayxa

E

k

ik

k

i

k

i

n

i

i

k

i

k

xaxaxayxa

E 21

10

1

...0

y x

x

y

cybxyaxZ iii zyx ,,

,,ba c

n

i

iiiii cyybxaxzE1

2

021

i

n

i

iiiii xcyybxaxza

E

)1(..............................2

1

2

1

iiii

n

i

i

n

i

ii yxcyxbxazx

Page 29: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

29

By solving (1), (2) and (3) for and , we get the best approximation.

5. Fitting an Exponential Curve

Let , be the sets of observations of related data and let be the

best fit for the data.

Then taking logarithm on both sides,

(*)

Let and , then (*) reduces to

which is linear in and , we can find since and are known, and from

we can get and hence is found out.

Fitting a curve of the form

Using this linear fit, we find .

ii

n

i

iiiii yxcyybxaxzb

E

1

2

)2(..............................1

22

1

2

1

2

1

n

i

iii

n

i

ii

n

i

i

n

i

iii yxcyxbyxayxz

i

n

i

iiiii ycyybxaxzb

E

1

2

)3(..............................1

22

111

n

i

ii

n

i

ii

n

i

i

n

i

ii ycyxbyxayz

,,ba c

ii yx , ni ,...,3,2,1 nxaby

logloglog101010

bay

x

,, loglog1010

ay

AY log10

b

B

BxAY x Y BA, x Y

BA, ba,xaby

baxy

baxy

logloglog101010

xay

b

logloglog101010

,,,xay

xAylettingbxAY

bA,

Page 30: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

30

are known and thus is found out.

Example 1. From the table given below, find the best values of

a and b in the law by the method of least squares.

: 0 5 8 12 20

: 3.0 1.5 1.0 0.55 0.18

Solution

Let be the approximating curve.

where B = b

So the normal equations are

y Y Y

0 3.0 0.4771 0 0

5 1.5 0.1761 25 0.8805

8 1.0 0 64 0

12 0.55 -0.2596 144 -3.1152

20 0.18 -0.7447 400 -14.894

45 -0.3511 633 -17.1287

Substituting these values, we get

Solving for and , we get

ba,baxy

bxaey

x

y

bxaey

BxAYbxAYe

log10

log10

e

xYxAxB

YAxB

2

5

x 2x x

1287.1763345

3511.0455

BA

BA

A B

Page 31: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

31

So

Hence the curve is

Exercise

1. Fit a straight line to the following data and hence find

: 0 5 10 15 20

: 7 11 16 20 26

2. Fit a straight line to the data

: 0.5 1.0 1.5 2.0 2.5 3.0

: 0.31 0.82 1.29 1.85 2.51 3.02

3. Fit a parabola to the data

: 1 2 3 4 5

: 2 3 5 8 10

4. Fit a curve of the form to the data given below:

: 1 2 3 4 5 6 7 8

: 15.3 20.5 27.4 36.6 49.1 65.6 87.8 117.6

5. Fit a curve of the form to the data given below

4815.0A

0613.0B

0304.31010 4815.0 Aa

0613.0log10

e

bB

1411.0)0613.0( log10

e

b

xey 1411.00304.3

)25( xy

x

y

x

y

x

y

bxaey

x

y

cxybyaxz

Page 32: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

32

(0,0,1), (0,1,2), (1,0,4), (1,1,1), (2,0,4), (1,2,5)

6. It is given that , and are related by to the data below and obtain the best

values of a and b.

: 1 2 4 6 8

: 5.43 6.28 10.32 14.86 19.5

x y bxx

ay

x

y

Page 33: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

33

Chapter Three

Numerical Solution of Ordinary Differential Equations

In this chapter we are highly interested in finding the solution of ordinary differential

equation numerically using different methods.

The topics covered here is

- Taylor series method

- Taylor series method for simultaneous first order DE

- Taylor series method for second order differential equation

- Picard’s method of successive approximations

- Euler’s Method

- Runge-Kutta method

- Predictor-corrector method

In the fields of Engineering and Science, we come across through the natural phenomena that can

be represented by mathematical models which happen to be in the form of differential equations;

for instance, the equation of motion, the equation of deflection of a beam, etc. The solution of

these differential equations is very essential in the studies of such phenomena.

While finding the solution of these differential equations there are number of differential

equations that we cannot solve analytically; however, in such situations, depending on the nature

of the model, we go for numerical solutions of these differential equations. In many researches,

especially after the advent of modern computers, the numerical solutions of the differential

equations have become very easy for manipulation.

Page 34: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

34

Thus, in this part we try to look some of the methods of numerical solutions that are

approximate solutions and in many cases these solutions are in the required (desired) degree of

accuracy and are quite sufficient.

Suppose we want to solve with the initial condition .

Let , , , … be the solution of at

Let be the exact solution. If we plot and draw the graph of

, (the exact curve) and also draw the approximate curve by plotting

(the approximated solution graph) we get two curves.

Suppose

The equation subject to the initial condition

is called an initial-value problem.

Using Taylor series we can expand in the neighborhood of as a power

series of . That is, if is close to , then by Taylor’s series, we have

),( yxfdx

dy 00 )( yxy

00 )( yxy 11)( yxy 22 )( yxy y ,...,, 210 xxxx

)(xyy

)(xyy

),...,(),,(),,( 221100 yxyxyx

)1........(,' yxfdx

dyy

),( yxfy

00)( yxy

)(xy 0x

0xx x0x

M

Q

P (x0,y0)

Approximate solution

Exact solution

QM = approximate value

PM = exact value at x = xi

Then QP = QM-PM

= yi – y(xi) = is called

Page 35: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

35

where etc

If is close to , substitute in (*) and get

Again starting from , express in a power series of and then substitute to

get . In this way we can get the sequence of values

If , we get the Maclaurin’s series expansion,

Example 1. Evaluate the solution of the differential equation

by taking four terms of its Maclaurin’s series for , ,

given and compare this result with its exact

solution.

Solution

By Maclaurin’s series, we have

....!3

'''

!2

'''

3

00

2

00000

xxxyxxxyxxxyxyxy

,'','

00

2

2

00

xxxx dx

ydxy

dx

dyxy

1xx 0x1xx )( 11 xyy

1x )(xy 1xx 2xx

)( 22 xyy y ,...,, 210 yyy

00 xx

...0''!2

0'02

yx

xyyxy

12 ydx

dy

0x 2.0x

6.0x 0)0( y

1' 2 yy 10' y

'2'' yyy 00'020'' yyy

''2'2''' 2 yyyy 20''' y

'''6'''24 yyyyy 004 y

...0'''!3

0''!2

0'032

yx

yx

xyyxy

Page 36: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

36

Exact solution

Let us compare the actual value with the approximate value

Values of x 0 0.2 0.4 0.6

Actual value of y 0 0.2027 0.4228 0.6841

Approximate value of y 0 0.2027 0.4213 0.6720

Error 0 0 0.0015 0.0121

Percentage of error 0 0 0.35 1.77

This table shows that when the distance of from increases the error also increases.

In this example, we have expanded in the neighborhood of and used the same

result to find when , and .

Now instead of doing this, after getting , expand again in the

neighborhood of and use this result to get . In doing so, we can minimize the

error.

Thus in the neighborhood of

...!5

16

!320

53

xx

x

0)0( y

00032.015

2

3

008.02.02.0

15

2

3

2.02.02.0

53

y 4213.0

6720.06.015

2

3

6.06.06.0

53

y

xycxydxy

dytantan

1

1

2

6942.06.0tan,2927.02.tan,00tan o

x0x

)(xy 0x

)(xy 2.0x 6.0x

)2.0()( 1 yxy )(xy

2.0x )6.0(y

2.0x

Page 37: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

37

= = (0.2027)2 + 1 = 1.0411

…, etc.

Putting these values and using in (1), we get

When we compare this value with the actual one i.e. 0.4228, we see that the error is only 0.0003,

nearly 0.07%

The error has decreased from 0.35% to 0.07%

Therefore, to reduce the error, each time obtain the power series of at and use this

to get and so on.

This method is called the method of starting the solution.

Point Wise Methods

Consider the previous example

First we got in terms of x and then we substituted

...!3

2.02.0'''

!2

2.02.0''2.02.0'2.0

32

xyxy

xyyxy

2027.0)2.0( y

)2.0(y 1))2.0(( 2 y

4221.00411.12027.022.0'2.022.0'' yyy

2.0''2.022.0'22.0'''2

yyyy

,3389.24221.02027.020411.122

4.0x

...2.04.06

3389.22.04.0

2

4221.02.04.00411.12027.04.0

32y

...)389871.0)(008.0()21105.0)(04.0()0411.1(2.02027.0

4225.0422480536.0

)(xy 1 ixx

)( 2ixy

0)0(,1' 2 yyy

...3

)(3

x

xxy

Page 38: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

38

. Instead, without getting as a function of we can directly get =

as

That is we get directly. So, a point wise solution is a series of points

which satisfy approximately a pre-assigned but not known particular solution.

Solution Using Taylor Series

AIM- To find the numerical solution of the equation

given the initial condition ……….. (1)

Now, we expand about the point using Taylor’s series in powers of .

That is,

Where

, where or

To find we use (1) and its derivatives at .

Even though the series in (2) is an infinite series, we can truncate it at any convenient term, if h

is small, and the accuracy can be obtained.

2.01 xx )(xy x )( 1xy )2.0(y

...!3

2.00'''2.0

!2

)0(''2.0)0(')0(2.0

32

yy

yyy

),(),,( 2211 yxyx

),...,(),,( 2211 yxyx

yxfdx

dy, 00 yxy

)(xy 0xx 0xx

...''!2

' 0

2

0000

xy

xxxyxxxyxy

0

0

xxdx

ydxy

r

rr

)2(...!3!2

'''

0

3''

0

21

0011 yh

yh

hyyxyy

01 xxh hxx 01

,..., ''

0

'

0 yy 0xx

Page 39: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

39

Now, once if we get , we can calculate etc by using

Again, expanding , in a Taylor’s series about the point

, we get

Proceeding in the same way, we get

Since this is an infinite series, to get an approximate value we have to truncate it at some term to

have a calculated numerical value.

Now, let us consider the terms up to and including and neglect terms involving and

higher powers of . The Taylor algorithm used this way is said to be of nth

order.

Thus, the truncation error is . If h is small enough we can neglect terms after the nth

term and get the error as

where

Example 1. Solve given , and find by using

Taylor’s method.

Solution

Here and

y ,,..., ''

1

'

1 yy

),( yxfy

)(xy

1xx

...!3!2

'''

1

3''

1

2'

112 yh

yh

hyyy

...!3!2

'''3

''2

'

1 nnnnn yh

yh

hyyy

nh 1nh

h

)( 1nhO

nn

fn

h

!hxxifxx 0110

,yxdx

dy 0)1( y )2.1(),1.1( yy

10 x 0.1 ,00 hy

yxydx

dy ' 010 xyy

Page 40: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

40

Thus by Taylor’s method, we have

Now again take and

Let us check for its exact solution

1''' yy 10100

'

0 yxy

''''' yy 2110'' y

etcy ,20'''

...!3!2!1

'''

0

3''

0

2'

001 yh

yh

yh

yy

...2!5

1.02

!4

1.02

!3

1.02

!2

1.011.001.1

5432

y

...000000166.000000833.000033.001.01.0

11033847.0

1.10 x 1.0h

21033847.111033847.01.111

'

1 yxy

21033847.21 '

1

''

1 yy

...

2103384.2

5

1

4

1

'''

1

1

'''

1

yyy

yy

...21033847.2

!4

1.0

21033847.2!3

1.021033847.2

2

1.021033847.11.011033847.0

4

32

2

y

...)21033847.2()0016667.0()005.0(21033847.2121033847.011033847.0

2461077.0

Page 41: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

41

Let

and

Integrating both sides,

Since

Hence

Example 2. Using Taylor series method, compute correct to

four decimal places, given and .

Solution

here and

yxdx

dy

dx

dy

dx

dvvyx 1

1 vdx

dv

1

v

dvdx

1 vncx

1 yxncx

cxeyx 1

0)1( y

102 ce

1221 ncnc

121 xexy

60.11034183 211.1)1.1( 11.1 ey

60.24280551 212.1)2.1( 12.1 ey

)1.0(y

22 yxdx

dy 10 y

22' yxydx

dy 00 x 1.0,10 hy

1100' 22 y

222'' '

000 yyxy

Page 42: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

42

Example 3. Using Taylor method, compute and

correct to four decimal places given

and

Solution

etc

By Taylor’s series, we have

8222 ''

00

'

0

'''

0 yyyy

2826224 ''

0

'

0

''

0

'

0

'''

00

''

0

'

0

''

0

'

0

4

0 yyyyyyyyyyy

...28!4

1.08

!3

1.02

2

1.01

1

1.011.0

432

y

70.00011666330.001333330.010.11 1.11144999

11145.1

)2.0(y )4.0(y

xydx

dy 1 00 y

xyy 21' 121 00

'

0 yxy

'2'' xyyy 01002''

0 y

''''2''' xyyyy 4022'''

0 y

'''''324 xyyy 04

0 y

45 '''42 xyyy ,325

0 y

...!4!3!2

4

0

4'''

0

3''

0

2'

001 yh

yh

yh

hyyy

...33!5

2.00

!4

2.04

!3

2.00

!2

2.012.002.0

5432

y

000085333.000533333.02.0

Page 43: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

43

Now again starting with , we have

,

.

Example 4. Using Taylor series method, find at

and given (correct to five decimal places)

Solution

Here

194752003.0

2.0x

2.0x 2.0,194752003.00 hy

9220992.0194752003.02.02121 00

'

0 yxy

758343806.0194752063.09220992.02.022 0

'

00

''

0 yyxy

9220992.027583436806.02.0222 ''

00

'

0

'''

0 yxyy

38505933.3

90408585.5758343686.0()38505933.3)(2.0(24

0 y

...90408585.5

!4

2.038505933.3

!3

2.0

)758343686.0(2

2.0)9220992.0)(2.0(194752003.04.0

43

2

y

359883723.0

y 2.0,1.0 xx

4.0x 10,2 yyxdx

dy

,...2.0,1.0,1.0,1,0 2100 xxhyx

yxy 2' 1'

0 y

'2'' yxy 1''

0 y

''2''' yy 112'''

0 y

Page 44: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

44

= 1+ (-0.1) + 0.005 + 0.0001666 + (-0.0000416) +…

= 0.905125

Now again using and , we have

etc.

= 0.821235167

Similarly, and

Taylor series method for simultaneous first order differential equations

The equation of the type

and

with initial conditions

'''4 yy 14

0 y

45 yy etcy ,10 5

0

...1!5

1.01

!4

1.01

!3

1.01

2

1.011.01

2

1.0)1)(1.0(1)1.0(

5432

2

y

1.01 x 905125.01 y

895125.0090512501.01

2

1

'

1 yxy

095125.1)895125.0(2.02 '

11

''

1 yxy

904875.0090512522 ''

1

'''

1 yy

,904875.0'''

1

4

1 yy

095125.12

1.0895125.01.0905125.02.0

2

y

...904875.0

!4

1.0904875.0

!3

1.043

7492.0)3.0( y 6897.0)4.0( y

zyxfdx

dy,, zyxg

dx

dz,,

0000 ,)( zxzyxy

Page 45: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

45

can be solved by Taylor series method as given below:

Example 5. Solve with by taking

, to get and .

Solution

and

and and

Using Taylor series, for and , we have

…… (1)

and

Substituting these in (1) and (2), we get

xydx

dzxz

dx

dy , 1)0(,10 zy

1.0h )1.0(y )1.0(z

xzy ' yxz '

00 x 10 y 1,0 00 zx 1.0h

?)1.0(1 yy ?1.01 zz

xzy ' '1'' yz

1''' zy etcyz '''''

''''' zy

1y 1z

...!3!2

1.0 0

3''

0

2'

001 yh

yh

hyyyy

)2(........!3!2

)1.0( '''

0

3''

0

2'

001 zh

zh

hyyzz

10 y 10 z

100

1

0 xzy 11000

'

0 yxz

011'

0

''

0 zy 2111 '

0

''

0 yz

2''

0

'''

0 zy 0''

0

'''

0 yz

2'''

0

4

0 yz

Page 46: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

46

= 1+0.1+0.000333+…

= 1.1003

=1+ 0.1 + 0.01+0.0000083+… = 1.1100

Example 6. Find given

and

Solution

Here and

etc

...024

0001.02

6

001.00

2

01.01.011 y

...224

0001.00

6

001.02

2

01.01.011 z

2.0,2.0,1.0 zyy

2, yxdx

dzzx

dx

dy 10,20 zy

2,0 00 yx 10 z

zxy '2' yxz

'1'' zy '21'' yyz

''''' zy ''2'2'''2

yyyz

etczy '''4 ''2'''6'''2'''2'''44 yyyyyyyyyyz

10 00

''

0 zxyy 420 2'

0 z

341'

0 y 31221''

0 z

3''

0 y 10322122'''

0 z

104

0 y 303223164

0 z

305

0 y 745

0 z

...30

120

1.010

24

1.03

6

1.03

2

1.0)1)(1.0(2)1.0(

5432

y

Page 47: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

47

= 2.084544167

= 2.084544167+0.267132966-0.016226621-0.0003105449027

- (0.000003091501458) +…

=0.152817221

Taylor series method for second order differential equation

Any differential equation of the second order or higher can be solved by reducing it to

a lower order differential equation. A second order differential equation can be reduced to a first

order differential equation by transforming and then the given equation can be solved so

easily.

Suppose …… (1)

is the given differential equation together with the given initial

conditions

and where , are known values at .

Setting , we get and (1) becomes

with initial condition and =

Using Taylor series method, we get

where …… (*)

...74

120

1.030

24

1.010

6

1.03

2

1.0)4)(1.0(1)1.0(

5432

z

...

24

1.074196035.0

6

1.0863269416.1

2

1.0)245324384.4)(1.0(5867855.0)2.0(

432

y

zy

dx

dyyxf

dx

yd,,

2

2

',,'' yyxfy

00)( yxy 00)( yxy 0y 0y 0x

py py

),,(' pyxfp

00)( yxy 00)( pxp 0y

...!32

'''

0

3''

0

2'

001 yh

ph

hppp hxxxxpp 0111 &

Page 48: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

48

becomes

Since and taking the derivative of again and again with respect to x, we get

, etc.

Hence can be solved using (**) and (*), so that we can get

& .

Once knowing and we can get

Again using

we get some value for and using

we get still some value for .

Example 7. Evaluate the values of and given

by using Taylor series method.

Solution

First put and hence the equation reduces to

Using the initial condition

Now can be solved given that

Here,

...!32

'''

0

3''

0

2'

001 yh

yh

hyyy

...(**)...!3!2

0

3

0

2

001

ph

ph

hpyy

),,(' pyxfp p

pp ,

,...,, '''

0

''

0

'

0 ppp

1y 1p

1y 1p 11

'''

1

''

1

'

1 ,,...,, yxatppp

...!3!2

'''

1

3''

1

2'

112 ph

ph

hppp2p

...!3!2

'''

1

3''

1

2'

112 yh

yh

hyyy2y

)1.0(y )2.0(y

00',10,0'''' 22 yyyyxy

zy 0' 22 yxzz

22' yxzz

0,10 '

00 yzy

22' yxzz 0,00 00 xandzz

1......2

''

0

2'

001 zh

hzzz

Page 49: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

49

and

Substituting, these values in (1), we get

= -0.0997

By Taylor series for , we get

= 0.995

Similarly,

22' yxzz zy '

'2'22'' yyxzzzz ,....''''',''' zyzy

22'''2''''2'2''' yyyzxzzxzzzzz

12

0

2

00

'

0 yzxz

0''

0 z 2'''

0 z

...26

001.00

2

01.011.001 z

1y

...2

)1.0( ''

0

2'

001 yh

hyyyy

...6

1.0

2

1.0))(1.0(1 ''

0

3

'

0

2

0 zzz

...)0(6

001.0)1(

2

01.001.01

...2

''

1

2'

1122 yh

hyyxyy

2......6

001.0

2

01.01.0995.0 ''

1

'

11 zzz

9890.0995.00997.01.0222

1

2

11

'

1 yzxz

1687.0''

1 z

Page 50: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

50

Using (2),

= 0.9801

Example 8. Solve and calculate .

Solution

Here and

Differentiating with respect to x,

Here

Exercise

Using Taylor series method, find the values required in each problem.

1. Find given

....1687.06

001.09890.0

2

01.00997.01.0995.02 y

00''' ygivenxyyy )1.0(y

0,1,0 '

000 yyx ''' xyyy

'''2''''''' xyyxyyyy 1'

000

''

0 yxyy

'''''3'''''''24 xyyxyyyy 02 ''

00

'

0

'''

0 yxyy

45 '''4 xyyy 34

0 y

546 5 xyyy 05

0 y ,...156

0 y

...!32

'''

0

3''

0

2'

00 yx

yx

xyyxy

...3!4

01!2

0142

xx

...4882

1642

xxx

00501252.1....

48

1.0

8

1.0

2

1.01

642

)1.0(y 1)0( , yyxdx

dy

Page 51: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

51

2. Find given

3. Obtain and given taking .

4. Find given .

5. Find given

and

6. Evaluate given

given at

7. Solve for x and y given at .

8. Find at given

9. Express as a power series given,

Picard’s Method of Successive Approximations

AIM: To solve subject to

Now

Integrating,

Setting , we have

)1.0(y 1)0( ,12 yyxy

)2.4(y )4.4(y 4)4( ,1

2

y

yxdx

dy2.0h

)3.0(),2.0(),1.0( yyy 1)0( ,23

ye

xyxy

x

)2.0(),1.0(),2.0(),1.0( zzyy

2, yxdx

dzzx

dx

dy 1)0(,2)0( zy

)2.0(),2.0(),1.0(),1.0( yxyx

txdt

dyty

dt

dx ,1 1,0 yx 0t

txdt

dytyx

dt

x 2 , 1,0 yx 1t

y 1.3 x,2.1 ,1.1 xx 1)1( ,1)1( ,32 yyxyyy

y 1)0( ),)(1.0( 22 yyxy

yxfdx

dy, 00)( yxy

dxyxfdyyxfdx

dy,,

cdxyxfyx

,

0xx

cdxyxfyx

0

,0

dxyxfyyx

x0

,0

Page 52: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

52

this type of equation is called an integral equation.

As the integration is not possible as it is, we will solve it numerically by successive

approximation. Now substitute the initial values of namely in the integrand in

place of and then integrate it to get an approximate value of .

i.e.

After getting the first approximation for , use this value of in place of in

and then again integrate to get the second approximation of namely .

Thus

Repeating this procedure again and again, we eventually get

This equation is called Picard’s iteration formula. This formula gives the general iterative

formula for y.

The sequence , ,…, should converge to ; otherwise the process is not valid.

The condition for the convergence of the sequence is both and are continuous.

i.e. in a region containing the point where , are

constants.

Example 1. Solve , , by Picard’s method up to the

third approximation. Hence find the value of .

dxyxfyyx

x0

,0

y0y ),( yxf

y y

dxyxfyyx

x0

00

1 ,

)1(y y )1(y y

),( yxf y )2(y

dxyxfyyx

x0

1

0

2 ,

dxyxfyyx

x

nn

0

1

0 ,

)1(y )2(y )(ny )(xy

),( yxfy

f

21, ky

fdnakyxf

),( 00 yx

1k 2k

2xyy 1)0( y

)2.0(),1.0( yy

Page 53: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

53

Solution

Hence, x0 = 0, y0 = 1 and

Using y(1)

again in (1), we get

Using again this result, we get

Now put

2' xyy

....0

2

0 dxxyyyx

x

2),( xyyxf

1.....10

2 dxxyyx

3

1113

0

21 xxdxxy

x

dxxyyx

0

212 1

dxxx

xx

0

23

311

12321

432 xxxx

dxxyyx

0

223 1

dxxxxx

xx

0

2432

123211

6012621

5432 xxxxx

1.0x

60

1.0

12

1.0

6

1.0

2

1.01.011.0

5432

y

Page 54: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

54

=

Note- In getting the value we could have started with = 0.1 and

= 1.104824833 to get a closer value of

i.e.

Example 2. Solve given . Obtain the values of

and using Picard’s method and check your

104824833.1

60

2.0

12

2.0

6

2.0

2

2.02.012.0

5432

y

1.218528

)2.0(y 0x

0y )2.0(y

dxxyyx

1.0

2

0104824833.1

x

xxyy

1.0

3

0

1

3104824833.1

3

1.0)1.0(104824833.1

3104824833.1104824833.1

33

x

x

3104824833.199467574.0

3xx

dxxyyx

1.0

212 104824833.1

dxxx

xx

0

23

3104824833.199467574.0104824833.1

22 1.0104824833.1)1.0(99467574.0104824833.1 xx

3344 1.03

11.0

12

1 xx

2184066.12.02 y

,yxdx

dy 1)0( y

)1.0(y )2.0(y

Page 55: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

55

result with the exact solution.

Solution

Here and

=

Now put

0 ,),( 0 xyxyxf 10 y

dxyxfyyx

x0

,0

dxyxfx

0

,1

dxyxfyx

0

1 ,1

dxxx

0

1,1

2

1112

0

xxdxx

x

dxxx

xyx

0

22

211

61

32 x

xx

dxx

xxxyx

0

323

611

2431

432 xx

xx

...243

143

2 xx

xxxy

1.0x

...24

1.0

3

1.01.01.011.0

432

y

Page 56: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

56

=

To find we use = and =

=

=

...24

0001.0

3

001.001.01.01

1.1103374

)2.0(y 0x 0.10y 1.1103374

x

dxyxfyy1.0

0 ,

x

dxyx1.0

1103374.1

x

dxxy1.0

1 1103374.11103374.1

))1.0(()1.0(1103374.11103374.1 22 xx

21103374.198930366.0 xx

x

dxxxxy1.0

22 1103374.198930366.01103374.1

3322 1.03

1))1.0((1103374.2)1.0(98930366.01103374.1 xxx

32

3

11103374.298930366.0989970326.0 xxx

x

dxxxxy1.0

323

3

11103374.298930366.1989970326.01103374.1

))1.0((98930366.1)1.0(989970326.01103374.1 22 xx

4433 1.012

11.01103374.2 xx

0015.012

1)007.0(1103374.2

)03.0(98930366.1)1.0(989970326.01103374.12.03

y

41.28391090

Page 57: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

57

Solving analytically, we get

= and

=

Example 3. Solve by Picard’s method

Solution

Here

=

Now

Example 4. Solve , by Picard’s method

Solution

By Picard’s method

yxdx

dy 12 xey x

)1.0(y 61.11034183

)2.0(y 61.24280551

10,22 yyxdx

dy

1,0 00 yx

dxyxfyyx

x0

,0 dxyx

x

0

221

3

1113

0

21 xxdxxy

x

dxx

xxyx

0

23

22

311

5743

2

15

2

63

1

6

1

3

21 xxx

xxx

...63

1

15

2

6

1

3

21 75432 xxxxxx

0)0(, yeyy x

x

xdxyxfyy

0

),(0 dxye

xx

0

100

1 x

xx edxey

Page 58: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

58

Exercise

1. Using Picard’s iterative formula,

a) Solve , given .

b) Obtain given and

c) Solve given

2. Find the values of for and given and which passes

through .

3. Given and , find

xdxeeyx

xx 02 1

12

2

0

3 x

edxxey xx

x

dxx

eeyx

xx

0

24 1

2

xx

6

3

dxxx

eyx

x

0

35

6

1242

42

xx

ex

1242

42

xx

exy x

12 yxdx

dy0)0( y

)1.0(yxy

xyy

1)0( y

xyy 21 0)0( y

y 1.0,0 xx 5.0x 22 yxy

)1,0(

2

2

1 y

xy

0)0( y )5.0(),25.0( yy

Page 59: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

59

Euler’s Method

In solving a first order differential equation by numerical methods, we have two types of

solutions:

i) Values of at specified values of

ii) A series solution of in terms of , which will yield the value of at a particular

value of by direct substitution in the series solution.

Taylor and Picard’s method studied so far belong to the first category in finding the numerical

solution of differential equations; the methods due to Euler, Runge-kutta, Adam-Bash Forth and

Milne come under the second category.

The methods of second category are called step-by-step methods because the values of are

calculated by short steps ahead of equal interval of the independent variable .

Euler’s method

Suppose we want to solve with initial conditions

Let us take the points

i.e. ,

Let the actual solution of the differential equation be denoted by the graph lies on

the curve. We require the value of the curve at .

The equation of the tangent line at to the curve is

y x

y x y

x

y

h x

yxfdx

dy, 00)( yxy

hxxxxxx ii 1210 where,...,,

ihxxi 0 ,...2,1,0i

),( iiii yxPP

yixx

),( 00 yx

0

P0

P1

P2

Q2

(x1,y1) Q1

M0 M1 M2

y

x0 x1 x2 x

Page 60: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

60

=

In the interval , the curve is approximated by the tangent.

The value of on the curve is approximately equal to the value of on the tangent

at corresponding to .

i.e.

Again, we approximate the curve by the line through and whose slope is f , we

get

Thus,

This formula is called Euler’s algorithm.

In other words,

In this method, the actual curve is approximated by a sequence of short straight lines.

As the intervals increase the straight line deviates much from the actual curve. Hence the

accuracy cannot be obtained as the number of intervals increase.

Referring to the above graph

error at

= it is of order h2.

0

'

,0 00xxyyy yx

000 , xxyxf

0000 , xxyxfyy

),( 10 xx

y y

),( 00 yx ixx

010001 , xxyxfyy

'

001 hyyy

),( 11 yx ),( 11 yx

hyxfyy 1112 ,

'

11 hyy

,...2,1,0,,1 nyxhfyy nnnn

),()()( yxhfxyhxy

11PQ 1xx

11

2

11

2

01 ,''2

,''!2

yxyh

yxyxx

Page 61: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

61

Example 1. Given and , determine the values of at

and by Euler method.

Solution

and ;

Here

We have to find . Take

By Euler algorithm,

Let us compare the results

Example 2. Using Euler’s method, solve numerically the equation,

for and .

Check your answer with the exact solution

yy 1)0( y y

02.0,01.0 xx 04.0x

yy 1)0( y yyxf ),(

04.0,03.0,02.0,01.0,1,0 432100 xxxxyx

4321 ,,, yyyy 01.0h

nnnnnn yxhfyhyyy ,'

1

99.001.01101.01, 0001 yxhfyy

))(01.0(99.0 1

'

112 yhyyy

9801.099.001.099.0

9801.001.09801.0, 2223 yxhfyy 0.9606

9703.001.09703.0, 3334 yxhfyy 0.9606

x 0.04 0.03 0.02 0.01 0

y 0.9606 0.9703 0.9801 0.9900 1

xey 0.9608 0.9704 0.9802 0.9900 1

1)0(, yyxy 2.0,0 xx 0.1x

Page 62: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

62

Solution

Here ,

= , = , = , = , =

By Euler algorithm,

=

=

=

=

=

Exact solution is

Euler

Exact

As you can see from the table, the values of deviate from the exact values as increases. To

avoid this discrepancy we need to improve Euler’s method.

Improved Euler Method

Let the tangent at to the curve be P0A. In the interval by the previous

Euler’s method, we approximate the curve by the tangent P0A.

2.0h 1,0 ,),( 00 yxyxyxf

1x 2.02x 4.0

3x 6.04x 8.0

5x 0.1

0000001 , yxhyyxhfyy

1.2 1)0.2(01

)2.12.0)(2.0(2.1)( 1112 yxhyy

48.1

)48.14.0)(2.0(48.12223 yxhyy

856.1

)856.16.0)(2.0(856.1)( 3334 yxhyy

3472.2

)3472.28.0(2.03472.25 y 94664.2

12 xey x

x 1.0 0.8 0.6 0.4 0.2 0

y 2.94664 2.3472 1.856 1.48 1.2 1

y 3.4366 2.6511 2.0442 1.5836 1.2428 1

y x

),( 00 yx ),( 10 xx

Page 63: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

63

Let Q1C be the line at Q1 whose slope is

Now take the average of the slopes at P0 and Q1

i.e.

Draw a line P0D through P0 with this as the slope.

That is,

and this line intersects at

In general,

This is what is known as improved Euler’s method.

11

1

1000

1

1 where, QMyyxhfyy

1

11, yxf

1

1100 ,,2

1yxfyxf

),( 00 yx

0

1

11000 ,,2

1xxyxfyxfyy

1xx

1

110001 ,,2

1yxfyxfhyy

0001000 ,,,2

1yxhfyxfyxfhy

nnnnnnnn yxhfyhxfyxfhyy ,,,2

11

(x0,y0)

P1

P0

x0

M0

Q1

x1

M1

(x1y )

A C

B

D

x

y

Page 64: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

64

Notice that the difference between Euler’s method and the improved Euler’s method

is that in the improved one we take the average of the slopes at and instead of

the slope at in the former method.

Modified Euler’s Method

In the improved Euler method, we arranged the slopes, whereas in modified Euler method, we

will average the points.

Let P0 be the point on the solution curve

Let P0A be the tangent at to the curve. Now let this tangent meet the ordinate at

and coordinate of . Calculate the slope at N1. i.e.

.

Let this line meet at .

This is taken as the approximate value of at

),( 00 yx 1

11, yx

),( 00 yx

),( 00 yx

),( 00 yx

102

1Nathxx y 0001 ,

2

1yxhfyN

0000 ,

2

1,

2

1yxhfyhxf

1xx 1

111 , yxk

1

1y y1xx

00000

1

1 ,2

1,

2

1yxhfyhxfhyy

P0 (x0,y0)

k1(x1,y1)

M0

N1

B

A

y

0 x0 x0+ h x1=x0+h

x

Page 65: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

65

In general,

or

This is called modified Euler’s formula.

Note: The Euler predictor is and the corrector is in the

improved Euler method.

When you read some literature there is some confusion among the authors. Some take the

improved Euler method as the modified Euler method and the modified Euler method is not

mentioned at all.

Example 3 Solve numerically for by improved

Euler’s method.

Solution

and h = 0.2.

By improved Euler method,

nnnnnn yxhfyhxfhyy ,

2

1,

2

11

yxhfyhxfhxyhxy ,

2

1,

2

1

'

1 nnn hyyy '

1

'

12

nnnn yyh

yy

00,' yeyy x4.0 ,2.0 xx

4.0,2.0,0,000,' 2100 xxyxyeyy x

00010001 ,,,2

1yxhfyxfyxfhyy

hxxxeeyhyeyy

000

00012

2.00

2.0102.00101.0 e

24214.02.0 1 yy

Page 66: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

66

Here

Example 4. Compute at by Modified Euler’s method

, .

Solution

Take

By modified Euler method,

=

1111111

2 ,,,2

1yxhfyhxfyxfhyy

46354.124214.0, 2.0

1111 eeyyxf

x

53485.046354.12.024214.0, 111 yxhfy

02667.253485.0,, 4.0

1111 eyxhfyhxf

02667.246354.11.024214.02 y

59116.0)4.0( 2 yy

y 25.0x

xyy 2 1)0( y

1 ,0 ;2),( 00 yxxyyxf

25.0 ,25.0 1 xh

nnnnnn yxhfy

hxfhyy ,

2

1,

21

000001 ,

2

1,

2yxhfy

hxfhyy

0)1,0(),( 00 fyxf

)1,125.0()25.0(11 fy

)1)(125.0)(2)(25.0(1

Page 67: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

67

Using

The error is only .

Example 5. Solve the equation given using modified

and Euler’s method and tabulate the solutions at ,

and . Compare these results with the exact solutions.

Solution

Here

i) Modified Euler method

0625.1)25.0( y

xdxy

dyxyy 22'

1)0( y

1)0( cy

2xey

064494459.125.02

25.0 ey

58910.00199944

,1 ydx

dy 0)0( y

2.0,1.0 xx

3.0x

1.0,3.0,2.0,1.0,0,0 32100 hxxxyx

yy 1

11,,1, 000 yyxfyyxf

000001 ,

2

1,

2yxfhy

hxfhyy

05.0,2

1and05.01.0

2

1

2

10000 yxhfyhx

095.005..011.005.0,05.01.001 fy

Page 68: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

68

Now again = 1- 0.95 = 0.905

=

=

=

ii) Improved Euler method

=

111 1),( yyxf

111112 ,

2

1,

2

1yxfhyhxfhyy

14025.015.01.0095.0 f

14025.011.0095.0

0.180975

222223 ,

2

1,

2

1yxfhyhxfhyy

180975.0,2.0

2

1.0180975.0,

2

1.02.01.0180975.0 ff

)0.22192625 f(0.25, (0.1) 0.180975

50.25878237

nnnnnnnn yxfhyhxfyxfhyy ,,,2

11

00000001 ,,,2

1yxfhyhxfyxfhyy

11, 00 yyxf

1.0,1.011.00,1.0,, 0000 ffyxfhyhxf

0.9 0.1-1

095.09.012

1.001.01 yy

11111112 ,,,2

1yxfhyhxfyxfhyy

Page 69: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

69

= = 0.8145

Exact solution

At

Modified improved exact

905.0095.011, 111 yyxf

095.011.0905,0,2.0,, 1111 fyxhfyhxf

)1855.0,2.0(f

180975.0905.08145.02

1.0095.02 y

22222223 ,,,2

1yxfhyhxfyxfhyy

180975.011.0180975.0,3.0180975.012

1.0180975.0 f

)2628775.01819025.0(05.0180975.0

258782375.0

dxy

dyy

dx

dy

11

xceycxyn 11 1

101 ,0 0 ccex

xey 1

095162581.01.0 y

181269246.0)2.0( y

259181779.0)3.0( y

x

10.09516258 0.095 0.095 0.1

60.18126924 0.180975 0.180975 0.2

Page 70: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

70

Example 6. Find, correct to four decimal places, the value of

Given , by using improved Euler method.

Solution

Here, , , and

By the improved Euler method,

Example 7. Using improved Euler method find y at and at

given

Solution

By improved Euler theorem,

Here

90.25918177 50.25878237 50.25878237 0.3

)1.0(y

yxy 21)0( y

1.0h 00 x 1.01 x 10 y

nnnnnnnn yxhfyhxfyxfhyy ,,,2

11

00000001 ,,,2

1yxhfyhxfyxfhyy

0

2

000

2

0 1.0,1.02

1.01 yxyfyx

11.011.0105.012

0.9055

1.0x

2.0x 10,2

yy

xy

dx

dy

nnnnnnnn yxfhyhxfyxfhyy ,,,2

11

1.0,1,0 00 hyx

00000001 ,,,2

1yxhfyhxfyxfhyy

0

1.1

211.01

1

021

2

1.01

Page 71: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

71

=

Thus

Example 8. Using modified Euler method, find

given

Solution

Here, ,

)1.1,1.0(11.01,1.0,, 00 ffyxhfyhxf nn

...918181818.0

1.1

1.021.1

0.918182

095909091.1918182.012

1.011 y

11111112 ,,,2

yxhfyhxhfyxfh

yy

913412201.0

09590909.1

1.02095909091.1, 11

yxf

913412201.01.0095909091.1,2.0,, 1111 fyxhfyhxf

187250311.1,2.0f

850337365.0

187250311.1

2.02187250311.1

850337365.0913412201.02

1.0095909091.12 y

184096569.1

)2.0(),1.0( yy

10,22 yyxdx

dy

1.0,1.0,1,0 100 xhyx 22),( yxyxf

Page 72: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

72

By modified Euler method,

=

Exercise

1. Use Euler’s method to find

a) given

b) taking given

2. Compute taking given using improved Euler

method.

3. Find and given taking by improved

Euler method.

4. Use improved Euler method to find given .

5. Using improved Euler method find given .

6. Use improved Euler method to calculate ,taking and

000001 ,

2,

2

1yxf

hyhxhfyy

22 105.0105.01.01

)1.0(y 1.1105

111112 ,

2,

2

1yxf

hyhxhfyy

22 172660513.115.01.01105.1

250263268.1

)4.0(y 1)0(, yxyy

)5.1(y 5.0h 1.1)0(,1 yyy

)3.0(y 1.0h 1)0(,2

yy

xy

dx

dy

)8.0(),6.0( yy )1(y 0)0(, yyxy 2.0h

)1.0(y 1)0(,

y

xy

xyy

)4.0(),2.0( yy 1)0(, yyxdx

dy

)5.0(y 1.0h

2)0(,sin yxyy

Page 73: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

73

7. Use modified Euler method and obtain given .

8. Use improved and modified Euler method, to get if , if .

9. Solve given if to obtain .

10. Given find if .

11. Find by improved Euler method, given

if .

Runge-Kutta Method

i) Second order Runge-kutta method

Suppose

By Taylor series, we have

Differentiating (1) with respect to x,

Using the values of and derived from (1) and (3), in (2) we get

Let

)2.0(y 2.0,1)0(),log( hyyxy

)6.1(yx

yy

dx

dy 2 1)1( y

yxy 23 4)0( y 25.0h )5.0(),25.0( yy

2

1)1(,

2

5 32 yyxx

yy )2(y 125.0h

)2.0(y 2)0(,2 yxyy

1.0h

1..........given, 00 yxyyxfdx

dy

)2(..........0''!2

' 32

hxyh

xhyxyhxy

3........''' yxyx ffffyfdx

dy

y

f

x

fy

y y

32

2

1hOfffhhfxyhxy yx

4........2

1 32 hOfffhhfy yx

11 ,, kxyxfyxhfy

212 , kmkymhxhfy

Page 74: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

74

and let where and are constants to be determined to get the better

accuracy of

Now expand and in powers of h, by Taylor series for two variables, we have

= higher powers of .

Substituting , in we get

Equating (4) and (5), we have

21 bkaky ba, m

.y

2k y

12 , mkymhxfhk

...

!2,

2

1

1

fy

mkx

mh

fy

mkx

mhyxfh

...!2

2

1 fy

mkx

mh

mhffmhffh yx

...22 yx ffmhfhmfh h

1k 2k ,y

32 hOfffmhhfbahfy yx

5.....)( 21

32 bkakhOfffbmhhfba yx

2

1,1 mbba

bmandba

2

11

211 kbkby

Page 75: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

75

Where

Now

i.e.

From this general second order Runge-kutta formula, setting , , , we get the

second order Runge-kutta algorithm.

and where

ii) Third order Runge-kutta Method

For n = 3, a similar derivation to the one as the second-order method can be performed. Since

the derivation is tedious we state simply the formula.

, where

iii) Fourth Order Runge-kutta method

),(1 yxhfk

b

fhy

b

hxfhk

2,

22

xyhxyy

b

hfy

b

hxbhfhfbxyhxy

2,

21

3

1 ,2

,2

,1 hOyxfb

hy

b

hxfhbyxfhbyy nnnnnnnn

0a 1b2

1m

12

1

2

1,

2

1

),(

kyhxhfk

yxhfk

2ky xh

3211 46

1kkkyy nn

),(1 yxfhk

hkyhxhfk 12

2

1,

2

1

)2,( 23 kkyhxhfk

Page 76: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

76

The most popular and commonly used form is the classical fourth-order Runge-kutta method.

, where

Note 1. The second order Runge-kutta method,

this is exactly the Modified Euler method.

Thus, the second order Runge-kutta method is simply the modified Euler method.

2. If , a function of alone, then the fourth order Runge-kutta method

reduces to

43211 226

1kkkkyy nn

yxhfk ,1

hkyhxhfk 12

2

1,

2

1

hky

hxhfk 23

2

1,

2

hkyhxhfk 34 ,

10020

2

1,

2ky

hxhfky

0000 ,

2

1,

2yxhfy

hxhf

000001 ,

2

1,

2yxhfy

hxhfyy

)(),( xfyxf x

01 xhfk

hxf

hxfxfhy 000

24

6

1

Page 77: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

77

= the area of between and with two equal intervals of

length by Simpson’s one-third rule. i.e. reduces to the area by Simpson’s one-third rule.

Example 1. Apply the fourth order Runge-kutta method to find

given that

Solution

Since h is not mentioned, we can take

By fourth-order Runge-kutta method, for the first interval

=

hxf

hxfxf

h

0002

43

2

)(xfy 0xx hxx 0

2

hy

)2.0(y 1)0(, yyxy

1.0h

2.0,1.0,1,0,, 2100 xxyxyxyxf

1.0101.0, 001 yxhfk

11.005.0105.01.02

1,

2

11002

kyhxhfk

1105.0055.0105.01.02

1,

2

12003

hkyhxhfk

12105.01105.011.01.0, 3004 kyhxhfk

432101 226

11.0 kkkkyyy

12105.01105.0211.021.06

11

110341667.1

Page 78: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

78

Now starting from we get . Again apply Runge-kutta algorithm replacing

by .

=

Remember that the exact solution is

The difference between the exact solution and the fourth order Runge-kutta method is

.

As compared to other methods, this method is the best one.

Example 2. Find the values of at using Runge-kutta

method of i) second order ii) third order and

iii) fourth order for the given that and .

Solution

i) Second order

),( 11 yx ),( 22 yx

),( 00 yx ),( 11 yx

121034166.0110341667.11.01.0, 111 yxhfk

176384605.115.01.02

,2

2112

ky

hxhfk

13263846.0

144298012.013263846.0132085875.02121034166.06

1110341667.12.0 y

21.24280514

12 xey x

61.24280551 )2.0( y

4320.00000037

y 2.0,1.0x

yy 1)0( y

1.0,2.0,1.0,1,0,),( 2100 hxxyxyyxf

1.011.0, 001 yxhfk

Page 79: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

79

Again let

=

ii) Third order

=

Now take and repeat the process

095.005.011.02

1,

2

11002

kyhxhfk

201 kyy

905.0095.01

),( 11 yx 0.905) (0.1,

1k 0.0905- (-0.905) (0.1)

085975.00905.02

1905.01.02

k

)2.0(y 0.819025 )(-0.0859750.905

1.0),( 001 yxhfk

2k 0.095-

)2,( 12003 kkyhxhfk

0.091- (-0.1)) 2(-0.095)(-(1 (0.1)

321 46

111.0 kkky

091.0()095.0(41.06

11

30.90483333

),( 11 yx 833333)(0.1,0.904

0904833333.0904833333.0,1.0, 111 yxhfk

Page 80: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

80

iii) Fourth order

Again taking and repeating the process, we get

1112

2

1,

2)1.0( ky

hxk

0904833333.0

2

1904833333.01.0

60.08595916-

0904833333.0085959166.02904833333.01.03 k

30.08233983-

32112 46

1kkkyy

082339833.0082339833.040904833333.06

1904833333.0

90.82113624

1.01 k

095.02 k

09525.00475.011.02

1,

2

12003

kyhxhfk

090475.009525.011.0, 3004 kyhxhfk

43211 226

11 kkkky

9048375 0.

),( 11 yx 8375)(0.1,0.904

1k 0.09048375- 5)(-0.904837 (0.1)

Page 81: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

81

2nd

order 3rd

order 4th

order exact

As we can see from the table fourth order values are closer to the exact values.

Example 3. Compute given by taking

using Runge-kutta method of fourth order.

Solution

1002

2

1,

2

11.0 kyhxfk

20.08595956- 5))0.04524187-75(-(0.90483 (0.1)

2003

2

1,

2

1)1.0( kyhxfk

086185771.0085959562.02

19048375.01.0

3114 , kyhxhfk

720.08186551- 10.08618577 048375(0.1)(-0.9

432112 226

1kkkkyy

818730902.0081865172.0

086185771.0085959562.0209048375.06

19048375.0

x xey

80.90483741 0.9048375 30.90483333 0.905 0.1

30.81873075 20.81873090 90.82113624 0.819025 0.2

)3.0(y 10,2 yxyydx

dy1.0h

)(),( 22 xyyyxfxyyy

Page 82: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

82

Now = (0.1) (-1) = -0.1

Now again taking in place of , we get

3.0,2.0,1.0,1.0,1,0 32100 xxxhyx

1k

1

2

22

1.0

2

1.01

2

)1.0(11.0k

295.005.095.01.0

0.0995125 -

2003

2

1,

2ky

hxhfk

95024375.0,05.01.0 f

295024375.005.095024375.01.0

0.09953919-

3004 , kyhxhfk

900460809.0,1.01.0 f

098154377.0

098154377.009953919.020995125.021.06

111 y

900623707.01.0 y

),( 11 yx ),( 00 yx

900623707.0,1.01.0, 111 fyxhfk

098173601.0

Page 83: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

83

Again, using = we find

=

=

2,

2

1112

ky

hxhfk

851536906.0,15.01.0 f

096030417.0

2,

2

2113

ky

hxhfk

2852608498.015.0852608498.01.0

096164968.0

3114 , kyhxhfk

804458738.0,2.01.0 f

10.09338895-

093388951.0096164968.0

2096030417.02098173601.06

1900623707.02

y

60.80463148

),( 22 yx 6)0.80463148 (0.2, )3.0(3 yy

221 , yxhfk

2)804631486.0)(2.0(804631486.01.0

50.09341178-

757925593.0,25.0)1.0(2

,2

2222 f

ky

hxhfk

90.09015383-

Page 84: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

84

=

Example 4. Using Runge-kutta method of fourth order, find

if

Solution

Here and

759554566.0,25.01.02

, 2223 f

kyhxhfk

35-0.0903785

714252951.0,25.01.0, 3224 fkyhxhfk

70.08417922-

084179227.0090378535.0

2090153839.02093411785.06

1804631486.03

y

714855526.0

)8.0(y

7379.1)6.0(,2 yxyy

8.0,7.0,1.0,7379.1,6.0 2100 xxhyx 2),( xyyxf

13779.06.07379.11.0, 2

001 yxhfk

2,

2

1002

ky

hxhfk

1384295.0806795.1,65.01.0

2,

2

2003

ky

hxhfk

38461475.065.080711475.11.0 2

3004 , kyhxhfk

Page 85: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

85

=

Now using = we continue to find

Example 5. Using Runge-kutta method of fourth order, solve

given at

Solution

and

138636147.0138461475.021384295.0213779.06

17379.17.0 y

61.87626801

),( 11 yx 6)1.87626801 (0.7, )8.0(y

138626801.07.0876268016.11.0, 2

111 yxhfk

2,

2

1112

ky

hxhfk

2,

2

2113

ky

hxhfk

138292208.0945422087.1,75.01.0 f

3114 , kyhxhfk

137456022.0014560224.2,8.01.0 f

13746022.0138292208.0

2138308141.02138626801.06

1876268016.18.0

y

62.01448193

22

22

xy

xy

dx

dy

1)0( y 4.0,2.0x

4.0,2.0,2.0,1,0 2100 xxhyx 22

22

,xy

xyyxf

Page 86: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

86

y

=

To find we use =

=

2.001

012.0, 201

yxhfk

2,

2

1002

ky

hxhfk

196721311.01.01.1

1.01.12.0

22

22

2,

2

2003

ky

hxhfk

196711597.01.0098360656.1

1.0098360656.12.0

22

22

3004 , kyhxhfk

18913131.02.0196711598.1

2.0196711598.12.0

22

22

18913131.0196711597.02196721311.022.06

112.0

11.19599952

)4.0(y ),( 11 yx 999521)(0.2,1.195

22

22

1112.0195999521.1

2.0195999521.12.0,2.0 yxfk

70.18911871

29055888.1,3.02.02

,2

2.0 1112 f

ky

hxfk

179493515.0

Page 87: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

87

=

Runge-kutta method for simultaneous first order differential equations

Aim- To solve numerically the simultaneous equations

given the initial conditions

Now starting from the increments in and respectively are given

by formulae

and

285746279.1,3.02.02

,2

2113 f

ky

hxhfk

179347655.0

375347176.1,4.02.0, 3114 fkyhxhfk

168804528.0

168804528.0179347655.0

2179493515.02189118717.06

1195999521.14.0

y

91.37526711

zyxfdx

dzandzyxf

dx

dy,,,, 21

0000 )(,)( zxzyxy

),,( 000 zyx zandy y z

00011 ,, zyxhfk 00021 ,, zyxhfm

2,

2,

2

10

10012

mz

ky

hxhfk

2,

2,

2

10

10022

mz

ky

hxhfm

2,

2,

2

20

20013

mz

ky

hxhfk

2,

2,

2

20

20023

mz

ky

hxhfm

3030014 ,, mzkyhxhfk 3030024 ,, mzkyhxhfm

4321 226

1kkkky 4321 22

6

1mmmmz

Page 88: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

88

By repeating this algorithm once again we can find starting from .

Example 6. Find , from the system of equations,

given using Runge-kutta

method of fourth order.

Solution

Here

So

zzzandyyy 0101

),,( 222 zyx ),,( 111 zyx

)1.0(y )1.0(z

2, yxdx

dzzx

dx

dy 1)0(,2)0( zy

2

21000 ),,(,),,(,1.0,1,2,0 yxzyxfzxzyxfhzyx

00011 ,, zyxhfk 00021 ,, zyxhfm

0.4- )2-(0 (0.1) 0.1 1)(0 (0.1) 2

2,

2,

2

10

10012

mz

ky

hxhfk

2,

2,

2

10

10022

mz

ky

hxhfm

4.2025)-(0.05 (0.1) (-0.2))1(0.1)(0.05

0.41525- 0.085

2,

2,

2

20

20013

mz

ky

hxhfk

2,

2,

2

20

20023

mz

ky

hxhfm

)(2.0425)-(0.05 (0.1) 0.792375)(0.05 (0.1) 2

50.41218062- 0.0842375

3030014 ,, mzkyhxhfk 3030024 ,, mzkyhxhfm

))(2.0842375 -(0.1 (0.1) 5)0.58781937 (0.1 (0.1) 2

50.42440459- 70.06878193

)068781937.0)0842375.0(2085.0(21.06

121 y

Page 89: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

89

=

=

Runge-kutta method for second order differential equation

Aim – To solve given

Now, let and so

and are the two simultaneous equations with

and itself.

Once again by applying Runge-kutta method for solving simultaneous first order differential

equations we can get the solution of the given problem.

Example 7. Given find by using

Runge-kutta method of fourth order.

Solution

Let

given

32.08454282

424404595.0412180625.0241525.024.06

111 z

50.58678902

',, yyxfy 0000 )(,)( yxyyxy

zy ' zy

',,' yyxfzy zy zzyxf ),,(1

),,(),,(2 zyxfzyxf

,0)0(,1)0(,0 yyyyxy )1.0(y

'''0''' xyyyyxyy

xzyzzy ''

zyxfzdx

dy,,1

zyxfxzydx

dz,,2

0,1.0,,0,1 0

'

000 xhyzy

001.0,, 00011 zyxhfk 1.0,, 0001 zyxhfm

Page 90: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

90

=

Exercise

In the exercise below, unless specified use fourth order Runge-Kutta method.

1. Find given taking .

2. Obtain the value of at if satisfies

taking .

3. Solve for , taking .

2,

2,

2

10

10012

mz

ky

hxhfk

2,

2,

2

10

10022

mz

ky

hxhfm

0.05) (0.05,1,- (0.1) = 0.005- = (0.05) (0.1) =

049875.0,

2

005.01,05.013 hfk 05)](0.05)(-0.-[-1 (0.1)

0.09975- )(-0.049875 (0.1)

0.0049875 - 049875.0,9975.0,05.023 hfm

3030114 ,, mzkyxhfk 975)049875)0.9((0.05)(0. (0.1)

50.09950062- 625)(-0.099500 (0.1)

250.00995006- 303024 ,, mzkyxhfm i

)099500625.0,09950125.0,1.0)(1.0(

)9950125.0)09950125.0)(1.0)((1.0(

30.09850624-

)0099500625.0()0049875.0(2)005.0(206

111 y

90.99501248

)2.0(y 2)0(, yxyy 1.0h

y 2.0x y 1)0(,2 yxyxdx

dy

1.0h

xydx

dy 4.1x 2.0,2)1( hy

Page 91: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

91

4. Solve given , to obtain .

5. Solve the initial-value problem with on the interval .

6. Evaluate given .

7. Solve for taking .

8. Find given taking by

i) second order ii) third order

iii) fourth order Runge-Kutta methods.

9. Solve as given taking .

10. Solve the system: for taking

.

11. Solve , given for to taking

12. Evaluate given .

13. Using Runge-Kutta method determine

given .

14. Solve using Runge-Kutta method for given

taking .

15. Find given by Runge-Kutta method.

16. Find given .

xy

xy

dx

dy

1)0( y )2.0(y

1)0(,2 2 utudt

du2.0h )6.0,0(

)3.0(),2.0(),1.0( yyy 1)0(,)1(2

1 2 yyxy

1)1(,1

2 y

xx

y

dx

dy)1.1(y 05.0h

)2.0(),1.0( yy 1)0(,2 yyxy 1.0h

1 xyy 6.0,4.0,2.0 xxx 2)0( y 2.0h

xydx

dzxz

dx

dy ,1 9.0,6.0,3.0 xxx

1,0,0 zyx

yxdx

dzzx

dx

dy , 1)0(,0)0( zy 0.0x 2.0 .1.0h

)1.1(),1.1( zy 1)1(,5.0)1(,, zyz

xy

dx

dzxyz

dx

dy

)1.0(),1.0( yx

1)0(,,1)0(, yxtydt

dyxtxy

dt

dx

0)( 22 yyxy 2.0x

0)0(,1)0( yy 2.0h

)1.0(y 5)0(,10)0(,2 yyyy

)2.0(,1.0( yy 0)0(,1)0(,122 yyxyyxy

Page 92: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

92

17. Obtain the value of given .

18. Compute the value of given .

Predictor-Corrector Method

The methods so far discussed are called single step methods because they use only the

information from the last step computed. But now we try to discuss multi-step methods.

Consider

We have used Euler’s formula to solve differential equation of the form

, and we have improved the Euler method by

In (2), to get the value of we require on the right hand side.

To overcome this difficulty, we calculate using Euler’s formula (1) and then we use it on the

right hand side of (2), to get the left hand side of (2). This can be used further to get refined

on the left hand side. Here, we predict the value of from the rough formula (1) and use

in (2) to correct the value. Every time, we improve using (2). Hence equation (1) Euler’s

formula is a predictor and (2) is a corrector.

A predictor formula is used to predict the value of at and a corrector formula is used

to correct the error and to improve that value of .

Milne’s Predictor- Corrector Formulae

Suppose our aim is to solve numerically.

)1.0(x 0)0(,3)0(,42

2

xxxdt

tdx

dt

xd

)2.0(y 0)0(,1)0(, yyyy

00,, yxyyxfdx

dy

1... ,2,1,0,,'1 iyxhfyy iiii

2... ,,2

1111 iiiiii yxfyxfhyy

1iy 1iy

1iy

1iy

1iy 1iy

y1iy

1iy

00,, yxyyxfdx

dy

Page 93: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

93

, where is a suitable

accepted spacing, which is very small.

By Newton’s forward interpolation formula, we have

, where

Changing to

Integrating both sides from to ,

Since

Now

nhxyyhxyyxyxyhxyy n 00211001 ...,,2, h

...

!3

21

!2

10

3

0

2

00

yuuu

yuu

yuyy

uhxxh

xxu

0

0

y y

)2(...

!3

21

!2

1' '

0

3'

0

2'

0

'

0

yuuu

yuu

yuyy

0x4x

hx

x

hx

x

x

xydxy

uuyuydxy

44

'

0

2'

0

'

00

0

0

0

4

0

|...!2

1'

duy

uuyuyh

4

0

'

0

2'

0

'

0 ...2

1

hdudxuhxx 0

...

46

1

232

1

2

234

'

0

323

'

0

22

'

0

'

004 uuu

yuu

yu

yuyhyy

...166464

6

18

3

64

2

184 '

0

3'

0

2'

0

'

0 yyyyh

...

3

8

3

2084 '

0

3'

0

2'

0

'

0 yyyyh

...

45

141

3

81

3

20)1(84 '

0

4'

0

3'

0

2'

0

'

0 yyEyEyEyh

...

45

1433

3

82

3

20)(84 '

0

4'

0

'

1

'

2

'

3

'

0

'

1

'

0

'

0

'

1

'

0 yyyyyyyyyyyh

Page 94: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

94

Taking into account only up to the third order equation, (3) gives

…………… (4)

The error happened in (4) is and this can be proved to be , where

.

Since for small values of .

The error is and hence (3) becomes

……..(5)

In general,

, where ……(6)

This equation is called Milne’s predictor formula.

To get Milne’s corrector formula, integrate equation (2) between the limits to .

..45

14

3

88

3

208

3

408

3

8

3

2084 '

0

4'

32

'

1

'

0

yhyyyyh

...45

14

3

8

3

4

3

8 '

0

4'

3

'

2

'

1

yhyyyh

3.......45

1422

3

4 '

0

4'

3

'

2

'

1 yh

yyyh

3210

'

3

'

2

'

104

223

4

223

4

fffh

y

yyyh

yy

...45

14 '

0

4 yh vy

h

45

14

40 , xx

hDeE hD 11 h

vy

h

45

14 5

vyh

yyyh

yy45

1422

3

4 '

3

'

2

'

104

1

5''

1

'

23145

1422

3

4v

nnnnn yh

yyyh

yy 131 , nn xx

0x hx 20

dxy

uuyuydxy

hx

x

hx

x

2 2'

0

2'

0

'

0

0

0

0

0

...2

1'

Page 95: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

95

…….…(7)

Again here taking into account only up to third order, we get

Here the error is and this can be proved to be

where and thus (7) becomes

In general,

where .

This equation is called Milne’s corrector formula.

Example 1. Find if is the solution of given

and

duy

uuyuyhyy

2

0

'

0

2'

0

'

002 ...2

1

2

0

2

0

'

0

223

'

0

2'

0 ...232

1

2

y

uuy

uuyh

...

24

1

15

412

3

8

2

1122 '

0

4'

0

2'

0

'

0 yyEyEyh

...

90

12

3

122 '

0

4'

0

'

1

'

2

'

0

'

1

'

0 yyyyyyyh

...90

43

'

0

4'

2

'

1

'

0 yh

yyyh

)8...(43

'

2

'

1

'

002 yyyh

yy

...90

'

0

4 yh vy

h

90

5

;20 xx

vyh

yyyh

yy90

43

5'

2

'

1

'

002

2

5

1

''

11190

'43

v

nnnnn yh

yyyh

yy 121 nn xx

)2(y )(xy yxdx

dy

2

1

595.3)1(,636.2)5.0(,0)0( yyy 968.4)5.1( y

Page 96: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

96

Solution

Here

By Milne’s predictor formula,

Now,

=

Using Milne’s corrector formula, we get,

=

5.0,2,5.1,1,5.0,0 43210 hxxxxx

968.4,595.3,636.2,2 3210 yyyy

'2

1, yyxyxf

''

1

'

231 223

4nnnnn yyy

hyy

3

'

2

'

104 223

4yyy

hyy

568.1636.25.02

1

2

111

'

1 yxy

2975.2595.312

1

2

122

'

2 yxy

234.3968.45.12

1

2

133

'

3 yxy

234.322975.2568.12

3

5.0424 y

6.871

'

4

'

3

'

224 43

yyyh

yy

4355.4871.622

1

2

144

'

4 yxy

4355.4234.342975.23

5.0595.34 y

76.87316666

Page 97: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

97

Example 2. Using Milne’s method find given

given and .

Solution

By Milne’s predictor formula,

=

Using the corrector formula, we get

)4.4(y 025 2 yyx

0097.1)2.4(,0049.1)1.4(,1)4( yyy 0143.1)3.4( y

1.0,4.4,3.4,2.4,1.4,4,5

2' 43210

2

hxxxxxx

yy

0143.1,0097.1,0049.1,1 3210 yyyy

048301267.0

1.45

0049.12

5

2 2

1

2

1'

1

x

yy

046690757.0

2.45

0097.12

5

2 2

2

2

1'

2

x

yy

045171884.0

3.45

0143.12

5

2 2

2

2

3'

3

x

yy

'

3

'

2

'

104 223

4yyy

hyy

00451718842046690757.0048301267.02

3

1.041

91.01870073

043738581.0

4.45

018700739.12

5

2 2

4

2

4'

4

x

yy

'

4

'

3

'

224 43

yyyh

yy

Page 98: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

98

=

Example 3. Determine the value of using Milne’s method given

use Taylor series to get the values of and

Solution

Here

Now

=

Once again

043738581.0045171884.04046690757.03

1.00097.1

91.01873722

)4.0(y ;10,' 2 yyxyy

),2.0(),1.0( yy )3.0(y

5.0,1,4.0,3.0,2.0,1.0,0 043210 hyxxxxx

1' 2

000

'

0

2 yyxyyxyy

32'2''' '

000

'

00

''

0 yyyyxyyyyxyy

10)'(2''2'2''''' '''

0

2 yyyyyxyy

...!32

'''

0

3''

0

2'

001 yh

yh

hyyy

116666667.1...106

001.03

2

01.011.01

358611111.12

111

'

1 yyxy

28675926.42 1

111

'

11

''

1 yyyyxy

4113088.162222'

1

'1

111

''

11

'''

1 yyyyyxy

...4113088.166

001.028675926.4

2

01.0358611111.11.011666667.12 y

31.27669679

885294059.12

222

'

2 yyxy

467653362.62 '

222

'

22

''

2 yyyyxy

Page 99: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

99

=

By Milne’s predictor formula

Since

=

Now using Milne’s corrector formula,

Example 4. Given and ,

evaluate by Milne’s predictor-corrector method.

68725078.282222'

2

''

22

'

2

''

22

'''

2 yyyyyxy

68725078.286

001.0467653362.6

2

01.0885294059.11.0276696793.13 y

41.50234567

'

3

'

2

'

104 223

4yyy

hyy

358611111.1'

1 y

885294059.1'

2 y

707746226.22

333

'

3 yyxy

70774626.22885294059.1358611111.12

3

1.0414 y

41.83298942

093046.42

444

1

4 yyxy

'

4

'

3

'

224 43

yyyh

yy

093046.470774626.24885294059.13

1.0276696793.1

83700763.1

2212

1yx

dx

dy 21.1)3.0(,12.1)2.0(,06.11.0,10 yyyy

)4.0(y

Page 100: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

100

Solution

By Milne’s predictor formula

=

By Milne’s corrector formula

=

Once again if we use this value of , we get

4.0,3.0,2.0,1.0,0 43210 xxxxx

1.0,21.1,12.1,06.1,1 3210 hyyyy

2212

1' yxy

2

1101

2

11

2

1 2

0

2

0

'

0 yxy

567418.006.11.012

11

2

1 222

1

22

1

'

1 yxy

7979345.0)21.1)(3.01(2

1)1(

2

1 222

3

2

33

yxy

'

3

'

2

'

104 223

4yyy

hyy

7979345.02652288.0367418.02

3

1.041

71.27712226

'

4

'

3

'

224 43

yyyh

yy 946003944.0'

4 y

946003944.0)7979345.0(4652288.03

1.012.1

51.27966766

4y

949778612.0279667665.14.012

1 22'

4 y

Page 101: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

101

So

=

If we repeat this procedure once again using this ,

By Milne’s corrector formula

=

Continuing this process again and again, after some steps we get

Example 5. Given , and , and

i) by Euler method; using that value obtained

ii) by Modified Euler method

iii) Obtain by Improved Euler method and find

iv) by Milne’s method.

Solution

By Euler method

By Modified Euler

949778612.07979345.04652288.03

1.012.14 y

71.27979348

4y

949965394.0)279793487.1(4.012

1 22'

4 y

949965394.07979345.04652288.03

1.012.14 y

31.27979971

71.279800034 y

yy 1 0)0( y

)1.0(y

)2.0(y

)3.0(y

)4.0(y

1.0011.00, 0001 yxhfyy

111112 ,

2

1,

2yxhfy

hxhfyy

1855.01.011.02

11.011.01.0

Page 102: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

102

By improved Euler method

=

Now using Milne’s predictor formula

=

By Milne’s corrector formula

=

Exercise

1. Using Milne’s method, find given

22232223 ,,,2

1yxhfyxfyxfhyy

1855.011.01855.011855.012

1.01855.0

0.2628775

'

3

'

2

'

104 223

4yyy

hyy

3210 121123

4yyy

hy

2628775.01(21855.011.012

3

1.040

0.327966

672034.0327966.011 4

'

4 yy

'

4

'

3

'

224 43

yyyh

yy

'

4322 1413

yyyh

y

672034.0)2628775.0(4)1855.01((3

1.01855.0

30.33333413

)2.0(y

0323.2)15.0(,0211.2)1.0(,0103.2)05.0(,2)0(,1.02.0 yyyyyxdx

dy

Page 103: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

103

2. Find given .

3. Using Runge-Kutta method of fourth order, find at given

. Continue your work to get by Milne’s method.

4. Solve by Taylor series method at and

hence find and by Milne’s method.

5. If , find and

by Milne’s method.

6. Estimate and using Milne’s method correct to three decimal places, given

.

7. Solve to obtain by Milne’s method. Obtain the data you

require by any method you like.

8. Using both predictor-corrector methods, estimate if satisfies , and

.

9. Given , find

by Milne’s predictor-corrector method.

10. Compute by Milne’s method given with . Obtain the

required data by Taylor series method.

11. Given , find by Euler method; by Taylor series

method; by Runge-Kutta method and by Milne’s method.

)8.0(y 7379.1)6.0(,46820.1)4.0(,12186.1)2.0(,1)0(,2 yyyyxyy

y 3.0,2.0,1.0 xxx

1)0(,2 yyxyy )4.0(y

1)0(,)1(2

1 2 yyxy 6.0,4.0,2.0 xxx

)8.0(y )1(y

090.2)3.0(,040.2)2.0(,010.2)1.0(,2)0(,2 yyyyyedx

dy x )4.0(y

)5.0(y

)8.0(y )1(y

6841.0)6.0(,4228.0)4.0(,2027.0)2.0(,0)0(,1 2 yyyyyy

1)0(,2 yyxy )4.0(y

)4.1(y y2

1

xx

y

dx

dy

972.0)3.1(,986.0)2.1(,996.0)1.1(,1)1( yyyy

2493.2)6.0(,1755.2)4.0(,0933.2)2.0(,2)0(,1

yyyyyx

y

)8.0(y

)6.0(y 1)0(, yyxy 2.0h

0)0(,23 yyey x)1.0(y )2.0(y

)3.0(y )4.0(y

Page 104: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

104

12. Find by Taylor series method; by modified Euler method; by

Runge-Kutta method and by Milne’s method, given .

13. Given obtain by Picard’s method; by modified Euler

method; by Runge-Kutta method; by Milne’s predictor-corrector method.

14. Given obtain power series by Picard’s method; using Milne’s

method, estimate and show that .

Estimate given using .

Boundary-Value Problem (BVP)

BVPs can be solved numerically by using either the Shooting Method or the Finite-

Difference Method (FDM). Here we consider the numerical solution of PVP using FDM. The

former method is left for the students as a reading assignment.

Some simple examples of two-point linear BVPs are:

'' 'y x f x y x g x y x r x (1)

with boundary conditions

0y x a and ny x b (2)

'' 21 1

2

2i i ii

y y yy O h

h

ivy x p x y x q x

(3)

with boundary conditions

'

0 0y x y x A and '

n ny x y x B . (4)

Problems of the type in Eq. (3) and Eq. (4), which involve the fourth-order differential

equation, are much involved and will not be discussed here. There exist many methods for

)2.0(y )4.0(y )6.0(y

)8.0(y 0)0(,1 2 yyy

1)0(,1 yxyy )1.0(y )2.0(y

)3.0(y )4.0(y

,10)0(,2 2 yxyy

2.0,6505.1)1( hy

)4.0(),5.0( yy 1)0(,2 yyxy 1.0h

Page 105: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

105

solving second-order BVPs of the type in Eq. (1) and Eq. (2). Of these, the Finite-Difference

Method is popular one and will be discussed.

Finite-Difference Method (FDM)

The FDM for the solution for a two-point BVP consists in replacing the derivatives occurring

in the differential equation (and the boundary conditions as well) by means of their finite-

difference approximations and then solving the resulting linear system of equations by a

standard procedure.

To obtain the approximate finite-difference approximations to the derivatives, we proceed as

follows:

Expanding y x h in Taylor’s series, we have

2 3' '' '''

2 6...h hy x h y x hy x y x y x (5)

from which we obtain

' '' ...2

y x h y x hy x y x

h

Thus we have

'y x h y x

y x O hh

(6)

Which is forward difference approximation for 'y x .

Similarly, expansion of y x h in Taylor’s series gives

2 3' '' '''

2 6...h hy x h y x hy x y x y x (7)

from which we obtain

'y x y x h

y x O hh

(8)

Page 106: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

106

Which is the backward difference approximation for 'y x .

A central difference approximation for 'y x can be obtained by subtracting Eq. (7) from

Eq. (5). We thus have

' 2

2

y x h y x hy x O h

h

(9)

It is clear that Eq. (9) is better approximation to 'y x than either Eq. (6) or Eq. (8). Again,

adding Eq. (5) and Eq. (7) we get an approximation for ''y x as

'' 2

2

2y x h y x y x hy x O h

h

(10)

In a similar manner, it is possible to derive finite-difference approximations to higher

derivatives.

To solve the BVP defined by Eq. (1) and Eq. (2), we divide the range 0 , nx x into n equal

subintervals of width h so that

0 , 0,1,2,..., .ix x ih i n

The corresponding values of y at these points are denoted by

0 , 0,1,2,..., .i iy x y y x ih i n

From Eq. (9) and Eq. (10), values of 'y x & ''y x at the point ix x can now be written as

' 21

2

i ii

y yy O h

h

and '' 21 1

2

2i i ii

y y yy O h

h

Page 107: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

107

In many applied problems; however, derivative boundary conditions may be prescribed, and

this requires a modification of the procedures described above. The following examples

illustrate the application of the FDM.

Example 1: A boundary-value problem is defined by

1 0, 0 1iiy y x ,

where

0 1 0, 0.5y y and h

Use the FDM to determine the value of y(0.5). Its exact solution is given by

1 cos1cos sin 1

sin1y x x x

,

from which, we obtain

0.5 0.139493927y .

Here 1nh . The difference equation is approximated as

1 1

2

21 0i i i

i

y y yy

h

, and this gives after simplification

2 2

1 12 , 1,2,..., 1i i iy h y y h i n ,

which together with the boundary conditions 0 0ny y , comprises a system of 1n

equations for 1n unknowns 0 1, ,...,

ny y y .

Choosing 1

2h (i.e. 2n ), the above system becomes

Page 108: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

108

0 1 2

1 12

4 4y y y

.

With 0 2 0y y , this gives

1 0.5 0.142857142y y .

Comparing with exact solution given above shows that the error in the computed solution is

0.00336 .

On the other hand, if we choose 1

4h (i.e. n=4), we obtain the three equations:

0 1 2

1 2 3

2 3 4

31 1

16 16

31 1

16 16

31 1

16 16

y y y

y y y

y y y

Where 0 4 0y y . Solving the system we obtain 2 0.5 0.140311804y y , the error in

which 0.00082 . Since the ration of the error is about 4 , it follows that the order of

convergence is 2h .

These results show that the accuracy obtained by the finite difference method depends upon the

width of the subinterval chosen and also on the order of approximations. As h is reduced, the

accuracy increases but the number equations to be solved also increases.

Example 2: Solve the boundary-value problem

2

20, 0 2

d yy x

dx ,

with 0 0 & 2 3,62686y y .

Page 109: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

109

The exact solution of this problem is sinhy x . The finite-difference approximation is given by

1 12

12i i i iy y y y i

h

We subdivide the subinterval 0,2 the four equal parts so that 0.5h . Let the values of y at the

five points be 0 1 2 3 4, , , ,&y y y y y . We are given that 0 0y , and 4 3.62686y .

Writing the difference equations at the three interval points (which are the unknowns), we obtain

0 1 2 1

1 2 3 2

2 3 3 3

4 2

4 2

4 2

y y y y

y y y y ii

y y y y

, respectively. Substituting for 0 4&y y and rearranging, we get the system

1 2

1 2 3

2 3

9 4 0

4 9 4 0

4 9 14.50744

y y

y y y iii

y y

The solution of (iii) is given in the table below.

x Computed solution of

y

Exact value

sinhy x

Error

0.5 0.52635 0.52110 0.00525

1.0 1.18428 1.17520 0.00908

1.5 2.13829 2.12928 0.00901

Exercise

1. Solve the boundary value defined by

'' 0, 0 0, 1 1y y y y ,

Page 110: A short note on Numerical Analysis II meant for self-taught …ndl.ethernet.edu.et/bitstream/123456789/78640/3/Numerical... · 2020. 5. 11. · A short note on Numerical Analysis

110

by finite-difference method. Compare the computed solution at 0.5y with the exact

value. Take 0.25h .

2. Project work. Shooting Method. This is a popular method for the solution of two-point

boundary-value problems. If the problem is defined by

''

0 1, 0y x f x y x and y x A ,

Then it is first transformed into the initial value problem

' ',y x z z x f x with 0 0y x and 0 0z x m , where 0m is a guess

for the value '

0y x . Let the solution corresponding to 1x x be 0Y . If 1Y is the value

obtained by another guess 1m for '

0y x , then 0 1Y and Y and are related linearly. Thus,

linear interpolation can be carried out between the values 0 0,x y and 1 1,m y .

Obviously, the process can be repeated till we obtain the value for 1y x is close to A .

Apply the Shooting method to solve the BVP

'' , 0 0, 1 1y x y x y y