CSE 330: Numerical Methods. Introduction The bisection and false position method require bracketing of the root by two guesses Such methods are called.

Slides:



Advertisements
Similar presentations
CSE 330: Numerical Methods
Advertisements

Open Methods Chapter 6 The Islamic University of Gaza
ROOTS OF EQUATIONS Student Notes ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier.
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|
Open Methods Chapter 6 The Islamic University of Gaza
Nonlinear Equations Your nonlinearity confuses me “The problem of not knowing what we missed is that we believe we haven't missed anything” – Stephen Chew.
Chapter 4 Roots of Equations
Open Methods (Part 1) Fixed Point Iteration & Newton-Raphson 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.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 8 Roots of Equations Open Methods.
Roots of Equations Open Methods Second Term 05/06.
FP1: Chapter 2 Numerical Solutions of Equations
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
Numerical Methods Applications of Loops: The power of MATLAB Mathematics + Coding 1.
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.
Chapter 3 Roots of Equations. Objectives Understanding what roots problems are and where they occur in engineering and science Knowing how to determine.
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
Newton’s Method, Root Finding with MATLAB and Excel
Case Study #1 Finding Roots of Equations ~ CE402 Numerical Methods for Engineers Dr. Fritz Fiedler ~ Andy Abrams David Crosby Zack Munstermann.
Today’s class Roots of equation Finish up incremental search
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.
Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002.
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.
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
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 / Chapter 5.
Newton-Raphson Method
Newton-Raphson Method
Secant Method.
Secant Method – Derivation
Chemical Engineering Majors Authors: Autar Kaw, Jai Paul
Solution of Equations by Iteration
Chapter 1: False-Position Method of Solving a Nonlinear Equation
Newton-Raphson Method
Computers in Civil Engineering 53:081 Spring 2003
Bisection Method.
Newton-Raphson Method
SOLUTION OF NONLINEAR EQUATIONS
Chemical Engineering Majors Authors: Autar Kaw, Jai Paul
ROOTS OF EQUATIONS.
Newton’s Method and Its Extensions
Newton-Raphson Method
Mechanical Engineering Majors Authors: Autar Kaw, Jai Paul
Copyright © Cengage Learning. All rights reserved.
MATH 1910 Chapter 3 Section 8 Newton’s Method.
Industrial Engineering Majors Authors: Autar Kaw, Jai Paul
1 Newton’s Method.
Major: All Engineering Majors Authors: Autar Kaw, Jai Paul
Presentation transcript:

CSE 330: Numerical Methods

Introduction The bisection and false position method require bracketing of the root by two guesses Such methods are called bracketing methods These methods are always convergent since they are based on reducing the interval between the two guesses In the Newton-Raphson method, the root is not bracketed. In fact, only one initial guess is needed to start the iterative process and to find the root of an equation This falls in the category of open methods Convergence in open methods is not guaranteed but if the method does converge, it does so faster than bracketing methods 2

Derivation of Newton-Raphson Method The Newton-Raphson method is based on the principle that if the initial guess of the root of f(x) =0 is at x i then if one draws the tangent to the curve at f(x i ), the point x i+1 where the tangent crosses the x -axis is an improved estimate of the root (see figure below) 3 f (x) f (x i ) f (x i+1 ) x i+2 x i+1 x i x θ [x i, f (x i )] C A B

Derivation of Newton-Raphson Method (continued) Using the definition of the slope of a function, at x=x i = AB/BC which gives (1) 4

Newton Raphson’s Method Equation (1) is called the Newton-Raphson formula for solving nonlinear equations of the form f ( x )=0 So, starting with an initial guess, x i, one can find the next guess x i+1 One can repeat this process until one finds the root within a desirable tolerance 5

Algorithm of Newton-Raphson Method The steps of the Newton-Raphson method to find the root of an equation f(x) are as follow: Step #1: Evaluate f’(x) symbolically Step #2: Use an initial guess of the root, x i to estimate the new value of the root, x i+1 as Step #3: Find the absolute relative approximate error as Step #4: Compare the absolute relative approximate error with the pre-specified relative error tolerance, Step #5: If > then go to Step 2, else stop the process. Also, check if the number of iterations has exceeded the maximum number of iterations allowed. If so, one needs to terminate the algorithm and notify the user. 6

Example 1 The equation that gives the depth in meters to which the ball is submerged under water is given by Use the Newton-Raphson method to obtain the depth to which the ball is submerged under water. Conduct three iterations to estimate the root of the above equation. the absolute relative approximate error at the end of each iteration 7

Solution to example 1 Let us assume the initial guess of the root of f(x)= 0 is x 0 =0.05 m. Iteration 1 The estimate of the root is The absolute relative approximate error at the end of Iteration 1 is 8

Solution to example 1 (continued) Iteration 2 The estimate of the root is The absolute relative approximate error at the end of Iteration 2 is Iteration 3 The estimate of the root is x 3 = The absolute relative approximation error at the end of iteration 3 is 0. 9

Drawbacks of the Newton-Raphson Method 1. Divergence at inflection points If the initial guess or an iterated value turns out to be close to the inflection point of the function f(x) in the equation f(x)=0, the solution may start diverging away from the root. It may then start converging back to the root. For example, to find the root of the equation the Newton-Raphson’s method reduces to Starting with an initial guess of x 0 =5.0, the next slide shows the iterated values of the root of the equation. 10

Table 1: Divergence near inflection point Iteration xixi – – – – – – – – – As you can observe, the root starts to diverge at Iteration 6 because the previous estimate of is close to the inflection point of x=1 (the value of f’(x) is zero at the inflection point). Eventually, after 12 more iterations the root converges to the exact value of x=0.2

Figure 3 Divergence at inflection point for 12

Drawbacks of the Newton- Raphson Method (continued) 2. Division by zero For the equation the Newton-Raphson method reduces to For x i = 0 or x i = 0.02, division by zero occurs For an initial guess close to 0.02 such as x 0 = , one may avoid division by zero, but then the denominator in the formula is a small number. For this case, as given in Table in the next slide, even after 9 iterations, the Newton-Raphson method does not converge. 13

Figure 4 Pitfall of division by zero or a near zero number 14

Table 2 Division by near zero in Newton-Raphson method Iteration Number – – – – – – – – – – – – – – – – –

Drawbacks of the Newton- Raphson Method (continued) 3. Oscillations near local maximum and minimum Results obtained from the Newton-Raphson method may oscillate about the local maximum or minimum without converging on a root but converging on the local maximum or minimum Eventually, it may lead to division by a number close to zero and may diverge For example, for the equation has no real roots (Figure 5 and Table 3). 16

Table 3 Oscillations near local maxima and minima in Newton-Raphson method 17 Iteration Number – –1.75 – –

Figure 5 Oscillations around local minima for 18

Drawbacks of the Newton- Raphson Method (continued) 4. Root jumping In some case where the function f(x) is oscillating and has a number of roots, one may choose an initial guess close to a root. However, the guesses may jump and converge to some other root. For example for solving the equation sinx = 0 if you choose as an initial guess, it converges to the root of x = 0 as shown in Table 4 and Figure 6. However, one may have chosen this as an initial guess to converge to 19

Table 4 Root jumping in Newton- Raphson method Iteration Number – – –

Figure 6 Root jumping from intended location of root for 21

Flow Chart of Newton Rapshon’s Method 22 Read x i Define the function, f(x) & its first derivative, f1(x) x i+1 = x i - f(x i ) / f1(x i ) A Read E limit & max_iteration E a = |(x i+1 -x i )*100/x i | E a : E limit Iteration_count : max_iteration Iteration_count++ Print Count, x i+1 & E a No convergence Start > < < > Stop iteration_count=0 x i = x i+1

Matlab code for NR method % Finding a root of a nonlinear equation using Newton Raphson's Method clc; clear all; (x) (2*x^3+7*x^2-14*x+5); (x) (6*x^2+14*x-14); xi = input('Enter the initial value of xi: '); maxcount = input('Enter the value of maximum number of count: '); eps = input('Enter the value of epsilon (%): '); count=0; disp( ' Count Xm error '); 23 while count<maxcount xi1=xi-f(xi)/f1(xi); err = abs ( (xi1 - xi) * 100 / xi1); xi=xi1; Y(1)=count; Y(2)=xi1; Y(3)=err; disp (Y); if err <= eps break; end count=count+1; end if count == maxcount && err>eps disp ('no convergence'); end

What is the secant method and why would I want to use it instead of the Newton-Raphson method? The Newton-Raphson method of solving a nonlinear equation f(x)=0 is given by the iterative formula (1) One of the drawbacks of the Newton-Raphson method is that you have to evaluate the derivative of the function. It can be a laborious process, and even intractable if the function is derived as part of a numerical scheme. To overcome these drawbacks, the derivative of the function, is approximated as (2) 24

Derivation of Secant Method Substituting Equation (2) in Equation (1) gives (3) The above equation is called the secant method. This method now requires two initial guesses, but unlike the bisection method, the two initial guesses do not need to bracket the root of the equation. The secant method is an open method and may or may not converge. However, when secant method converges, it will typically converge faster than the bisection method. However, since the derivative is approximated as given by Equation (2), it typically converges slower than the Newton-Raphson method. 25

Figure 1 Geometrical representation of the secant method 26 f ( x ) f ( x i ) f ( x i–1 ) x i+1 x i–1 x i x B C AD E

Derivation of Secant Method (continued) The secant method can also be derived from geometry, as shown in Figure 1. Taking two initial guesses, one draws a straight line between and passing through the x -axis at x i. ABE and DCE are similar triangles. Hence On rearranging, the secant method is given as 27

Apply Secant Method in the floating ball problem Let us assume the initial guesses of the root of f(x)=0 as x _1 =0.02 and x 0 =

Secant Method: Floating ball problem (continued) The absolute relative approximate error at the end of Iteration 1 is As you need an absolute relative approximate error of 5% or less so you need more iteration to carry on. Iteration 2 The absolute relative approximate error at the end of Iteration 2 is 3.525%. 29

Iteration 3 for the floating ball problem (Secant Method) X 3 = The absolute relative approximate error at the end of Iteration 3 is % Table 1 shows the secant method calculations for the results from the above problem. Table 1: Secent Method Result as Function of Iteration 30 Iteration Number, I X X X X10 -13

31 Read x i-1 and x i Define the function, f(x) A Read E limit & max_iteration E a = |(x i+1 -x i )*100/x i | E a : E limit Iteration_count : max_iteration Iteration_count++ Print Count, x i+1 & E a No convergence Start > < < > Stop 31 Prof. S. M. Lutful Kabir, BRAC University iteration_count=0 x i = x i+1

Thanks 32