- + Suppose f(x) is a continuous function of x within interval [a, b]. f(a) = - ive and f(b) = + ive...

42

Transcript of - + Suppose f(x) is a continuous function of x within interval [a, b]. f(a) = - ive and f(b) = + ive...

ab

f(b)

f(a)

f(x)

xp

0

-

+

Suppose f(x) is a continuous function of x within interval [a, b].

f(a) = - ive and f(b) = + ive

There exist at least a number p in [a, b] with f(p) = 0.

Meaning, p is a root of the equation f(x) = 0

ab

f(b)

f(a)

f(x)

xp

0

-

+

The Bisection Method calls for a repeated halving of subintervals of [a, b]

each time locating the half containing p.

Bisection Method

(Binary Search)

a = a1

b = b1

a1b1p1

f(b1)

f(a1)

f(p1)

a2 b2p2

f(p2)

a3 b3p3

f(x)

x

Bisection Algorithm

Set a1 = a and b1 = b.

Find the midpoint between a1 and b1.

Midpoint,

2

bap 11

1

If f(p1) = 0, then p1 is the root of the equation within [a, b].

If f(p1) 0, then what?

Then find if f(p1) has the same sign as either f(a1) or f(b1).

a = a1

b = b1

a1b1p1

f(b1)

f(a1)

f(p1)

a2 b2p2

f(p2)

a3 b3p3

f(x)

x

Bisection Algorithm

IF f(p1) has the same sign as f(a1) , then the root is in [p1, b1]. Set a2 = p1 and b2 = b1.

IF f(p1) has the same sign as f(b1) , then the root is in [a1, p1]. Set a2 = a1 and b2 = p1.

The root is in the interval [a2, b2]. Divide the interval in two halves and repeat the process.

When do we stop?

εpp 1NN

εp

pp

N

1NN

εpf N

0104 23 xx)x(f hasa root in [1, 2].

n an pn bn1 1.0 (-) 1.5 (+) 2.0 (+)

2 1.0 (-) 1.25 (-) 1.5 (+)

3 1.25 (-) 1.375 (+) 1.5 (+)

4 1.25 (-) 1.3125 (-) 1.375 (+)

5 1.3125 (-) 1.34375 (-) 1.375 (+)

The Method of False Position

The method is based on bracketing the root between two points.

At the beginning choose two points, 0 1 and p p

so that 0 1 0f p f p

Now draw a line joining 0 0 1 1 and p , f p p , f p

The x-intercept of the line is 2p

Now bracket the root between either 0 2 1 2 or p , p p , p

Which pair to choose?

0 2If 0 then choosef p f p 0 2p , p

1 2if 0 then choosef p f p On the other hand

1 2p , p

Let us assume that 0 2 0f p f p

This means that the root is between 0 2p , p

Now draw a line joining 0 0 2 2 and p , f p p , f p

The x-intercept of the line is 3p

and the process continues …

0104 23 xx)x(f hasa root in [1, 2].

n1 1.26316

2 1.33883

3 1.35855

4 1.36355

5 1.36481

np

Fixed-Point Iteration

Rewrite f(x) = 0 in the form of x = g(x) and iterate.

0104 23 xx)x(f has

a root in [1, 2].

We can rewrite f(x) in the form of x = g(x) in the following ways.

2

1

4

2

13

3

2

1

2

231

410(d)

102

1(c)

410(b)

104(a)

x/)x(gx

x)x(gx

xx/)x(gx

xxx)x(gx

104(a) 231 xxx)x(gx

Start with x = 1.5

8750

10514515151 231

.

...).(gx

7326

108750487508750

875023

1

.

...

).(gx

Results of the Fixed-point Iteration

n (a) (b) (c) (d)

1 1.5 1.5 1.5 1.5

2 -0.875 0.8165 1.2869537 1.3483997

3 6.732 2.9969 1.4025408 1.3673763

4 -469.7 1.3454583 1.3649570

5 1.3751702 1.3652647

6 1.3600941 1.3652255

7 1.3678469 1.3652305

8 1.3638870 1.3652299

9 1.3659167 1.3652300

810031 . 21658.

Why some expressions failed to deliver the root?

To deliver the root, g(x) for all x in [a, b] must stay within [a, b].

b g a a

b g b a

p0

p

(p0, f(p0))

p2

p1

0pf slope

1pf slope f(x)

x

f(x)

(p1, f(p1))

Newton’s Method

Consider the triangle (p2, 0), (p1, 0) and (p1, f(p1)).

Newton’s Method

p0

p

(p0, f(p0))

p2

p1

0pf slope

1pf slope f(x)

x

f(x)

(p1, f(p1))

Consider the triangle (p2, 0), (p1, 0) and (p1, f(p1)).

(p2, 0) (p1, 0)

(p1, f(p1))

1pf slope

(p2, 0) (p1, 0)

(p1, f(p1))

1pf slope

The slope,

21

11 pp

pfpf

11 2

1

or, f p

p pf p

12 1

1

or, f p

p pf p

A sequence can be generated as:

-1n

-1n-1nn pf

pfpp

Example:

8x3xxf

104xxxf2

23

11pf5pf1p 111

4551

11

51

pf

pfpp

1

112 .

17.991pf1.548pf1.455p 222

3691

99117

54814551

pf

pfpp

2

223 .

.

..

3651

57416

06203691

pf

pfpp

3

334 .

.

..