Solution of Nonlinear Equations ( Root Finding Problems ) Definitions Classification of Methods  Analytical Solutions  Graphical Methods  Numerical.

Slides:



Advertisements
Similar presentations
Engineering Computation
Advertisements

Lecture 5 Newton-Raphson Method
CSE 330: Numerical Methods
Roots of Equations Our first real numerical method – Root finding
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.
Regula-Falsi Method. Type of Algorithm (Equation Solver) The Regula-Falsi Method (sometimes called the False Position Method) is a method used to find.
Engineering Computation
Open Methods Chapter 6 The Islamic University of Gaza
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.
Roots of Equations Open Methods (Part 2).
Chapter 6 Open Methods.
Second Term 05/061 Roots of Equations Bracketing Methods.
A few words about convergence We have been looking at e a as our measure of convergence A more technical means of differentiating the speed of convergence.
Open Methods (Part 1) Fixed Point Iteration & Newton-Raphson Methods
Roots of Equations Bracketing Methods.
Open Methods Chapter 6 The Islamic University of Gaza
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
Roots of Equations Open Methods Second Term 05/06.
Fin500J: Mathematical Foundations in Finance Topic 3: Numerical Methods for Solving Non-linear Equations Philip H. Dybvig Reference: Numerical Methods.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Roots of Equations Chapter 3. Roots of Equations Also called “zeroes” of the equation –A value x such that f(x) = 0 Extremely important in applications.
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.
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
1 Nonlinear Equations Jyun-Ming Chen. 2 Contents Bisection False Position Newton Quasi-Newton Inverse Interpolation Method Comparison.
Lecture 6 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
1 Solution of Nonlinear Equation Dr. Asaf Varol
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 for Engineering MECN 3500
Numerical Methods.
CHAPTER 3 NUMERICAL METHODS
Numerical Methods Root Finding 4. Fixed-Point Iteration---- Successive Approximation Many problems also take on the specialized form: g(x)=x, where we.
Newton’s Method, Root Finding with MATLAB and Excel
Today’s class Roots of equation Finish up incremental search
4 Numerical Methods Root Finding Secant Method Modified Secant
Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002.
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)
Numerical Methods Solution of Equation.
Today’s class Numerical differentiation Roots of equation Bracketing methods Numerical Methods, Lecture 4 1 Prof. Jinbo Bi CSE, UConn.
4 Numerical Methods Root Finding Secant Method Modified Secant
SOLVING NONLINEAR EQUATIONS. SECANT METHOD MATH-415 Numerical Analysis 1.
4 Numerical Methods Root Finding.
Root Finding UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
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.
Numerical Methods and Optimization C o u r s e 1 By Bharat R Chaudhari.
1 M 277 (60 h) Mathematics for Computer Sciences Bibliography  Discrete Mathematics and its applications, Kenneth H. Rosen  Numerical Analysis, Richard.
NUMERICAL ANALYSIS I. Introduction Numerical analysis is concerned with the process by which mathematical problems are solved by the operations.
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.
Solution of Nonlinear Equations ( Root Finding Problems )
Lecture Notes Dr. Rakhmad Arief Siregar Universiti Malaysia Perlis
4 Numerical Methods Root Finding Secant Method Modified Secant
Numerical Methods and Analysis
Newton’s Method for Systems of Non Linear Equations
~ Roots of Equations ~ Bracketing Methods Chapter 5
Lecture 4: Numerical Methods
Read Chapters 5 and 6 of the textbook
Part 2 / Chapter 5.
Computers in Civil Engineering 53:081 Spring 2003
MATH 175: Numerical Analysis II
SOLUTION OF NONLINEAR EQUATIONS
4 Numerical Methods Root Finding.
Mechanical Engineering Majors Authors: Autar Kaw, Jai Paul
1 Newton’s Method.
Solutions for Nonlinear Equations
Presentation transcript:

Solution of Nonlinear Equations ( Root Finding Problems ) Definitions Classification of Methods  Analytical Solutions  Graphical Methods  Numerical Methods  Bracketing Methods (bisection, regula-falsi)  Open Methods (secant, Newton-Raphson, fixed point iteration) Convergence Notations 1

All Iterative 2 Nonlinear Equation Solvers BracketingGraphicalOpen Methods Bisection False Position (Regula-Falsi) Newton Raphson Secant Fixed point iteration

Roots of Equations 3 p = pressure, T = temperature, R = universal gas constant, a & b = empirical constants Thermodynamics: van der Waals equation; v = V/n (= volume/# moles) Find the molecular volume v such that

Roots of Equations 4 Civil Engineering: Find the horizontal component of tension, H, in a cable that passes through (0,y 0 ) and (x, y) w = weight per unit length of cable

Roots of Equations 5 L = inductance, C = capacitance, q 0 = initial charge Electrical Engineering : Find the resistance, R, of a circuit such that the charge reaches q at specified time t

Roots of Equations 6 Mechanical Engineering: Find the value of stiffness k of a vibrating mechanical system such that the displacement x(t) becomes zero at t= 0.5 s. The initial displacement is x 0 and the initial velocity is zero. The mass m and damping c are known, and λ = c/(2m). in which

Root Finding Problems Many problems in Science and Engineering are expressed as: 7 These problems are called root finding problems.

Roots of Equations A number r that satisfies an equation is called a root of the equation. 8

Zeros of a Function Let f(x) be a real-valued function of a real variable. Any number r for which f(r)=0 is called a zero of the function. Examples: 2 and 3 are zeros of the function f(x) = (x-2)(x-3). 9

Graphical Interpretation of Zeros  The real zeros of a function f(x) are the values of x at which the graph of the function crosses (or touches) the x-axis. 10 Real zeros of f(x) f(x)

Simple Zeros 11

Multiple Zeros 12

Multiple Zeros 13

Facts  Any n th order polynomial has exactly n zeros (counting real and complex zeros with their multiplicities).  Any polynomial with an odd order has at least one real zero.  If a function has a zero at x=r with multiplicity m then the function and its first (m-1) derivatives are zero at x=r and the m th derivative at r is not zero. 14

Roots of Equations & Zeros of Function 15

Solution Methods Several ways to solve nonlinear equations are possible:  Analytical Solutions  Possible for special equations only  Graphical Solutions  Useful for providing initial guesses for other methods  Numerical Solutions  Open methods  Bracketing methods 16

Analytical Methods Analytical Solutions are available for special equations only. 17

Graphical Methods  Graphical methods are useful to provide an initial guess to be used by other methods. 18 Root

Numerical Methods Many methods are available to solve nonlinear equations:  Bisection Method  bracketing method  Newton’s Method  open method  Secant Method  open method  False position Method (bracketing method)  Fixed point iterations (open method) Muller’s Method Bairstow’s Method ………. 19

Bracketing Methods  In bracketing methods, the method starts with an interval that contains the root and a procedure is used to obtain a smaller interval containing the root.  Examples of bracketing methods: Bisection method False position method (Regula-Falsi) 20

Open Methods  In the open methods, the method starts with one or more initial guess points. In each iteration, a new guess of the root is obtained.  Open methods are usually more efficient than bracketing methods.  They may not converge to a root. 21

Convergence Notation 22

Convergence Notation 23

Speed of Convergence  We can compare different methods in terms of their convergence rate.  Quadratic convergence is faster than linear convergence.  A method with convergence order q converges faster than a method with convergence order p if q>p.  Methods of convergence order p>1 are said to have super linear convergence. 24

Bisection Method The Bisection Algorithm Convergence Analysis of Bisection Method Examples 25

Introduction  The Bisection method is one of the simplest methods to find a zero of a nonlinear function.  It is also called interval halving method.  To use the Bisection method, one needs an initial interval that is known to contain a zero of the function.  The method systematically reduces the interval. It does this by dividing the interval into two equal parts, performs a simple test and based on the result of the test, half of the interval is thrown away.  The procedure is repeated until the desired interval size is obtained. 26

Intermediate Value Theorem  Let f(x) be defined on the interval [a,b].  Intermediate value theorem: if a function is continuous and f(a) and f(b) have different signs then the function has at least one zero in the interval [a,b]. 27 ab f(a) f(b)

Examples  If f(a) and f(b) have the same sign, the function may have an even number of real zeros or no real zeros in the interval [a, b].  Bisection method can not be used in these cases. 28 ab ab The function has four real zeros The function has no real zeros

Two More Examples 29 ab ab  If f(a) and f(b) have different signs, the function has at least one real zero.  Bisection method can be used to find one of the zeros. The function has one real zero The function has three real zeros

Bisection Method  If the function is continuous on [a,b] and f(a) and f(b) have different signs, Bisection method obtains a new interval that is half of the current interval and the sign of the function at the end points of the interval are different.  This allows us to repeat the Bisection procedure to further reduce the size of the interval. 30

Bisection Method Assumptions: Given an interval [a,b] f(x) is continuous on [a,b] f(a) and f(b) have opposite signs. These assumptions ensure the existence of at least one zero in the interval [a,b] and the bisection method can be used to obtain a smaller interval that contains the zero. 31

Bisection Algorithm Assumptions:  f(x) is continuous on [a,b]  f(a) f(b) < 0 Algorithm: Loop 1. Compute the mid point c=(a+b)/2 2. Evaluate f(c) 3. If f(a) f(c) < 0 then new interval [a, c] If f(a) f(c) > 0 then new interval [c, b] End loop 32 a b f(a) f(b) c

Bisection Method 33 a0a0 b0b0 a1a1 a2a2

Example

Flow Chart of Bisection Method 35 Start: Given a,b and ε u = f(a) ; v = f(b) c = (a+b) /2 ; w = f(c) is u w <0 a=c; u= wb=c; v= w is (b-a) /2<ε yes no Stop no

Example Answer: 36

Example Answer: 37

Best Estimate and Error Level Bisection method obtains an interval that is guaranteed to contain a zero of the function. Questions:  What is the best estimate of the zero of f(x)?  What is the error level in the obtained estimate? 38

Best Estimate and Error Level The best estimate of the zero of the function f(x) after the first iteration of the Bisection method is the mid point of the initial interval: 39

Stopping Criteria Two common stopping criteria  Stop after a fixed number of iterations  Stop when the absolute error is less than a specified value How are these criteria related? 40

Stopping Criteria 41

Convergence Analysis 42

Convergence Analysis – Alternative Form 43

Example 44

Example  Use Bisection method to find a root of the equation x = cos(x) with absolute error <0.02 (assume the initial interval [0.5, 0.9]) 45 Question 1: What is f (x) ? Question 2: Are the assumptions satisfied ? Question 3: How many iterations are needed ? Question 4: How to compute the new estimate ?

46 CISE301_Topic2

Bisection Method Initial Interval 47 a =0.5 c= 0.7 b= 0.9 f(a)= f(b) = Error < 0.2

Bisection Method Error < Error < 0.05

Bisection Method Error < Error <.0125

Summary  Initial interval containing the root: [0.5,0.9]  After 5 iterations: Interval containing the root: [0.725, 0.75] Best estimate of the root is | Error | <

A Matlab Program of Bisection Method a=.5; b=.9; u=a-cos(a); v=b-cos(b); for i=1:5 c=(a+b)/2 fc=c-cos(c) if u*fc<0 b=c ; v=fc; else a=c; u=fc; end 51 c = fc = c = fc = c = fc = c = fc =

Example Find the root of: 52

Example Iterationab c= (a+b) 2 f(c) (b-a) E E E

Bisection Method Advantages  Simple and easy to implement  One function evaluation per iteration  The size of the interval containing the zero is reduced by 50% after each iteration  The number of iterations can be determined a priori  No knowledge of the derivative is needed  The function does not have to be differentiable Disadvantage  Slow to converge  Good intermediate approximations may be discarded 54

Bisection Method (as C function) double Bisect(double xl, double xu, double es, int iter_max) { double xr; // Est. Root double xr_old; // Est. root in the previous step double ea; // Est. error int iter = 0; // Keep track of # of iterations double fl, fr; // Save values of f(xl) and f(xr) xr = xl; // Initialize xr in order to // calculating "ea". Can also be "xu". fl = f(xl); do { iter++; xr_old = xr; xr = (xl + xu) / 2; // Estimate root fr = f(xr); 55

56 if (xr != 0) ea = fabs((xr – xr_old) / xr) * 100; test = fl * fr; if (test < 0) xu = xr; else if (test > 0) { xl = xr; fl = fr; } else ea = 0; } while (ea > es && iter < iter_max); return xr; }

Regula – Falsi Method 57

Regula Falsi Method  Also known as the false-position method, or linear interpolation method.  Unlike the bisection method which divides the search interval by half, regula falsi interpolates f(x u ) and f(x l ) by a straight line and the intersection of this line with the x-axis is used as the new search position.  The slope of the line connecting f(x u ) and f(x l ) represents the "average slope" (i.e., the value of f'(x)) of the points in [x l, x u ]. 58

59

Regula Falsi Method  The regula falsi method start with two point, (a, f(a)) and (b,f(b)), satisfying the condition that f(a)f(b)<0.  The straight line through the two points (a, f(a)), (b, f(b)) is  The next approximation to the zero is the value of x where the straight line through the initial points crosses the x-axis. 60

Example  Finding the Cube Root of 2 Using Regula Falsi  Since f(1)= -1, f(2)=6, we take as our starting bounds on the zero a=1 and b=2.  Our first approximation to the zero is  We then find the value of the function:  Since f(a) and y are both negative, but y and f(b) have opposite signs 61

Example (cont.)  Calculation of using regula falsi. 62

63 Open Methods (a)Bisection method (b)Open method (diverge) (c)Open method (converge) To find the root for f(x) = 0, we construct a magic formulae x i+1 = g(x i ) to predict the root iteratively until x converge to a root. However, x may diverge!

64 What you should know about Open Methods  How to construct the magic formulae g(x) ?  How can we ensure convergence?  What makes a method converges quickly or diverge?  How fast does a method converge?

OPEN METHOD Newton-Raphson Method Assumptions Interpretation Examples Convergence Analysis 65

Newton-Raphson Method (Also known as Newton’s Method) Given an initial guess of the root x 0, Newton- Raphson method uses information about the function and its derivative at that point to find a better guess of the root. Assumptions: f(x) is continuous and the first derivative is known An initial guess x 0 such that f’(x 0 )≠0 is given 66

Newton Raphson Method - Graphical Depiction -  If the initial guess at the root is x i, then a tangent to the function of x i that is f’(x i ) is extrapolated down to the x-axis to provide an estimate of the root at x i+1. 67

Derivation of Newton’s Method 68

Newton’s Method 69

Newton’s Method 70 F.m FP.m

Example 71

Example 72 k ( Iteration ) xkxk f(x k )f’(x k )x k+1 |x k+1 –x k |

Convergence Analysis 73

Convergence Analysis Remarks 74 When the guess is close enough to a simple root of the function then Newton’s method is guaranteed to converge quadratically. Quadratic convergence means that the number of correct digits is nearly doubled at each iteration.

Error Analysis of Newton-Raphson Method Using an iterative process we get x k+1 from x k and other info. We have x 0, x 1, x 2, …, x k+1 as the estimation for the root α. Let δ k = α – x k 75

76 Error Analysis of Newton-Raphson Method By definition Newton-Raphson method

77 Suppose α is the true value (i.e., f(α) = 0 ). Using Taylor's series Error Analysis of Newton-Raphson Method When x i and α are very close to each other, c is between x i and α. The iterative process is said to be of second order.

Problems with Newton’s Method 78 If the initial guess of the root is far from the root the method may not converge. Newton’s method converges linearly near multiple zeros { f(r) = f’(r) =0 }. In such a case, modified algorithms can be used to regain the quadratic convergence.

Multiple Roots 79

Problems with Newton’s Method - Runaway - 80 The estimates of the root is going away from the root. x0x0 x1x1

Problems with Newton’s Method - Flat Spot - 81 The value of f’(x) is zero, the algorithm fails. If f ’(x) is very small then x 1 will be very far from x 0. x0x0

Problems with Newton’s Method - Cycle - 82 The algorithm cycles between two values x 0 and x 1 x 0 =x 2 =x 4 x 1 =x 3 =x 5

Secant Method  Secant Method  Examples  Convergence Analysis 83

Newton’s Method (Review) 84

85 Requires two initial estimates x o, x 1. However, it is not a “bracketing” method. The Secant Method has the same properties as Newton’s method. Convergence is not guaranteed for all x o, f(x). The Secant Method

Secant Method 86

 Notice that this is very similar to the false position method in form  Still requires two initial estimates  This method requires two initial estimates of x but does not require an analytical expression of the derivative.  But it doesn't bracket the root at all times - there is no sign test 87

88

Secant Method 89

Secant Method 90

Secant Method - Flowchart 91 Stop NO Yes

Modified Secant Method 92

Example 93

Example x(i)f(x(i))x(i+1)|x(i+1)-x(i)|

Convergence Analysis  The rate of convergence of the Secant method is super linear:  It is better than Bisection method but not as good as Newton’s method. 95

OPEN METHOD Fixed Point Iteration 96

97 Fixed Point Iteration  Also known as one-point iteration or successive substitution  To find the root for f(x) = 0, we reformulate f(x) = 0 so that there is an x on one side of the equation. If we can solve g(x) = x, we solve f(x) = 0. –x is known as the fixed point of g(x). We solve g(x) = x by computing until x i+1 converges to x.

98 Fixed Point Iteration – Example Reason: If x converges, i.e. x i+1  x i

99 Example Find root of f(x) = e -x - x = 0. (Answer: α= ) ixixi ε a (%)ε t (%)

100 Fixed Point Iteration  There are infinite ways to construct g(x) from f(x). For example, So which one is better? (ans: x = 3 or -1 ) Case a:Case b:Case c:

101 1.x 0 = 4 2.x 1 = x 2 = x 3 = x 4 = x 5 = x 0 = 4 2.x 1 = x 2 = -6 4.x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x 0 = 4 2.x 1 = x 2 = x 3 = Converge! Converge, but slower Diverge!

102 Fixed Point Iteration Impl. (as C function) // x0: Initial guess of the root // es: Acceptable relative percentage error // iter_max: Maximum number of iterations allowed double FixedPt(double x0, double es, int iter_max) { double xr = x0; // Estimated root double xr_old; // Keep xr from previous iteration int iter = 0; // Keep track of # of iterations do { xr_old = xr; xr = g(xr_old); // g(x) has to be supplied if (xr != 0) ea = fabs((xr – xr_old) / xr) * 100; iter++; } while (ea > es && iter < iter_max); return xr; }

Comparison of Root Finding Methods  Advantages/disadvantages  Examples 103

Summary MethodProsCons Bisection- Easy, Reliable, Convergent - One function evaluation per iteration - No knowledge of derivative is needed - Slow - Needs an interval [a,b] containing the root, i.e., f(a)f(b)<0 Newton- Fast (if near the root) - Two function evaluations per iteration - May diverge - Needs derivative and an initial guess x0 such that f’(x0) is nonzero Secant- Fast (slower than Newton) - One function evaluation per iteration - No knowledge of derivative is needed - May diverge - Needs two initial points guess x0, x1 such that f(x0)- f(x1) is nonzero 104

Example 105

Solution _______________________________ k x k f(x k ) _______________________________

Example 107

Five Iterations of the Solution k x k f(x k ) f’(x k ) ERROR ______________________________________

Example 109

Example 110

Example Estimates of the root of: x-cos(x)= Initial guess correct digit correct digits correct digits correct digits 111

Example In estimating the root of: x-cos(x)=0, to get more than 13 correct digits:  4 iterations of Newton (x 0 =0.8)  43 iterations of Bisection method (initial interval [0.6, 0.8])  5 iterations of Secant method ( x 0 =0.6, x 1 =0.8) 112