58
1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

Embed Size (px)

Citation preview

Page 1: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

1

Open Methods

Lecture NotesDr. Rakhmad Arief SiregarUniversiti Malaysia Perlis

Applied Numerical Method for Engineers

Chapter 6

Page 2: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

2

Page 3: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

3

Review of previous method

In the previous chapter, the root is located within an interval

Lower bound Upper bound

Repeated application if these methods always result in closer estimates of true value of the root

These methods are said to be CONVERGENT because they move closer to the truth as computation progresses

Page 4: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

4

Open Methods

In contrast, the open methods are based on formulas that require only a single or two of x.

Do not bracket the root. It is called as diverge or move

away from the true root as the computation progresses. Fig (b)

However, when it is converge (Fig. c), they do not so much more quickly than the bracketing method

Page 5: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

5

Simple Fixed-Point Iteration

This method also called as, simple fixed-point iteration, or one point iteration or successive substitution method

Open methods employ formula to predict the root. The formula can be developed by rearranging the function f(x)

= 0 so that x is on the left-hand side of the equation:

Example: can be rearranged to:

Example: can be rearranged to:

)(xgx

0322 xx2

32 x

x

0sin x xxx sin

Page 6: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

6

Simple Fixed-Point Iteration

The utility of is to provides a formula to predict a new value of x as function of an old value of x

Thus given an initial guess at the root xi, it can be used to compute a new estimate xi+1 as expressed by the iterative formula:

Thus the approximation error (as in the previous chapters) can be calculated as

)(xgx

%1001

1

i

iia x

xx

)(1 ii xgx

Page 7: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

7

Ex. 6.1 Simple Fixed-Point Iteration

Use simple fixed-point iteration to locate the root of

Solution The function can be separated directly and

expressed in the form of

With an initial guess of x0 =0, then the iterative equation can be calculated as

xexf x )(

ixi ex 1

Page 8: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

8

Ex. 6.1 Simple Fixed-Point Iteration

an initial guess of x0 =0, true root: 0.56714329

ixi ex 1

Page 9: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

9

Convergence

Why this result can be called as convergence?

Reading assignment: Read section 6.1.1 pp. 135

Page 10: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

10

Ex. 6.2 Two-curve graphical method

Separate the equation into two parts and determine its root graphically

Solution Reformulate the equation as: and

xexf x )(

xy 1xey 2

Page 11: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

11

In graphical methods The intersection of the

two curves indicates a root estimate of approximately x =0.57

Page 12: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

12

Exercise

Use simple fixed-point iteration to locate the root of

Use an initial guess of x0 = 0.5

xxxf sin2)(

Page 13: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

13

Solution

The first iteration is

Page 14: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

14

Solution

The remaining iterations are

Page 15: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

15

The Newton-Raphson Methods

The most widely used of all root-locating formula is the Newton-Raphson equation.

If the initial guess at the root is xi, a tangent can be extended from the point [xi, f(xi)]

The point where this tangent crosses the x axis usually represents an improved estimate of the root.

Page 16: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

16

The Newton-Raphson Methods

The Newton-Raphson method can be derived on the basis of this geometrical interpretation

The first derivative at x is equivalent to the slope:

which can be rearranged to yield

1

)()(

ii

ii xx

xfxf

)(

)(1

i

iii xf

xfxx

Page 17: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

17

Ex. 6.3 Newton-Raphson Method

Use the Newton-Raphson method to estimate the root of

Employing an initial guess of x0 = 0 Solution The first derivative of the function can be evaluated as

Which can be substituted along with the original function

xexf x )(

1)( xexf

)(

)(1

i

iii xf

xfxx

11

i

i

xi

x

ii e

xexx

Page 18: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

18

Ex. 6.3 Newton-Raphson Method

Starting with an initial guess of x0 = 0, this iterative equation can be applied to compute:

The approach rapidly converges on the true root. Faster that by using simple fixed-point iteration

Page 19: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

19

Termination Criteria and Error Estimates

The approximate percent relative error can also be used as a termination criterion.

Other criteria can also be obtained such as discussed in Example 6.4

Page 20: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

20

Pitfalls of the Newton-Raphson Method

Although the Newton-Raphson method is often very efficient, there are situations where it performs poorly.

A special case – multiple roots – will be addressed later

However, even when dealing with simple roots, difficulties can also arise, as in the following example

Page 21: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

21

Ex. 6.5 Slowly Converging Function with Newton-Raphson

Determine the positive root of f(x) = 1010-1 using the Newton-Raphson method and an initial guess of x = 0.5

Solution The Newton-Raphson formula for this case is

Which can be used to compute:

9

10

1 10

1

i

iii x

xxx

Page 22: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

22

Iteration results

Page 23: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

23

Pitfalls of the Newton-Raphson Method

Page 24: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

24

Pitfalls of the Newton-Raphson Method

Page 25: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

25

The Secant Method

A potential problem in implementing the Newton-Raphson method is the evaluation of the derivative.

For polynomials and many other function this is not convenient

There are certain function the derivative may be extremely difficult or inconvenient to evaluate

Page 26: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

26

The Secant Method

For these cases, the derivative can be approximated by a backward finite divided difference

The secant method can be formulated as:

ii

iii xx

xfxfxf

1

1 )()()(

)(

)(1

i

iii xf

xfxx

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

Page 27: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

27

Graphical depiction of the secant method

Page 28: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

28

Ex. 6.6

Use the secant method to estimate the root of f(x) = e-

x – x. Start with the estimates of xi-1 = 0 and x0 = 1.0. Solution (true root = 0.56714329…) First iteration

Xi-1 = 0 f(xi-1)=1.0 X0 = 1 f(x0) = -0.63212

Calculate t = 8.0%

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

61270.0

)63212.0(1

)10(63212.011

x

Page 29: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

29

Ex. 6.6

Solution (true root = 0.56714329…) Second iteration

X0 = 1 f(x0)= - 0.63212 X1 = 0.61270 f(x1) = - 0.07081

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

56384.0)07081.0(63212.0

)61270.01(07081.061270.02

x

Page 30: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

30

Ex. 6.6

Solution (true root = 0.56714329…) Third iteration

X0 = 0.61270 f(x1)= - 0.07081 X1 = 0.56384 f(x1) = 0.00518

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

56717.0)0518.0(07081.0

)56384.061270.0(00518.056384.03

x

Page 31: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

31

Ex. 6.6x

Use the secant method to estimate the root of f(x) = e-x – 2x. Start with the estimates of xi-1 = 0 and x0 = 1.0.

Solution (true root = xxxx) First iteration

Xi-1 = 0 f(xi-1)=xx X0 = 1 f(x0) = xxxx

Calculate t = 8.0%

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

61270.0

)63212.0(1

)10(63212.011

x

Page 32: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

32

Next week

Reading assignment: Read pp. 146 – 157 Read pp. 160 – 174

Page 33: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

33

Quiz (60 Minutes)

What do you know about mathematical model in solving engineering problem? (10 marks)

Use zero through third order Taylor series expansions to predict f(2.5) for f(x) = ln x using a base point at x = 1. Compute the true percent relative error for each approximation. (15 marks)

Determine the real root of f(x)= 5x3-5x2+6x-2 using bisection method. Employ initial guesses of xl = 0 and xu = 1. iterate until the estimated error a falls below a level of s = 15% (20 marks)

Page 34: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

34

The difference between the Secant and False-Position Methods

Similarity of Secant and False-Position Methods The approximate root equation are identical on a term by term

basis

Both of them use two initial estimates to compute an approximation of the slope.

Critical difference: How in both methods the new estimate replaces the initial value

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

)()(

)(

ul

uluur xfxf

xxxfxx

False Position Method

Secant Method

Page 35: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

35

Page 36: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

36

Ex. 6.7

Use the false-position and secant methods to estimate the root of f(x) = ln x.

Start the computation with value of xl = xi-1 = 0.5 xu = xi = 5.0

Solution

The false-position method

The secant method

Page 37: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

37

Page 38: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

38

Modified Secant Method

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

)()(

)(1

iii

iiii xfxxf

xfxxx

ii

iii xx

xfxfxf

1

1 )()()(

i

iiii x

xfxxfxf

)()(

)(

Modified Secant Method

Original Secant Method

Page 39: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

39

Ex. 6.8

Use the secant method to estimate the root of f(x) = e-x – x. Use a value of 0.01 for and start with x0 = 1.0.

Solution (true root = 0.56714329…) First iteration

x0 = 1 f(x0) = -0.63212 x1+ x0 = 1.01 f(x1+ x0) = -0.64578

Calculate t = 5.3%

)()(

)(1

iii

iiii xfxxf

xfxxx

537263.0

)63212.0(64578.0

)63212.0(01.011

x

Page 40: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

40

Ex. 6.8

Solution (true root = 0.56714329…) Second iteration

x0 = 0.537263 f(x0) = -0.047083 x1+ x0 = 0.542635 f(x1+ x0) = -0.038579

Calculate t = 0.0236%

)()(

)(1

iii

iiii xfxxf

xfxxx

56701.0

)047083.0(038579.0

)047083.0(005373.0537263.01

x

Page 41: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

41

Ex. 6.8

Solution (true root = 0.56714329…) Third iteration

x0 = 0.56701 f(x0) = 0.000209 x1+ x0 = 0.572680 f(x1+ x0) = -0.00867

Calculate t = 2.365x10-5 %

)()(

)(1

iii

iiii xfxxf

xfxxx

567143.0

)000209.0(00867.0

)000209.0(00567.056701.01

x

Page 42: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

42

Multiple Roots

)1)(1)(3()( xxxxf )1)(1)(1)(3()( xxxxxf

Page 43: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

43

Multiple Roots

Page 44: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

44

Modified Newton-Raphson

A modifications have been proposed by Ralston and Rabinowitz (1978)

)(

)(1

i

iii xf

xfxx

)()()(

)()(21

iii

iiii

xfxfxf

xfxfxx

Original Newton-Raphson

Modified Newton-Raphson

Page 45: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

45

Ex. 6.9

Use both the standard ad modified Newton-Raphson methods to evaluate the multiple root of

f(x) = (x-3)(x-1)(x-1)

with initial guess of x0 = 0.

Solution (true value: 1.0) First derivative: f’(x) = 3x2 - 10x + 7 Second derivative f’’(x) = 6x - 10

)(

)(1

i

iii xf

xfxx

)()()(

)()(21

iii

iiii

xfxfxf

xfxfxx

7103

3752

23

1

ii

iiiii xx

xxxxx

)106)(375(7103

)7103)(375(2322

223

1

iiiiii

iiiiiii

xxxxxx

xxxxxxx

Original Newton-Raphson

Modified Newton-Raphson

Page 46: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

46

Original Newton-Raphson Method

)(

)(1

i

iii xf

xfxx

7103

3752

23

1

ii

iiiii xx

xxxxx

Page 47: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

47

Modified Newton-Raphson Method

)()()(

)()(21

iii

iiii

xfxfxf

xfxfxx

)106)(375(7103

)7103)(375(2322

223

1

iiiiii

iiiiiii

xxxxxx

xxxxxxx

Page 48: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

48

Ex. 6.9

For both methods to search for single root at x = 3 using initial guess of x0 = 4

Both methods converge quickly, with the standard method being somewhat more efficient

Page 49: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

49

Modified secant method

For multiple root secant method can be modified as:

)()(

))((

1

11

ii

iiiii xfxf

xxxfxx

)()(

))((

1

11

ii

iiiii xuxu

xxxuxx

)(

)()(

xf

xfxu i

Page 50: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

50

System of Nonlinear Equations

We have discussed on the determination of roots of single equation

How about locating roots of a set of simultaneous equations

Nonlinear equations is algebraic and transcendental equations that do not fit following format

0...)( 2211 bxaxaxaxf nn

Page 51: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

51

By Fixed-Point Iteration

Non linear equations:

Two simultaneous nonlinear equation with two unknown, x and y.

102 xyx

573 2 xyy

010),( 2 xyxyxu

573),( 2 xyyyxv

Page 52: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

52

6.10

Use fixed-point iteration to determine the root of Eq. (6.16). Note that a correct pair of roots is x = 2 and y = 3. Initiate the computation with guesses of the x = 1.5 and y = 3.5.

Solution

102 xyx

573 2 xyy

i

ii y

xx

2

1

10

21 357 iii yxy

Page 53: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

53

6.10

Solution On the basis of the initial value x = 1.5 and y = 3.5

21429.25.3

)5.1(10 2

1

ix

37516.24)5.3)(21429.2(357 21 iy

i

ii y

xx

2

1

10

21 357 iii yxy

Page 54: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

54

6.10

Solution On the basis of the initial value x = 1.5 and y = 3.5

010),( 2 xyxyxu

573),( 2 xyyyxv

xyx 10

x

yy

3

57

Page 55: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

55

6.10

Solution On the basis of the initial value x = 1.5 and y = 3.5

17945.2)5.3)(5.1(10 x

86051.2)17945.2(3

5.357

y

xyx 10

x

yy

3

57

Page 56: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

56

6.10

Page 57: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

57

By Newton-Raphson

Page 58: 1 Open Methods Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis Applied Numerical Method for Engineers Chapter 6

58

Assignment

Solve problem 6.2