Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots...

16
Roots of Equations: Bracketing Methods

Transcript of Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots...

Page 1: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

Roots of Equations: Bracketing Methods

Page 2: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

2

How to Solve?

v(t)' gmcd

tanhgcd

mt

t'4v'36g'9.81cd'0.25m'?

v(t)' gmcd

tanhgcd

mt

t'4v'36g'9.81cd'0.25m'?

Page 3: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

3

Techniques for Finding Roots

• Graphical Methods• Bracketing Methods• Open Methods

Page 4: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

4

Graphical Methods

• The best.• The worst.

Page 5: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

5

Bracketing Methods

• Find roots between a lower bound xl and an upper bound xu such that f(xl)*f(xu)<0.

• Initial guess needed (incremental search).• Always work if roots exist between the two

limits.• Converge slower than open methods.

Page 6: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

6

Conditions

a) f(xl)*f(xu)>0, no root.b) f(xl)*f(xu)<0, one root.c) f(xl)*f(xu)>0, even number

of roots.d) f(xl)*f(xu)<0, odd number

of roots.

Page 7: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

7

Conditions (cont.)

a) f(xl)*f(xu)<0, repeated roots.

b) f(xl)*f(xu)<0, no root.

Page 8: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

8

Incremental Search

• Goal: find xl and xu such that f(xl)*f(xu)<0.• Range of search must be decided. • Large step size may miss some roots.• Small step size increases computation time.

Page 9: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

9

Example• Cases where roots could be missed because the incremental length

of the search procedure is too large.• Note that the last root on the right is multiple and would be missed

regardless of the increment length.

Page 10: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

10

Example 5.2

• sin(10x)+cos(3x)• 50 steps:

3.2449, 3.30613.3061, 3.36733.7347, 3.79594.6531, 4.71435.6327, 5.6939

Page 11: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

11

Example 5.2 (cont.)• sin(10x)+cos(3x)• 100 steps:

3.2424, 3.27273.3636, 3.39393.7273, 3.75764.2121, 4.24244.2424, 4.27274.6970, 4.72735.1515, 5.18185.1818, 5.21215.6667, 5.6970

Page 12: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

12

Bisection

• Iterative.• Every iteration reduces the bound by half.• Algorithm: repeat the following

xr = ( xl + xu )/2if f(xr)*f(xu)<0

xl = xrelse

xu = xrend

Page 13: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

13

Example 5.3

Page 14: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

14

Converge Criteria

• Use relative approximate errora=| ( xr

new - xrold ) / xr

new ) | 100%.• Not suitable when the root is close to 0.• In that case, use approximate error.

a=| xrnew - xr

old |• Number of iteration can be determined if a is

specified.n'1%log2

Δx 0

Ea,d

Δx 0: initial boundEa,d: desired Ea

n'1%log2Δx 0

Ea,d

Δx 0: initial boundEa,d: desired Ea

Page 15: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

15

False Position

• Iterative.• Similar to bisection but determine the next bound by line

equation.• Algorithm: repeat the following

xr'xu&f(xu)(xl&xu)f(xl)&f(xu)

if f(xr)f(xu)<0xl'xr

elsexu'xr

end

xr'xu&f(xu)(xl&xu)f(xl)&f(xu)

if f(xr)f(xu)<0xl'xr

elsexu'xr

end

Page 16: Roots of Equations: Bracketing Methodsjuiching/NMChap5.pdf · Bracketing Methods • Find roots between a lower bound x l and an upper bound x u such that f(x l)*f(x u)

16

False Position (cont.)

• Usually converge faster than bisection but not always.

• Example: f(x)=x10-1