Metode Terbuka (Open Methods) -...

24
a home base to excellence Metode Terbuka (Open Methods) Pertemuan - 3 Mata Kuliah : Analisis Numerik dan Pemrograman Kode : TSP 303 SKS : 3 SKS

Transcript of Metode Terbuka (Open Methods) -...

Page 1: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Metode Terbuka

(Open Methods)

Pertemuan - 3

Mata Kuliah : Analisis Numerik dan Pemrograman

Kode : TSP – 303

SKS : 3 SKS

Page 2: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• TIU : Mahasiswa dapat mencari akar-akar suatu persamaan, menyelesaikan

persamaan aljabar linear, pencocokan kurva, dan membuat program

aplikasi analisis numeriknya

• TIK : Mahasiswa dapat menjelaskan Metode Terbuka (Open Methods)

untuk menyelesaikan permasalahan akar-akar persamaan

Page 3: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• Sub Pokok Bahasan :

Simple Fixed-Point Iteration

Metode Newton-Raphson

Metode Secant

Kelemahan dan Kelebihan dari metode tersebut

Page 4: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• For the bracketing methods, the root is located within an interval prescribed by a lower and an upper bound.

• Repeated application of these methods always results in closer estimates of the true value of the root.

• Such methods are said to be convergent because they move closer to the truth as the computation progresses

• In contrast, the open methods are based on formulas that require only a single starting value of x or two starting values that do not necessarily bracket the root

Page 5: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• As such, they sometimes diverge or move away from the true root as the computation progresses (Fig. b).

• However, when the open methods converge (Fig. c), they usually do so much more quickly than the bracketing methods.

Page 6: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Simple Fixed-Point Iteration

• Open methods employ a formula to predict the root.

• Such a formula can be developed for simple fixed-point iteration (or, as it is also called, one-point iteration or successive substitution) by rearranging the function f(x)=0 so that x is on the left-hand side of the equation:

x=g(x) (1)

Page 7: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• This transformation can be accomplished

either by algebraic manipulation or by simply

adding x to both sides of the original

equation.

• For example,

0

0322

xsin

xx

xxsinx

xx

2

32

Page 8: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• The utility of Eq. (1) is that it provides a formula to predict a

new value of x as a function of an old value of x.

• Thus, given an initial guess at the root xi, Eq. (1) can be used

to compute a new estimate xi+1 as expressed by the iterative

formula

xi+1= g(xi) (2)

• the approximate error for this equation can be determined

using the error estimator

%

x

xx

i

iia 100

1

1

Page 9: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Example 1 :

Use simple fixed-point iteration to locate the

root of f(x)=e−x− x

The function can be separated directly and expressed

in the form

xi+1=e−xi

Page 10: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• Starting with an initial guess of x0=0, this

iterative equation can be applied to compute

Iteration xi g(xi) a (%) t (%)

0 0 1

1 1 0,36788 100

2

3

4

5

6

7

8

9

10

the true value of

the root: 0.56714329.

Page 11: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

The Newton-Raphson Method

• Perhaps the most widely used of all root-locating formulas 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 12: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• the first derivative at x is equivalent to the

slope

• Which can be rearranged to yield Newton-

Raphson formula :

1

0

ii

ii

xx

xfxf

i

iii

xf

xfxx

1 (3)

Page 13: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Example 2 :

Use the Newton-Raphson method to estimate

the root of f(x)=e−x− x, employing an initial

guess of x0 = 0

The first derivative of the function can be evaluated as

f(x = −e− − , hi h can be substituted along with the

original function into Eq. (3) to give

11

i

i

x

ix

iie

xexx

Page 14: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• Starting with an initial guess of x0=0, this iterative

equation can be applied to compute

Iterasi x i f(x i ) f /(x i ) a (%) t (%)

1 0 1 -2

2 0,5 0,1065 -1,607

3 0,5663 0,0013 -1,568

4

5

the true value of

the root: 0.56714329.

Page 15: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• Although the Newton-Raphson method is

often very efficient, there are situations

where it performs poorly.

• Fig. a depicts the case where an inflection

point [that is, f’’ = ] o urs in the i init of a root.

• Fig. b illustrates the tendency of the

Newton-Raphson technique to oscillate

around a local maximum or minimum.

• Fig. c shows how an initial guess that is

close to one root can jump to a location

several roots away.

• O iousl , a zero slope [f’ = ] is trul a disaster because it causes division by zero

in the Newton-Raphson formula (see Fig d)

Page 16: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

The Secant Method

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

• Although this is not inconvenient for polynomials and many other functions, there are certain functions whose derivatives may be extremely difficult or inconvenient to evaluate.

• For these cases, the derivative can be approximated by a backward finite divided difference, as in the following figure

Page 17: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

ii

iii

xx

xfxfxf

1

1

This approximation can be

substituted into Eq. (3) to

yield the following iterative

equation:

ii

iiiii

xfxf

xxxfxx

1

1

1(4)

Page 18: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• Equation (4) is the formula for the secant

method.

• Notice that the approach requires two initial

estimates of x.

• However, because f(x) is not required to

change signs between the estimates, it is not

classified as a bracketing method.

Page 19: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Example 3 :

Use the Secant method to estimate the root of

f(x)=e−x− x, employing an initial guess of x0 = 0

Start with initial estimates of x−1 =0 and x0= 1.0.

Iteration x i-1 x i x i+1 f(x i-1 ) f(x i ) a (%)

0 0 1 0,6127 1 -0,632

1 1 0,6127 0,5638 -0,632 -0,071 -8,666

2

3

4

5

Page 20: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

The Difference Between the Secant and False-Position Methods

• The Eqs. Above are identical on a term-by-term basis.

• Both use two initial estimates to compute an approximation of the slope of the function that is used to project to the x axis for a new estimate of the root.

• However, a critical difference between the methods is how one of the initial values is replaced by the new estimate.

ii

iiiii

xfxf

xxxfxx

1

1

1

ul

uluur

xfxf

xxxfxx

False-Position Formula Secant Formula

Page 21: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

• Recall that in the false-position method the

latest estimate of the root replaces

whichever of the original values yielded a

function value with the same sign as f(xr).

• Consequently, the two estimates always

bracket the root.

• Therefore, the method always converges

• In contrast, the secant method replaces the

values in strict sequence, with the new

value xi+1 replacing xi and xi replacing xi− .

• As a result, the two values can sometimes

lie on the same side of the root.

• For certain cases, this can lead to

divergence.

Page 22: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Homework

Use : Simple Fixed-Point Iteration Method (x = g(x))

Page 23: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Homework

Use Secant Method

Page 24: Metode Terbuka (Open Methods) - OpenCourseWareocw.upj.ac.id/files/Slide-TSP303-Analisis-Numerik-Pemrograman-TSP... · Metode Terbuka (Open Methods) Pertemuan ... dan membuat program

a home base to excellence

Homework

Use Newton Raphson Method