INTRODUCTION TO NUMERICAL ANALYSIS

Similar documents
CHAPTER-II ROOTS OF EQUATIONS

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

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

Numerical Solution of f(x) = 0

Solution of Algebric & Transcendental Equations

Solution of Nonlinear Equations

Numerical Methods. Root Finding

SOLVING EQUATIONS OF ONE VARIABLE

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

Finding the Roots of f(x) = 0

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

Numerical Analysis Fall. Roots: Open Methods

SOLUTION OF ALGEBRAIC AND TRANSCENDENTAL EQUATIONS BISECTION METHOD

Figure 1: Graph of y = x cos(x)

Chapter 1. Root Finding Methods. 1.1 Bisection method

Numerical Methods Lecture 3

Determining the Roots of Non-Linear Equations Part I

Scientific Computing: An Introductory Survey

MATH 3795 Lecture 12. Numerical Solution of Nonlinear Equations.

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

Solving Non-Linear Equations (Root Finding)

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

Root Finding (and Optimisation)

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

Practical Numerical Analysis: Sheet 3 Solutions

Numerical Methods

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

15 Nonlinear Equations and Zero-Finders

Lecture 44. Better and successive approximations x2, x3,, xn to the root are obtained from

p 1 p 0 (p 1, f(p 1 )) (p 0, f(p 0 )) The geometric construction of p 2 for the se- cant method.

Scientific Computing. Roots of Equations

CS 450 Numerical Analysis. Chapter 5: Nonlinear Equations

A Review of Bracketing Methods for Finding Zeros of Nonlinear Functions

1. Method 1: bisection. The bisection methods starts from two points a 0 and b 0 such that

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

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 Analysis: Solving Nonlinear Equations

NUMERICAL AND STATISTICAL COMPUTING (MCA-202-CR)

Halley s Method: A Cubically Converging. Method of Root Approximation

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

Numerical Methods I Solving Nonlinear Equations

Chapter 4. Solution of Non-linear Equation. Module No. 1. Newton s Method to Solve Transcendental Equation

Numerical Methods. Roots of Equations

Chapter 3: Root Finding. September 26, 2005

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

Math Numerical Analysis

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

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

Motivation: We have already seen an example of a system of nonlinear equations when we studied Gaussian integration (p.8 of integration notes)

Today s class. Numerical differentiation Roots of equation Bracketing methods. Numerical Methods, Fall 2011 Lecture 4. Prof. Jinbo Bi CSE, UConn

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

10.3 Steepest Descent Techniques

CHAPTER 4 ROOTS OF EQUATIONS

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

Finding Roots of Equations

ROOT FINDING REVIEW MICHELLE FENG

Solving Nonlinear Equations

Root Finding Methods

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

x 2 x n r n J(x + t(x x ))(x x )dt. For warming-up we start with methods for solving a single equation of one variable.

Lecture 8. Root finding II

Goals for This Lecture:

Lecture 8: Optimization

Homework 2 solutions

Solutions of Equations in One Variable. Newton s Method

MATH 350: Introduction to Computational Mathematics

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

Chapter 6. Nonlinear Equations. 6.1 The Problem of Nonlinear Root-finding. 6.2 Rate of Convergence

Line Search Methods. Shefali Kulkarni-Thaker

Numerical Methods in Physics and Astrophysics

Numerical solutions of nonlinear systems of equations

MATH 350: Introduction to Computational Mathematics

Nonlinear Equations. Chapter The Bisection Method

A short presentation on Newton-Raphson method

Numerical Methods in Physics and Astrophysics

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

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

Optimization and Calculus

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

Numerical Methods Dr. Sanjeev Kumar Department of Mathematics Indian Institute of Technology Roorkee Lecture No 7 Regula Falsi and Secant Methods

NOTES FOR NUMERICAL METHODS MUHAMMAD USMAN HAMID

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

Computational Methods. Solving Equations

Chapter 4. Solution of a Single Nonlinear Algebraic Equation

Applied Mathematics Letters. Combined bracketing methods for solving nonlinear equations

Numerical Analysis MTH603

CS 323: Numerical Analysis and Computing

Unit 2: Solving Scalar Equations. Notes prepared by: Amos Ron, Yunpeng Li, Mark Cowlishaw, Steve Wright Instructor: Steve Wright

BEKG 2452 NUMERICAL METHODS Solution of Nonlinear Equations

Homework No. 2 Solutions TA: Theo Drivas

Notes for Numerical Analysis Math 5465 by S. Adjerid Virginia Polytechnic Institute and State University. (A Rough Draft)

1. Nonlinear Equations. This lecture note excerpted parts from Michael Heath and Max Gunzburger. f(x) = 0

Numerical Analysis Solution of Algebraic Equation (non-linear equation) 1- Trial and Error. 2- Fixed point

by Martin Mendez, UASLP Copyright 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

TWO METHODS FOR OF EQUATIONS

AB.Q103.NOTES: Chapter 2.4, 3.1, 3.2 LESSON 1. Discovering the derivative at x = a: Slopes of secants and tangents to a curve

Appendix 8 Numerical Methods for Solving Nonlinear Equations 1

4 Nonlinear Equations

Bisected Direct Quadratic Regula Falsi

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.

Transcription:

INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University

3. SOLVING NONLINEAR EQUATIONS 3.1 Background 3.2 Estimation of errors in numerical solutions 3.3 Bisection method 3.4 Regula falsi method 3.5 Newton's method 3.6 Secant method 3.7 Fixed point iteration method 3.8 Use of MATLAB built in Functions for solving nonlinear equations 3.9 Equations with multiple roots 3.10 System of nonlinear equations

3.1 Background Equation of one variable An equation might have no solution or can have one or several roots. When the equation is simple, the value of x can be determined analytically. In many situations, however, it is impossible to determine the root of an equation analytically. Ex)

Overview of approaches in solving equations numerically Bracketing methods and open methods 3.1 Background Bracketing methods: interval that includes the solution always converge to the solution Open methods: initial guess for the solution usually more efficient but sometimes might not yield the solution

Accuracy 3.2 Estimation of Errors in Numerical Solutions Several measures can be used to estimate the accuracy of an approximate solution. The decision as to which measure to use depends on the application and has to be made by the person solving the equation. True (exact) solution: Numerical solution: 0 (small number) True error True error cannot be calculated because the true solution is not know. Tolerance in Tolerance in Useful for bracketing methods Estimated relative error

Signs at the endpoints of the interval The equation has a solution within a given interval,. will have opposite signs at the endpoints of the interval. 3.3 Bisection Method Process of finding a solution

3.3 Bisection Method Algorithm Choose the first interval by finding points and Termination of iteration? Calculated the first estimate of the numerical solution ( ) Determine whether the true solution is, or, Select subinterval

Example 3 1 3.3 Bisection Method F = @ (x) 8-4.5*(x-sin(x)); fplot(f,[0,4])

3.3 Bisection Method clear all F = @ (x) 8-4.5*(x-sin(x)); a = 2; b = 3; imax = 20; tol = 0.001; Fa=F(a); Fb=F(b); if Fa*Fb > 0 disp('error: The function has the same sign at points a and b.') else disp('iteration a b (xns) Solution f(xns) Tolerance') for i = 1:imax xns = (a + b)/2; toli=(b-a)/2; FxNS=F(xNS); fprintf('%3i %11.6f %11.6f %11.6f %11.6f %11.6f\n',i, a, b, xns, FxNS, toli) if FxNS == 0 fprintf('an exact solution x =%11.6f was found',xns) break end if toli < tol break end if i == imax fprintf('solution was not obtained in %i iterations',imax) break end if F(a)*FxNS < 0 end end b = xns; else a = xns; end

Example 3 1 Try with more strict tolerance criteria. (ex. tol = eps) imax may need to be increased. 3.3 Bisection Method

Additional notes 3.3 Bisection Method The method always converges to an answer, provided a root was trapped in the interval [a, b] to begin with. The method may fail when the function is tangent to the axis and does not cross the x axis at f(x) = 0. The method converges slowly relative to other methods.

3.4 Regula Falsi Method Regular falsi method (false position and linear interpolation methods) Bracketing method Initial interval:, Connect endpoints by a straight line Estimate the first numerical solution, Define a new interval:,

Additional notes 3.4 Regula Falsi Method The method always converges to an answer, provided a root was trapped in the interval [a, b] to begin with. Frequently, as in the case shown in Fig. 3 9, the function in the interval [a, b] is either concave up or concave down. In this case, one of the endpoints of the interval stays the same in all the iterations, while the other endpoint advances toward the root. In other words, the numerical solution advances toward the root only from one side. The convergence toward the solution could be faster if the other endpoint would also "move" toward the root. Several modifications have been introduced to the regula falsi method that make the subinterval in successive iterations approach the root from both sides. (will be HW problem)

Additional notes 3.4 Regula Falsi Method Bisection Regula falsi

Additional notes 3.4 Regula Falsi Method Concave down With inflection point

Newton s method (Newton Raphson method) Isaac Newton (1669) Joseph Raphson (1690) is known to have a solution near a given point. 3.5 Newton s Method 0

When are the iterations stopped? Estimated relative error 3.5 Newton s Method Tolerance in δ

Example 3 2 3.5 Newton s Method

Example 3 2 3.5 Newton s Method function [Xs, i] = NewtonRoot(Fun,FunDer,Xest,Err,imax) % NewtonRoot finds the root of Fun = 0 near the point Xest using Newton's method. % Input variables: % Fun Handle of a user-defined function that calculates Fun for a given x. % FunDir Handle of a user-defined function that calculates the derivative % of Fun for a given x. % Xest Initial estimate of the solution. % Err Maximum error. % imax Maximum number of iterations % Output variable: % Xs Solution for i = 1:imax Xi = Xest - Fun(Xest)/FunDer(Xest); if abs((xi - Xest)/Xest) < Err Xs = Xi; break end Xest = Xi; end if i == imax end fprintf('solution was not obtained in %i iterations.\n',imax) Xs = ('No answer');

Example 3 2 3.5 Newton s Method function newton F = @ (x) 8-4.5*(x-sin(x)); df= @ (x) -4.5*(1-cos(x)); x0=2.0; err=1.0e-4; imax=10; [sol, iter]=newtonroot(f,df,x0,err,imax); disp(sol); disp(iter);

Notes on Newton s method 3.5 Newton s Method The method, when successful, works well and converges fast. When it does not converge, it is usually because the starting point is not close enough to the solution. Convergence problems typically occur when the value of is close to zero in the vicinity of the solution.

Notes on Newton s method 3.5 Newton s Method A function, which is the derivative of the function, has to be substituted in the iteration formula In many cases, it is simple to write the derivative, but sometimes it can be difficult to determine. When an expression for the derivative is not available, it might be possible to determine the slope numerically or to find a solution by using the secant method (Section 3.6), which is somewhat similar to Newton's method but does not require an expression for the derivative.

Example 3 3: Convergence of Newton's method 3.5 Newton s Method

Secant method Initial guess for two points: Define a straight line. Define where the straight line intersects the axis. 3.6 Secant Method 0

Relationship to Newton s method 3.6 Secant Method Initial guess for two points: It is not necessary to know the analytical form of

Program for secant method 3.6 Secant Method function Xs = SecantRoot(Fun,Xa,Xb,Err,imax) % SecantRoot finds the root of Fun = 0 using the Secant method. % Input variables: % Fun Name of a user-defined function that calculates Fun for a given x. % a, b Two points in the neighborhood of the root (on either side, or the % same side of the root). % Err Maximum error. % imax Maximum number of iterations % Output variable: % Xs Solution for i = 1:imax FunXb = Fun(Xb); Xi = Xb - FunXb*(Xa-Xb)/(Fun(Xa)-FunXb); if abs((xi - Xb)/Xb) < Err Xs = Xi; break end Xa = Xb; Xb = Xi; end if i == imax end fprintf('solution was not obtained in %i iterations.\n',imax) Xs = ('No answer');

Program for secant method 3.6 Secant Method function secant F = @ (x) 8-4.5*(x-sin(x)); x0=2.0; x1=3.0; err=1.0e-5; imax=10000; [sol,iter]=secantroot(f,x0,x1,err,imax); disp(sol); disp(iter);

Fixed point iteration method 3.7 Fixed Point Iteration Method (not always) Rewriting the equation iteration function Fixed point

Divergence of the iteration 3.7 Fixed Point Iteration Method The fixed point iteration method converges if, in the neighborhood of the fixed point, the derivative of g(x) has an absolute value that is smaller than 1. g 1

Choosing the appropriate iteration function The iteration function is not unique! Ex) 3.7 Fixed Point Iteration Method Case a Case b Case c

Divergence of the iteration 3.7 Fixed Point Iteration Method Let f ( x ) 0 or x g( x ) with a true solution x TS TS TS TS k 1 TS x x e = x x g( x ) g( x ) k k TS k 1 TS gx ( ) gx ( ) x x k 1 TS k 1 TS Error reduction factor ek = g ( k 1) e k 1 g ( k 1) ek 1 k 1 k 1 TS x x Iteration converges if M max g ( x) 1 x

Choosing the appropriate iteration function 3.7 Fixed Point Iteration Method 2 Ex: f( x) x 2x 3 ( x 3)( x 1) 0 x 3, 1 6 g ( x) 1 x g( x)? 4 x 2x 3 g ( x) 3 x g2( x) x 2 1 2 3 x x g3( x) 2 2 8 1 x k gx ( k 1) g ( x) 2 g ( x) 3 6 2 8 6 2 4 6 Diverge 4 4 2 2-2 2 4 6-2 -2-1 1 2 3 4 5-2 -4-4

3.8 Use of MATLAB Built in Functions Built in functions fzero: to find a root of any equation roots: to find the roots of a polynomial fzero roots

General strategy 3.9 Equations with Multiple Solutions Determine the approximate location of the roots by defining smaller intervals over which the roots exist. This can be done by plotting the function or by evaluating the function over a set of successive points and looking for sign changes of the function. Apply any of the methods over a restricted subinterval. For example, [1,2] and after that, [4,5]

Example 3.9 Equations with Multiple Solutions

A system of non linear equations 3.10 Systems of Non linear Equations Two or more nonlinear equations that have to be solved simultaneously. Newton method Fixed point iteration method

Newton s method Solving a system of two non linear equations 3.10 Systems of Non linear Equations Estimated solution: 0 0

Newton s method Cramer s rule 3.10 Systems of Non linear Equations New estimation!

Newton s method Example 3.10 Systems of Non linear Equations

Newton s method Example 3.10 Systems of Non linear Equations %solution of Chapter 3 Example 5 F1 = @ (x,y) y - 0.5*(exp(x/2) + exp(-x/2)); F2 = @ (x,y) 9*x^2 + 25*y^2-225; F1x = @ (x) -(exp(x/2) - exp(-x/2))/4; F2x = @ (x) 18*x; F2y = @ (y) 50*y; Jacob = @ (x,y) -(exp(x/2) - exp(-x/2))/4*50*y - 18*x; xi = 2.5; yi = 2; Err = 0.0000001; for i = 1:5 Jac = Jacob(xi,yi); Delx = (-F1(xi,yi)*F2y(yi) + F2(xi,yi))/Jac; Dely = (-F2(xi,yi)*F1x(xi) + F1(xi,yi)*F2x(xi))/Jac; xip1 = xi + Delx; yip1 = yi + Dely; Errx = abs((xip1 - xi)/xi); Erry = abs((yip1 - yi)/yi); fprintf('i =%2.0f x = %-7.4f y = %-7.4f Error in x = %-7.5f Error in y = %-7.5f\n'...,i,xip1,yip1,Errx,Erry) if Errx < Err & Erry < Err break else xi = xip1; yi = yip1; end end

Newton s method Solving a system of n non linear equations 3.10 Systems of Non linear Equations

3.10 Systems of Non linear Equations Newton s method Convergence is not guaranteed! Additional notes The method, when successful, converges fast. When it does not converge, it is usually because the initial guess is not close enough to the solution. The partial derivatives (the elements of the Jacobian matrix) have to be determined. This can be done analytically or numerically. However, for a large system of equations, the determination of the Jacobian might be difficult. When the system of equations consists of more than three equations, the solution of the linear equations has to be done numerically.

3.10 Systems of Non linear Equations Fixed point iteration method for solving a system of non linear equations Initial guess: New estimate:,,,,,, Converged solution:,,,,,, Forms of iteration functions are not unique.