Download presentation

Presentation is loading. Please wait.

Published byMoises Seton Modified over 4 years ago

1
**Roots of Equations Our first real numerical method – Root finding**

Finding the value x where a function y = f(x) = 0 You will encounter this process again and again

2
**Two Fundamental Approaches**

Bracketing Methods Bisection False Position Approach Open Methods Fixed-Point Iteration Newton-Raphson Secant Methods Roots of Polynomials

3
Chapter 5 Bracketing Methods

4
**Bracketing Methods 5.1 Introduction and Background**

5.2 Graphical Methods 5.3 Bracketing Methods and Initial Guesses 5.4 Bisection 5.5 False-Position

5
**Single root (change sign) Three roots (change sign)**

Graphical methods No root (same sign) Single root (change sign) Two roots (same sign) Three roots (change sign)

6
Special Cases Multiple Roots Discontinuity

7
**Graphical Method - Progressive Enlargement**

Two distinct roots

8
Graphical Method Graphical method is useful for getting an idea of what’s going on in a problem, but depends on eyeball. Use bracketing methods to improve the accuracy Bisection and false-position methods

9
Bracketing Methods Both bisection and false-position methods require the root to be bracketed by the endpoints. How to find the endpoints? * plotting the function * incremental search * trial and error

10
Incremental Search

11
Incremental Search

12
**Incremental Search Find 5 roots**

>> xb=incsearch(inline('sin(10*x)+cos(3*x)'),3,6) number of brackets: 5 xb = >> yb = xb.*0 yb = >> x=3:0.01:6; y=sin(10*x)+cos(3*x); >> plot(x,y,xb,yb,'r-o') Find 5 roots

13
**Use 50 intervals between [3, 6]**

missed 1 2 3 4 5 missed

14
**Increase Subintervals to 200**

>> xb=incsearch(inline('sin(10*x)+cos(3*x)'),3,6,200) number of brackets: 9 xb = >> yb = xb.*0; >> H = plot(x,y,xb(:,1),yb(:,1),'r-v',xb(:,2),yb(:,2),'k^'); >> set(H,'LineWidth',2,'MarkerSize',8) Find all 9 roots!

15
Incremental Search Find all 9 roots

16
**Bracketing Methods Graphic Methods (Rough Estimation)**

Single Root e.g.(X-1) (X-2) = 0 (X = 1, X =2) Double Root e.g. (X-1)^2 = 0 (X = 1) Effective Only to Single Root Cases f(x) = 0 xr is a single root then f(xl)*f(xu) always < 0 if xl < xr and xu > xr.

17
**Bisection Method Step 1: Choose xl and xu such that xl and xu**

bracket the root, i.e. f(xl)*f(xu) < 0. Step 2 : Estimate the root (bisection). xr = 0.5*(xl + xu) Step 3: Determine the new bracket. If f(xr)*f(xl) < xu = xr else xl = xr end Step 4: Examine if xr is the root.

18
**Bisection Method x* x1 x2 x3**

5. If not Repeat steps 2 and 3 until convergence x1 x* x2 x3 Non-monotonic convergence: x1 is closer to the root than x2 or x3

19
y f(xl)f(xu) <0 xm=0.5(xl+xu) xu o x xl Bisection Method

20
Bisection Flowchart no yes

21
Mass of a Bungee Jumper Determine the mass m of a bungee jumper with a drag coefficient of 0.25 kg/m to have a velocity of 36 m/s after 4 s of free fall. Rearrange the equation – solve for m

22
**Graphical Depiction of Bisection Method**

(50 kg < m < 200 kg)

23
**Hand Calculation Example**

Bisection Method f(2) = 3, f(3.2) = 0.84

24
**Use “inline” command to specify the function “func”**

M-file in textbook Use “inline” command to specify the function “func”

25
**Use “feval” to evaluate the function “func”**

An interactive M-file Use “feval” to evaluate the function “func” yb y ya a x b break: terminate a “for” or “while” loop

26
**Examples: Bisection 1. Find root of Manning's equation**

2. Two other functions

27
**Bisection Method for Manning Equation**

»bisect2('manning') enter lower bound xl = 0 enter upper bound xu = 10 allowable tolerance es = maximum number of iterations maxit = 50 Bisection method has converged step xl xu xr f(xr)

28
**CVEN 302-501 Homework No. 4 Chapter 4**

Problems 4.10 (15), 4.12 (15) Hand computation Chapter 5 Problem 5.8 (20) (hand calculations for parts b) and c) Problem 5.1 (20) (hand calculations) Problem 5.3 (20) (hand calculations) Problem 5.4 (30) (MATLAB Program) Due 09/22/08 Monday at the beginning of the period

29
**False-Position (point) Method**

Why bother with another method? The bisection method is simple and guaranteed to converge (single root) But the convergence is slow and non-monotonic! The bisection method is a brute force method and makes no use of information about the function Bisection only the sign, not the value f(xk ) itself False-position method takes advantage of function curve shape False position method may converge more quickly

30
**False-Position Method**

Algorithm for False-Position Method 1. Start with [xl , xu] with f(xl) . f(xu) < 0 (still need to bracket the root) 2. Draw a straight line to approximate the root 3. Check signs of f(xl) . f(xr) and f(xr) . f(xu) so that [xl , xu ] always bracket the root Maybe less efficient than the bisection method for highly nonlinear functions

31
**False-Position Method**

y(xu) y(x) secant line xr xl xu x x* y(xl) Straight line (linear) approximation to exact curve

32
**False Point Method Step 1: Choose xl and xu. f(xl)*f(xu) < 0.**

Step 2 : Estimate the root: Find the intersection of the line connecting the two points (xl, f(xl)), and (xu,f(xu)) and the x-axis. xr = xu - f(xu)(xu - xl)/(f(xu) - f(xl)) Step 3: Determine the new bracket. If f(xr)*f(xl) < 0 , then xu = xr else xl = xr Step 4: whether or not repeat the iteration (see slide 18).

33
**y o x False-point method xr=xu - f(xu)(xu-xl)/(f(xu) -f(xl)) xu,f(xu)**

xl,f(xl) False-point method

34
**False-Position Method**

From geometry, similar triangles have similar ratios of sides The new approximate for the root : y(xr ) = 0 This can be rearranged to yield False Position formula

35
False-point Method Flowchart no yes

36
**Hand Calculation Example**

False- Position

37
**Examples: False-Position**

1. Find root of Manning's equation 2. Some other functions

38
**Linear Interpolation Method**

False-position (Regula-Falsi) Linear interpolation Linear Interpolation Method

39
**False-Position (Linear Interpolation) Method**

Manning Equation >> false_position('manning') enter lower bound xl = 0 enter upper bound xu = 10 allowable tolerance es = maximum number of iterations maxit = 50 False position method has converged step xl xu xr f(xr) Much faster convergence than the bisection method May be slower than bisection method for some cases

40
**Convergence Rate Why don't we always use false position method?**

There are times it may converge very, very slowly. Example: What other methods can we use?

41
**Convergence slower than bisection method**

1 2 3 2 1 root midpoint

42
**Bisection Method False-Position Method**

» xl = 0; xu = 3; es = ; maxit = 100; » [xr,fr]=bisect2(inline(‘x^4+3*x-4’)) Bisection method has converged step xl xu xr f(x) » xl = 0; xu = 3; es = ; maxit = 100; » [xr,fr]=false_position(inline(‘x^4+3*x-4’)) False position method has converged step xl xu xr f(xr) ….

43
**Example: Rate of Convergence**

» x = -2:0.1:2; y = x.^3-3*x+1; z = x*0; » H = plot(x,y,'r',x,z,'b'); grid on; set(H,'LineWidth',3.0); » xlabel('x'); ylabel('y'); title('f(x) = x^3 - 3x + 1 = 0');

44
**Comparison of rate of convergence for bisection and false-position method**

>> bisect2(inline('x^3-3*x+1')) enter lower bound xl = 0 enter upper bound xu = 1 allowable tolerance es = 1.e-20 maximum number of iterations maxit = 100 exact zero found step xl xu xr f(xr) .. . Continued on next page

45
**Compute relative errors**

>> false_position(inline('x^3-3*x+1')) enter lower bound xl = 0 enter upper bound xu = 1 allowable tolerance es = 1.e-20 maximum number of iterations maxit = 100 exact zero found step xl xu xr f(xr) iter1=length(x1); iter2=length(x2); k1=1:iter1; k2=1:iter2; >> root1=x1(iter1); root2=x2(iter2); >> error1=abs((x1-root1)/root1); error2=abs((x2-root2)/root2); >> H=semilogy(k1,error1,'ro-',k2,error2,'bs-'); set(H,'LineWidth',2.0); >> xlabel('Number of Iterations'); ylabel('Relative Error'); f(x) = x3 – 3x +1 = 0 Compute relative errors

46
Rate of Convergence f(x)= x3 3x + 1 Bisection Method False position

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google