Numerical Methods. Read xl and xu Define the function f(xl)f(xu) : 0 xu = xm Find xm=(xl+xu)/2 Read ε(limit) & max_iteration f(xl)f(xm):0 Ea = |(xm-xmold)*100/xm|

Slides:



Advertisements
Similar presentations
CSE 330: Numerical Methods
Advertisements

Roots of Equations Our first real numerical method – Root finding
Civil Engineering Majors Author(s): Autar Kaw, Jai Paul
ROOTS OF EQUATIONS Student Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 7 Roots of Equations Bracketing Methods.
Chapter 4 Roots of Equations
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 51.
Second Term 05/061 Roots of Equations Bracketing Methods.
Roots of Equations Bracketing Methods.
Dr. Marco A. Arocha Aug,  “Roots” problems occur when some function f can be written in terms of one or more dependent variables x, where the.
Bracketing Methods Chapter 5 The Islamic University of Gaza
8/30/ Secant Method Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
Solving Non-Linear Equations (Root Finding)
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 Roots of Equations Why? But.
Newton-Raphson Method Electrical Engineering Majors Authors: Autar Kaw, Jai Paul Transforming Numerical Methods Education.
Newton-Raphson Method
9/20/ Secant Method Civil Engineering Majors Authors: Autar Kaw, Jai Paul
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
10/21/ Bisection Method Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
Newton-Raphson Method Chemical Engineering Majors Authors: Autar Kaw, Jai Paul Transforming Numerical Methods Education.
Lecture 6 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
Numerical Methods for Engineering MECN 3500
Numerical Methods Part: False-Position Method of Solving a Nonlinear Equation
Numerical Methods.
11/30/ Secant Method Industrial Engineering Majors Authors: Autar Kaw, Jai Paul
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Roots of Equations ~ Bracketing Methods Chapter 5.
Newton-Raphson Method. Figure 1 Geometrical illustration of the Newton-Raphson method. 2.
ROOTS OF EQUATIONS. Bracketing Methods The Bisection Method The False-Position Method Open Methods Simple Fixed-Point Iteration The Secant Method.
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 5 Bracketing Methods.
Solving Non-Linear Equations (Root Finding)
Solution of Nonlinear Equations Topic: Bisection method
Numerical Methods Solution of Equation.
4 Numerical Methods Root Finding Secant Method Modified Secant
1/29/ Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul
2/2/ Secant Method Electrical Engineering Majors Authors: Autar Kaw, Jai Paul
SOLVING NONLINEAR EQUATIONS. SECANT METHOD MATH-415 Numerical Analysis 1.
Newton-Raphson Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul Transforming Numerical Methods Education.
3/7/ Bisection Method Electrical Engineering Majors Authors: Autar Kaw, Jai Paul
Numerical Methods Part: False-Position Method of Solving a Nonlinear Equation
6/13/ Secant Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul
Project on Newton’s Iteration Method Presented by Dol Nath Khanal Project Advisor- Professor Dexuan Xie 05/11/2015.
CSE 330: Numerical Methods. What is true error? True error is the difference between the true value (also called the exact value) and the approximate.
7/11/ Bisection Method Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
Numerical Methods Slide Credit
CSE 330: Numerical Methods. Introduction The bisection and false position method require bracketing of the root by two guesses Such methods are called.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 / Chapter 5.
Newton-Raphson Method
4 Numerical Methods Root Finding Secant Method Modified Secant
Newton-Raphson Method
Bracketing Methods (Bisection Method)
Secant Method.
~ Roots of Equations ~ Bracketing Methods Chapter 5
Lecture 4: Numerical Methods
Secant Method – Derivation
Chemical Engineering Majors Authors: Autar Kaw, Jai Paul
Part 2 / Chapter 5.
Chapter 1: False-Position Method of Solving a Nonlinear Equation
Newton-Raphson Method
Bisection Method.
Newton-Raphson Method
SOLUTION OF NONLINEAR EQUATIONS
Chemical Engineering Majors Authors: Autar Kaw, Jai Paul
ROOTS OF EQUATIONS.
Some Comments on Root finding
Newton-Raphson Method
Mechanical Engineering Majors Authors: Autar Kaw, Jai Paul
MATH 1910 Chapter 3 Section 8 Newton’s Method.
Industrial Engineering Majors Authors: Autar Kaw, Jai Paul
Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
Presentation transcript:

Numerical Methods

Read xl and xu Define the function f(xl)f(xu) : 0 xu = xm Find xm=(xl+xu)/2 Read ε(limit) & max_iteration f(xl)f(xm):0 Ea = |(xm-xmold)*100/xm| xl = xm Ea : ε (limit) Iteration_count : max_iteration Iteration_count++ Print Count, xl, xu, xm, f(xl), f(xm) f(xl)f(xm) & error No convergence Start < > < > > < < > Stop 2 iteration_count=0 xmold = xl Xmold=xm =

% Bisection method for finding the root of a nonlinear equation clc; clear all; f + 6 * x^2 - 7 * x - 60); while 1 xl = input('Enter the value of xl: '); xu = input('Enter the value of xu: '); if (f(xl)*f(xu)<0) disp('The xl and xu encompass atleast one root'); break; end disp ('The xl and xu do not encompass the root'); disp ('Enter a new set'); end maxcount = input('Enter the value of maximum number of count: '); eps = input('Enter the value of epsilon (%): '); count=0; xmold=xl; disp( ' Count Xl Xu Xm f(Xl) f(Xm) fXl*fXm % Error ') 3

while count<maxcount xm=(xl+xu)/2; err=abs((xm-xmold)*100/xm); xmold=xm; Y(1)=count; Y(2)=xl; Y(3)=xu; Y(4)=xm; Y(5)=f(xl); Y(6)=f(xm); Y(7)=Y(5)*Y(6); Y(8)=err; disp (Y); 4 if (f(xl)*f(xm)<0) xu=xm; else xl=xm; end if (abs(f(xl)*f(xm))<1.0e-10) break end if err <= eps break; end count=count+1; end if count == maxcount && err>eps disp ('no convergence'); end

f(x) = x^3 – 4 * x ^2 – x + 4 x l =3.5 and x u = 4.8 RESULT Iteration x m % Error f(x m )

 f(x) = 5 * exp ( -x) -2  Assume x l =0 and x u =2  Calculate x m, % error and f(x m ) for three iterations 6 Iteration X m % Error f(x m )

7 Figure 1

 However, in the example shown in Figure 1, the bisection method may not be efficient because it does not take into consideration that f(x L ) is much closer to the zero of the function f(x) as compared to f(x U )  In other words, the next predicted root x r would be closer to x L (in the example as shown in Figure 1), than the mid-point between x L and x U  The false-position method takes advantage of this observation mathematically by drawing a secant from the function value at x L to the function value at x U and estimates the root as where it crosses the x-axis. 8

 Based on two similar triangles, shown in figure 1, one gets (4)  From equation (4), one obtains  The above equation can be solved to obtain the next predicted root x r as (5) 9

 The equation (5), through simple algebraic manipulations, can also be expressed as (6) or (7). 10

The steps to apply the false-position method to find the root of the equation f(x)=0 are as follows.  Step#1: Choose x L and x U as two guesses for the root such that or in other words f(x) changes sign bet n x L and x U  Step#2: Estimate the root x r of the equation f(x)=0 as  Step #3. Now check the following  If then the root lies between x L and x r  If then the root lies between x U and x r  If then the root is x r. Stop the algorithm. 11

 Step #4: Find the new estimate of the root  Find the absolute relative approximate error as  where x r new = estimated root from present iteration x r old = estimated root from previous iteration 12

 Step # 5. Compare the absolute relative approximate error with the pre-specified relative error tolerance.  If then go to step 3, else stop the algorithm. Note one should also check whether the number of iterations is more than the maximum number of iterations allowed. If so, one needs to terminate the algorithm and notify the user about it.  Note that the false-position and bisection algorithms are quite similar. The only difference is the formula used to calculate the new estimate of the root as shown in steps #2 and #4! 13

IterationxLxL xUxU xrxr f(x m ) X X X10 -7 Table 1 Root of floating ball problem for false-position method 14

 Find the root of using the initial guesses of x L =-2.5 and x U =-1.0 and a pre-specified tolerance of Table 2 Root of for false-position method IterationxLxL xUxU f(x L )f(x U )xrxr f(x r ) N/A

Read x l and x u Define the function f(x l )f(x u ) : 0 x u = x i x i = [x u f(x l )-x l f(x u ]/ [f(x l )-f(x u ) ] A Read E limit & max_iteration f(x l )f(x i ):0 E a = |(x i -x iold )*100/x i | x l = x i E a : E limit Iteration_count : max_iteration Iteration_count++ Print Count, x i & f(x i ) No convergence Start < > < > > < < > Stop 16 iteration_count=0 x iold = x l X iold= x i =

clear all; f (x) (x^2 - 5*x + 6); while 1 xl = input('Enter the value of xl: '); xu = input('Enter the value of xu: '); if (f(xl)*f(xu) < 0) disp('The xl and xu encompass atleast one root'); break; end disp ('The xl and xu do not encompass the root’); disp(‘Enter a new set'); end maxcount = input('Enter the value of maximum number of count: '); eps = input('Enter the value of epsilon (%): '); count = 0; xiold = xl; disp( ' Count Xi Error f(xi)'); while count < maxcount xi=(xu*f(xl) –xl*f(xu))/ (fxl)-f(xu)) ; if (f(xl)*f(xi) < 0) xu = xi; else xl = xi; end err=abs(xi - xiold)*100/xi); xmold = xi; Y(1) = count; Y(2) = xi; Y(3) = err; Y(4)=f(xi); disp (Y); if (abs(f(xl)*f(xi))<1.0e-10) break; end if err < eps break; end count = count+1; end if count == maxcount && err>eps disp ('no convergence'); end 17

18