TWO METHODS FOR OF EQUATIONS

Similar documents
CE 205 Numerical Methods. Some of the analysis methods you have used so far.. Algebra Calculus Differential Equations etc.

Solution of Algebric & Transcendental Equations

MATH 3795 Lecture 12. Numerical Solution of Nonlinear Equations.

Numerical Solution of f(x) = 0

SOLVING EQUATIONS OF ONE VARIABLE

cha1873x_p02.qxd 3/21/05 1:01 PM Page 104 PART TWO

Finding the Roots of f(x) = 0. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Finding the Roots of f(x) = 0

Numerical Analysis Fall. Roots: Open Methods

Analysis Methods in Atmospheric and Oceanic Science

Numerical Methods School of Mechanical Engineering Chung-Ang University

Numerical Methods. Roots of Equations

Numerical Methods Lecture 3

Analysis Methods in Atmospheric and Oceanic Science

Root Finding (and Optimisation)

Lecture 8. Root finding II

Chapter 5 Roots of Equations: Bracketing Models. Gab-Byung Chae

Queens College, CUNY, Department of Computer Science Numerical Methods CSCI 361 / 761 Spring 2018 Instructor: Dr. Sateesh Mane.

Math Numerical Analysis Mid-Term Test Solutions

Therefore, the root is in the second interval and the lower guess is redefined as x l = The second iteration is

Bisection and False Position Dr. Marco A. Arocha Aug, 2014

6.1 The function can be set up for fixed-point iteration by solving it for x

CS 221 Lecture 9. Tuesday, 1 November 2011

CHAPTER 4 ROOTS OF EQUATIONS

NUMERICAL METHODS. x n+1 = 2x n x 2 n. In particular: which of them gives faster convergence, and why? [Work to four decimal places.

MATH 350: Introduction to Computational Mathematics

PART I Lecture Notes on Numerical Solution of Root Finding Problems MATH 435

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

3.1 Introduction. Solve non-linear real equation f(x) = 0 for real root or zero x. E.g. x x 1.5 =0, tan x x =0.

NUMERICAL AND STATISTICAL COMPUTING (MCA-202-CR)

Root finding. Eugeniy E. Mikhailov. Lecture 06. The College of William & Mary. Eugeniy Mikhailov (W&M) Practical Computing Lecture 06 1 / 10

Zeroes of Transcendental and Polynomial Equations. Bisection method, Regula-falsi method and Newton-Raphson method

Root finding. Root finding problem. Root finding problem. Root finding problem. Notes. Eugeniy E. Mikhailov. Lecture 05. Notes

Chapter 3 Solving Nonlinear Equations

Numerical Methods I Solving Nonlinear Equations

MATH 350: Introduction to Computational Mathematics

Lecture 5: Random numbers and Monte Carlo (Numerical Recipes, Chapter 7) Motivations for generating random numbers

GENG2140, S2, 2012 Week 7: Curve fitting

Root finding. Eugeniy E. Mikhailov. Lecture 05. The College of William & Mary. Eugeniy Mikhailov (W&M) Practical Computing Lecture 05 1 / 10

Numerical Methods. Root Finding

MATH 3795 Lecture 13. Numerical Solution of Nonlinear Equations in R N.

INTRODUCTION TO NUMERICAL ANALYSIS

Lecture Notes to Accompany. Scientific Computing An Introductory Survey. by Michael T. Heath. Chapter 5. Nonlinear Equations

Scientific Computing. Roots of Equations

Outline. Scientific Computing: An Introductory Survey. Nonlinear Equations. Nonlinear Equations. Examples: Nonlinear Equations

Midterm Review. Igor Yanovsky (Math 151A TA)

Scientific Computing: An Introductory Survey

Lecture 7. Root finding I. 1 Introduction. 2 Graphical solution

Optimization and Calculus

CS 450 Numerical Analysis. Chapter 5: Nonlinear Equations

Roots of Equations. ITCS 4133/5133: Introduction to Numerical Methods 1 Roots of Equations

1 The best of all possible worlds

x x2 2 + x3 3 x4 3. Use the divided-difference method to find a polynomial of least degree that fits the values shown: (b)

Nonlinearity Root-finding Bisection Fixed Point Iteration Newton s Method Secant Method Conclusion. Nonlinear Systems

Root Finding: Close Methods. Bisection and False Position Dr. Marco A. Arocha Aug, 2014

Outline. Math Numerical Analysis. Intermediate Value Theorem. Lecture Notes Zeros and Roots. Joseph M. Mahaffy,

Variable. Peter W. White Fall 2018 / Numerical Analysis. Department of Mathematics Tarleton State University

Math Numerical Analysis

Edexcel GCE Further Pure Mathematics (FP1) Required Knowledge Information Sheet. Daniel Hammocks

Lecture 7: Numerical Tools

Finding Roots of Equations

BSM510 Numerical Analysis

CS412: Introduction to Numerical Methods

Two hours. To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER. 29 May :45 11:45

Instructor: Marios M. Fyrillas HOMEWORK ASSIGNMENT ON NUMERICAL SOLUTION OF NONLINEAR EQUATIONS

Investigating Limits in MATLAB

Computational Methods CMSC/AMSC/MAPL 460. Solving nonlinear equations and zero finding. Finding zeroes of functions

STOP, a i+ 1 is the desired root. )f(a i) > 0. Else If f(a i+ 1. Set a i+1 = a i+ 1 and b i+1 = b Else Set a i+1 = a i and b i+1 = a i+ 1

1.1: The bisection method. September 2017

THE SECANT METHOD. q(x) = a 0 + a 1 x. with

Some MATLAB Programs and Functions. Bisection Method

Review. Numerical Methods Lecture 22. Prof. Jinbo Bi CSE, UConn

COURSE Numerical integration of functions

Preliminary Examination in Numerical Analysis

Solving nonlinear equations (See online notes and lecture notes for full details) 1.3: Newton s Method

Chapter 4. Solution of a Single Nonlinear Algebraic Equation

Curve Fitting. Objectives

Is the Hénon map chaotic

9.5. Polynomial and Rational Inequalities. Objectives. Solve quadratic inequalities. Solve polynomial inequalities of degree 3 or greater.

Applied Mathematics Letters. Combined bracketing methods for solving nonlinear equations

Math Introduction to Numerical Methods - Winter 2011 Homework 2 Assigned: Friday, January 14, Due: Thursday, January 27,

Virtual University of Pakistan

(f(x) P 3 (x)) dx. (a) The Lagrange formula for the error is given by

NON-LINEAR ALGEBRAIC EQUATIONS Lec. 5.1: Nonlinear Equation in Single Variable

Chapter 3: Root Finding. September 26, 2005

INTRODUCTION, FOUNDATIONS

Lecture 7: Minimization or maximization of functions (Recipes Chapter 10)

Jim Lambers MAT 460/560 Fall Semester Practice Final Exam

BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination December, 2015 BCS-054 : COMPUTER ORIENTED NUMERICAL TECHNIQUES

Roots of equations, minimization, numerical integration

CS 323: Numerical Analysis and Computing

SBAME CALCULUS OF FINITE DIFFERENCES AND NUMERICAL ANLAYSIS-I Units : I-V

Math 473: Practice Problems for Test 1, Fall 2011, SOLUTIONS

CS 323: Numerical Analysis and Computing

Numerical Analysis MTH603

LECTURE 16 GAUSS QUADRATURE In general for Newton-Cotes (equispaced interpolation points/ data points/ integration points/ nodes).

Nonlinearity Root-finding Bisection Fixed Point Iteration Newton s Method Secant Method Conclusion. Nonlinear Systems

The roots are found with the following two statements. We have denoted the polynomial as p1, and the roots as roots_ p1.

5. Hand in the entire exam booklet and your computer score sheet.

ASSIGNMENT BOOKLET. Numerical Analysis (MTE-10) (Valid from 1 st July, 2011 to 31 st March, 2012)

Transcription:

TWO METHODS FOR FINDING ROOTS OF EQUATIONS Closed (Bracketing) Methods Open Methods

Motivation: i In engineering applications, it is often necessary to determine the rootofan of equation when a formula does not exist to yield an explicit solution. Example: Determine the formula for x, given a quadratic equation, 2 ax bx c + + = 0 Here there is a formula that can be derived for the explicit value of x, x = ± 2 b b 4ac 2a

Often, however, the unknown cannot be evaluated explicitly. We say that variable is implicit in the equation and that the equation is transcendental. Example: cos x x= 0 also stated as f ( x) = cos x x Note that we cannot rearrange this equation to obtain an explicit expression for x.

How can we determine the value of x that will satisfy the transcendental equation? Numerical procedures can be used to determine the roots of a transcendental equation. Two categories of numerical methods for determining the roots : Bracketing methods. Open methods.

Bracketing Methods f(x) x x l x r Strategy 1 Choose a range of x x < x < x that contains a root 1. Choose a range of x, x l < x < x r, that contains a root, f(x) = 0. Note that f(x l ) * f(x r ) < 0.

2. Divide the range into two ranges. f(x) x l x m x r x 3. Test one of the ranges for the existence of a root, f x f x ( ) ( )? <?0 l m

f(x) x l x m x r x 4. If f(x l ) * f(x m ) > 0 (as it is in the figure above), the root lies in the range, x m < x < x r, and x l becomes x m ; otherwise, the root lies in the range, x m < x < x r, and x r becomes x m. 5. Repeat procedures 2 through 4 until x r x <ε x = l ( x + x ) l r 2

Example Problem Find the root of f ( ) sin Solution: f x = x x In order to get a rough estimate of the location of the root, plot x versus f(x). >> x = linspace(0,1); >> fx = sin(sqrt(x)) x; >> plot(x,fx) >> grid on >> From the plot, we can see that the root lies in the range, 0.5 < x < 1.0

Bisection method Divide the selected range into two equal sized ranges, x m = (0.5 + 1.0)/ 2 = 0.75 Test the left range for a root, ( ) ( ) ( ) l ( ) f ( ) i ( ) m f x = f 0.5 = sin 0.5 0.5 = 0.1496 f x = f 0.75 = sin 0.75 0.75 = 0.0118 f x f x ( ) ( ) = 0.0018 l m

Since the product is positive, ii the root does not lie in the left range; therefore, it lies in the right range and, x l = x m. The search range has been reduced to 0.75 < x < 1.0 Repeat the procedure using MATLAB tillthe the range has been narrowed to less than 0.001. >> f = @(x) sin(sqrt(x)) x; >> f(xl)*f(xm) f(xm) ans = 8.2502e 004 >> xl = 0.75; >> xr = 1.00; >> xm = (xl + xr)/2; >> f = @(x) sin(sqrt(x)) x; >> f(xl)*f(xm) f(xm) ans = 8.2502e 004 >> xr = xm; >> xm = (xl + xr)/2; >> f(xl)*f(xm) ans = 3.3294e 004 >> xr = xm; >> xm = (xl + xr)/2; >> f(xl)*f(xm) ans = 9.4581e 005 >> xroot = (xl+xm)/2 xroot = 0.7656 Test the solution, >> % test >> f(xroot) ans = 0.0019

Programmingthebisection method The bisection method is seen to be an effective strategy to determine the root of an equation, but the hand calculations to compute the answer are time consuming. Let s see how to create an m file that will automatically do our work, and how call the m file to solve the problem.

function [xr, ea, iter] = divide_and_conquer(f, xl, xu, tol) ea = 100; iter = 0; fxl = f(xl); fxu = f(xu); while ea > tol iter = iter + 1; xr = (xl+xu)/2; % bisection method %xr = xu (fxu*(xl xu)) ( / (fxl fxu); % false position method if f(xr)*f(xu)< 0 % conditional statement xl = xr; fxl = f(xl); else xu = xr; fxu = f(xu); end if iter > 100 % safety valve in case no root exists at all ea = 1; else ea = abs((xu xl)/xr); end end

Launch the routine from MATLAB >> f = @(x) sin(sqrt(x)) x; >> xl = 0.5; >> xu = 1.0; >> tol = 0.0000001; >> [xr, ea, iter] = divide_and_conquer(f, xl, xu, tol) xr = 0.7686 ea = 7.7545e 008 iter = 23 >> % test >> f(xr) ans = 3.4000e 008

False position method Another bracketing method is known as the false position method in which the bisection step, xr = (xl+xu)/2; % bisection method, is replaced by an interpolation, xr = xu (fxu*(xl xu)) / (fxl fxu); % false position method xl xm xu

Modify the code using the false position method and solve the root finding problem. %xr = (xl+xu)/2; % bisection method xr = xu (fxu*(xl xu)) / (fxl fxu); % false position method >> f = @(x) sin(sqrt(x)) x; >> xl = 0.5; >> xu = 1.0; 10; >> tol = 0.0000001; >> [xr, ea, iter] = divide_and_conquer(f, xl, xu, tol) xr = 0.7686 ea = 2.8888e 016 iter = 15 Note that only 15 iterations were needed vs. 23.

Open Methods Newton Raphson (Newton s) Method Derivation using Taylor s series [ n ( ) ] ( ) ( ) ( ) n df xi df xi xi+ 1 xi f ( xi+ 1) = f ( xi) + xi+ 1 xi +... + +... [ n dx ] dx n! Truncate the series, df ( x ) ( ) ( ) + i ( ) f x + 1 f x x + 1 x dx i i i i

Recall that we are looking for x i+1 such that f(x i+1 ) = 0, so 0 ( xi ) ( ) df x f ( x ) + i x + 1 x dx i i i Rearrange to get an expression for x i+1, ( i) ( ) i 1 i ; + i i ( ) f x df x x x where f ( x ) = f x dx i Which is known as Newton s method.

Example Problem Find the root of ( ) sin ( ) f x = x x cos( x ) First derivative of f: f ( x ) = 1 2 x Newton s method becomes: x i+ 1 ( x ) i ( x ) i sin xi = xi cos 2 xi 1

Iteratively ti update dt x i using MATLAB >> f = @(x) sin(sqrt(x)) x; >> fprime = @(x)cos(sqrt(x))./(2*sqrt(x)) () (q ())/( q ()) 1; x = 0.5000; >> x = x f(x)/fprime(x) x = 0.8236 >> x = x f(x)/fprime(x) x = 0.7697 >> x = x f(x)/fprime(x) x = 0.7686 Note that finding the root to 4 places only took 3 iterations.

Secant tmthd Method Another open method to be used when f (x) is difficult or impossible to determine. Derivation Approximate f (x) using a finite difference, ( ) ( ) df f x i f x f ( x) = dx x x i i 1 i 1 Substitute into Newton s method, x i+ 1 f ( xi)( xi xi 1) xi f ( x ) f ( x ) f xi f xi 1

Example Problem Using the secant method, determine the root of, With MATLAB ( ) sin ( ) f x = x x >> f = @(x) sin(sqrt(x)) x; >> x0 =.5; >> x1 = 1.0; >> x2 = x1 f(x1)*(x1 x0)/(f(x1) f(x0)) >> x0 = x1; >> x1 = x2; >> x2 = x1 f(x1)*(x1 x0)/(f(x1) f(x0)) x2 = 0.7667 x2 = 0.7428 >> x0 = x1; >> x1 = x2; >> x2 = x1 f(x1)*(x1 x0)/(f(x1) f(x0)) x2 = 0.7687

Another Example Problem (from Cengal and Boles, example 16.4) Determine x: x 5 16.461 = 1 2 13.5 x 2 ( 3 x)( 2.5 x 2) 1 2 f ( x) x 5 = 16.461 1 2 x x 13.5 x 2 ( 3 x )( 2.5 x 2 ) 1 2 Now, find x such that f(x) = 0.

Using MATLAB Plot x vs. f(x) >> x = linspace(0,2.9); >> f = @(x)16.461 (x./((3 x).*(2.5 x/2).^.5))./(5./(13.5 x/2)).^.5; >> fx = f(x); >> grid on >> plot(x,fx) >> hold on >> x = linspace(3.1,4); >> fx = f(x); >> plot(x,fx) >> grid on

Secant Method >> x0 = 1.5; >> x1 = 2.0; 20; >> x2 = x1 f(x1)*(x1 x0)/(f(x1) f(x0)) x2 = 7.0474 >> x0 = x1; >> x1 = x2; >> x2 = x1 f(x1)*(x1 x0)/(f(x1) f(x0)) x2 = Note that for this case, the secant is clearly diverging, and will never reach the correct solution Motto of the story: 12.3827 13.5411i Not every numerical method will work with every problem.

MATLAB function for finding roots, fzero FromMATLAB help facility fzero Find zero of a function of one variable Syntax x = fzero(fun,x0) MATLAB example >> f = @(x) 16.461 (x/((3 x)*(2.5 x/2)^.5))/(5/(13.5 x/2))^.5; >> x0 = 1; >> x = fzero(f,x0) x = 2.7541

MATLAB function for finding roots of polynomials, roots Consider an n th degree polynomial n n 1 1 cx 1 + cx 2 +... + cx n + c n + 1 = 0 TheMATLAB function, roots, will factor the polynomial (find the zeros) = [ ] c c c c... c n c n+ r 1 2 3 1 ( ) = roots c

Note that r is a row vector of length n, such that, Example ( x r )( x r )( x r ) ( x r )( x r )... = 0 1 2 3 n 1 4 3 2 x x x x 23 + 185 601 + 630 = 0 >> p = [1 23 185 601 630] p = 1 23 185 601 630 >> r = roots(p) r = 9.0000 7.0000 5.0000 2.0000 n

Also note >> r = [2 5 7 9]; >> p = poly(r) p = 1 23 185 601 630 Which h relates the factored version to the polynomial. l ( )( )( )( ) 4 3 2 x 2 x 5 x 7 x 9 = x 23x + 185x 601x+ 630 = 0