Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 6 Open Methods.

Similar presentations


Presentation on theme: "Chapter 6 Open Methods."— Presentation transcript:

1 Chapter 6 Open Methods

2 Open Methods 6.1 Simple Fixed-Point Iteration
6.2 Newton-Raphson Method* 6.3 Secant Methods* 6.4 MATLAB function: fzero 6.5 Polynomials

3 Open Methods There exist open methods which do not require bracketed intervals Newton-Raphson method, Secant Method, Muller’s method, fixed-point iterations First one to consider is the fixed-point method Converges faster but not necessary converges

4 Bracketing and Open Methods

5 Fixed-Point Iteration
First open method is fixed point iteration Idea: rewrite original equation f(x) = 0 into another form x = g(x). Use iteration xi+1 = g(xi ) to find a value that reaches convergence Example:

6 Simple Fixed-Point Iteration Two Alternative Graphical Methods
f(x) = 0 f1(x) = f2(x) f(x) = f1(x) – f2(x) = 0

7 Fixed-Point Iteration
Convergent Divergent

8 Steps of Fixed-Point Iteration
x = g(x), f(x) = x - g(x) = 0 Step 1: Guess x0 and calculate y0 = g(x0). Step 2: Let x1 = g(x0) Step 3:Examining if x1 is the solution of f(x) = 0. Step 4. If not, repeat the iteration, x0 = x1

9 Newton’s Method King of the root-finding methods Newton-Raphson method
Based on Taylor series expansion

10 Newton-Raphson Method
Truncate the Taylor series to get At the root, f(xi+1) = 0 , so

11 Newton-Raphson Method

12 Newton-Raphson Method
False position - secant line Newton’s method - tangent line root x* xi+1 xi

13 Newton Raphson Method Step 1: Start at the point (x1, f(x1)).
Step 2 : The intersection of the tangent of f(x) at this point and the x-axis. x2 = x1 - f(x1)/f `(x1) Step 3: Examine if f(x2) = 0 or abs(x2 - x1) < tolerance, Step 4: If yes, solution xr = x2 If not, x x2, repeat the iteration.

14 Newton’s Method Note that an evaluation of the derivative (slope) is required You may have to do this numerically Open Method – Convergence depends on the initial guess (not guaranteed) However, Newton method can converge very quickly (quadratic convergence)

15 Script file: Newtraph.m

16 Bungee Jumper Problem Newton-Raphson method
Need to evaluate the function and its derivative Given cd = 0.25 kg/m, v = 36 m/s, t = 4 s, and g = 9.81 m2/s, determine the mass of the bungee jumper

17 Bungee Jumper Problem >> y=inline('sqrt(9.81*m/0.25)*tanh(sqrt(9.81*0.25/m)*4)-36','m') y = Inline function: y(m) = sqrt(9.81*m/0.25)*tanh(sqrt(9.81*0.25/m)*4)-36 >> dy=inline('1/2*sqrt(9.81/(m*0.25))*tanh(sqrt(9.81*0.25/m)*4)-9.81/(2*m)*4*sech(sqrt(9.81*0.25/m)*4)^2','m') dy = dy(m) = 1/2*sqrt(9.81/(m*0.25))*tanh(sqrt(9.81*0.25/m)*4)-9.81/(2*m)*4*sech(sqrt(9.81*0.25/m)*4)^2 >> format short; root = newtraph(y,dy,140, ) root =

18 Multiple Roots A multiple root (double, triple, etc.) occurs where the function is tangent to the x axis double roots single root

19 Examples of Multiple Roots

20 Multiple Roots Problems with multiple roots
The function does not change sign at even multiple roots (i.e., m = 2, 4, 6, …) f (x) goes to zero - need to put a zero check for f(x) in program slower convergence (linear instead of quadratic) of Newton-Raphson and secant methods for multiple roots

21 Modified Newton-Raphson Method
When the multiplicity of the root is known Double root : m = 2 Triple root : m = 3 Simple, but need to know the multiplicity m Maintain quadratic convergence See MATLAB solutions

22 Multiple Root with Multiplicity m
f(x)=x5  11x4 + 46x3  90x2 + 81x  27 double root three roots Multiplicity m m = 1 : single root m = 2 : double root m = 3: triple root

23 Modified Newton’s Method
Can be used for both single and multiple roots (m = 1: original Newton’s method) m =1: single root m=2, double root m=3 triple root etc.

24 Original Newton’s method m = 1 Modified Newton’s Method m = 2
» multiple1('multi_func','multi_dfunc'); enter multiplicity of the root = 1 enter initial guess x1 = 1.3 allowable tolerance tol = 1.e-6 maximum number of iterations max = 100 Newton method has converged step x y » multiple1('multi_func','multi_dfunc'); enter multiplicity of the root = 2 enter initial guess x1 = 1.3 allowable tolerance tol = 1.e-6 maximum number of iterations max = 100 Newton method has converged step x y Double root : m = 2 f(x) = x5  11x4 + 46x3  90x2 + 81x  27 = 0

25 Modified Newton’s Method with u = f / f
A more general modified Newton-Raphson method for multiple roots u(x) contains only single roots even though f(x) may have multiple roots

26

27 Modified Newton’s method with u = f / f 
function f = multi_func(x) % Exact solutions: x = 1 (double) and 2 (triple) f = x.^5 - 11*x.^4 + 46*x.^3 - 90*x.^2 + 81*x - 27; function f_pr = multi_pr(x) % First derivative f'(x) f_pr = 5*x.^4 - 44*x.^ *x.^ *x + 81; function f_pp = multi_pp(x) % Second-derivative f''(x) f_pp = 20*x.^ *x.^ *x - 180; >> [x, f] = multiple2('multi_func','multi_dfunc','multi_ddfunc'); enter initial guess: xguess = 0 allowable tolerance: es = 1.e-6 maximum number of iterations: maxit = 100 Newton method has converged step x f df/dx d2f/dx2 Double root at x = 1

28 Original Newton’s method (m = 1)
f(x) = x5  11x4 + 46x3  90x2 + 81x  27 = 0 >> [x,f] = multiple1('multi_func','multi_dfunc'); enter multiplicity of the root = 1 enter initial guess: xguess = 10 allowable tolerance: es = 1.e-6 maximum number of iterations: maxit = 200 Newton method has converged step x f df/dx … …… …… ….. Triple Root at x = 3

29 Modified Newton’s method
f(x) = x5  11x4 + 46x3  90x2 + 81x  27 = 0 >> [x,f] = multiple2('multi_func','multi_dfunc','multi_ddfunc'); enter initial guess: xguess = 10 allowable tolerance: es = 1.e-6 maximum number of iterations: maxit = 100 Newton method has converged step x f df/dx d2f/dx2 Triple root at x = 3 Original Newton-Raphson method required 135 iterations Modified Newton’s method converged in only 7 iterations

30 Convergence of Newton’s Method
The error of the Newton-Raphson method (for single root) can be estimated from xk+1 Quadratic convergence

31 Newton-Raphson Method
Although Newton-Raphson converges very rapidly, it may diverge and fail to find roots 1) if an inflection point (f’’=0) is near the root 2) if there is a local minimum or maximum (f’=0) 3) if there are multiple roots 4) if a zero slope is reached Open Method, Convergence not guaranteed

32 Newton-Raphson Method
Examples of poor convergence

33 Use secant line instead of tangent line at f(xi)
Secant Method Use secant line instead of tangent line at f(xi)

34 Secant Method The formula for the secant method is
Notice that this is very similar to the false position method in form Still requires two initial estimates But it doesn't bracket the root at all times - there is no sign test

35 False-Position and Secant Methods

36 Algorithm for Secant method
Open Method 1. Begin with any two endpoints [a, b] = [x0 , x1] 2. Calculate x2 using the secant method formula 3. Replace x0 with x1, replace x1 with x2 and repeat from (2) until convergence is reached Use the two most recently generated points in subsequent iterations (not a bracket method!)

37 Secant Method Advantage of the secant method -
It can converge even faster and it doesn’t need to bracket the root Disadvantage of the secant method - It is not guaranteed to converge! It may diverge (fail to yield an answer)

38 Convergence not Guaranteed
y = ln x no sign check, may not bracket the root

39 Secant method False position method
» [x1 f1]=secant('my_func',0,1,1.e-15,100); secant method has converged step x f » [x2 f2]=false_position('my_func',0,1,1.e-15,100); false_position method has converged step xl xu x f

40 Secant method may converge even faster and it doesn’t need to bracket the root
False position

41 Similarity & Difference b/w F-P & Secant Methods
False-point method Starting two points. Similar formula xm = xu - f(xu)(xu-xl)/(f(xu)- f(xl)) ___________________________ Next iteration: points replace-ment: if f(xm)*f(xl) <0, then xu = xm else xl = xm. Require bracketing. Always converge Secant method Starting two points. Similar formula x3= x2-f(x2)(x2-x1)/(f(x2)- f(x1)) ___________________________ Next iteration: points replace-ment: always x1 = x2 & x2 =x3. no requirement of bracketing. Faster convergence May not converge

42 Bisection -- 47 iterations False position -- 15 iterations
Convergence criterion Bisection iterations False position iterations Secant iterations Newton’s iterations Bisection False position Secant Newton’s

43 Modified Secant Method
Use fractional perturbation instead of two arbitrary values to estimate the derivative  is a small perturbation fraction (e.g., xi/xi = 106)

44 MATLAB Function: fzero
Bracketing methods – reliable but slow Open methods – fast but possibly unreliable MATLAB fzero – fast and reliable fzero: find real root of an equation (not suitable for double root!) fzero(function, x0) fzero(function, [x0 x1])

45 fzero unable to find the double root of
>> root=fzero('multi_func',-10) root = >> root=fzero('multi_func',1000) >> root=fzero('multi_func',[ ]) >> root=fzero('multi_func',[-2 2]) ??? Error using ==> fzero The function values at the interval endpoints must differ in sign. >> root=multiple2('multi_func','multi_dfunc','multi_ddfunc'); enter initial guess: xguess = -1 allowable tolerance: es = 1.e-6 maximum number of iterations: maxit = 100 Newton method has converged step x f df/dx d2f/dx2 fzero unable to find the double root of f(x) = x5  11x4 + 46x3  90x2 + 81x  27 = 0

46 fzero and optimset functions Find sign change after 22 iterations
>> options=optimset('display','iter'); >> [x fx]=fzero('manning',50,options) Func-count x f(x) Procedure initial search search search search search search search search search Looking for a zero in the interval [4.7452, 82] interpolation interpolation interpolation e interpolation e interpolation e interpolation e interpolation Zero found in the interval: [4.7452, 82]. x = fx = e-013 Search in both directions x0  x for sign change Find sign change after 22 iterations Switch to secant (linear) or inverse quadratic interpolation to find root

47 Root of Polynomials Bisection, false-position, Newton-Raphson, secant methods cannot be easily used to determine all roots of higher-order polynomials Muller’s method (Chapra and Canale, 2002) Bairstow method (Chapra and Canale, 2002) MATLAB function: roots

48 Secant and Muller’s Method

49 Muller’s Method y(x) Secant line x1 x x3 x2 Parabola
Fit a parabola (quadratic) to exact curve Find both real and complex roots (x2 + rx + s = 0 )

50 MATLAB Function: roots
Recast the root evaluation task as an eigenvalue problem (Chapter 20) Zeros of a nth-order polynomial r = roots(c) - roots c = poly(r) - inverse function

51 Roots of Polynomial Consider the 6th-order polynomial
(4 real and 2 complex roots) >> c = [ ]; >> r = roots(c) r = i i 3.0000 2.0000 >> polyval(c, r), format long g ans = e e-012i e e-012i e-012 e-013 e-013 e-014 Verify f(xr) =0

52 f(x) = x5  11x4 + 46x3  90x2 + 81x  27 = (x  1)2(x  3)3
>> c = [ ]; r = roots(c) r = i i i i

53 CVEN 302-501 Homework No. 5 Chapter 5
Problem 5.10 b) & c) (25)(using MATLAB Programs) Chapter 6 Problem 6.3 (Hand Calculations for parts (b), (c), (d))(25) Problem 6.7 (MATLAB Program) (25) Problem 6.9 (MATLAB program) (25) Problem 6.16 (use MATLAB function fzero) (25) Due on Monday 09/29/08 at the beginning of the period


Download ppt "Chapter 6 Open Methods."

Similar presentations


Ads by Google