Finding Roots of Equations

Similar documents
Numerical Analysis Fall. Roots: Open Methods

SOLVING EQUATIONS OF ONE VARIABLE

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

Numerical Methods. Root Finding

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

Numerical Methods School of Mechanical Engineering Chung-Ang University

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

MATH 3795 Lecture 12. Numerical Solution of Nonlinear Equations.

Numerical Methods Lecture 3

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

Numerical Solution of f(x) = 0

APPLICATIONS OF DIFFERENTIATION

Applied Numerical Methods With MATLAB for Engineers and Scientists

(a) Show that there is a root α of f (x) = 0 in the interval [1.2, 1.3]. (2)

INTRODUCTION TO NUMERICAL ANALYSIS

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

Finding the Roots of f(x) = 0

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

Exact and Approximate Numbers:

Solving Non-Linear Equations (Root Finding)

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

Chapter 4. Solution of a Single Nonlinear Algebraic Equation

Finding roots. Lecture 4

CHAPTER-II ROOTS OF EQUATIONS

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

2.29 Numerical Fluid Mechanics Spring 2015 Lecture 4

Example - Newton-Raphson Method

Mathematical Methods for Numerical Analysis and Optimization

NUMERICAL METHODS FOR SOLVING EQUATIONS

Page No.1. MTH603-Numerical Analysis_ Muhammad Ishfaq

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.

NUMERICAL AND STATISTICAL COMPUTING (MCA-202-CR)

Virtual University of Pakistan

Solution of Algebric & Transcendental Equations

B.Tech. Theory Examination (Semester IV) Engineering Mathematics III

FP1 PAST EXAM QUESTIONS ON NUMERICAL METHODS: NEWTON-RAPHSON ONLY

CHAPTER 4 ROOTS OF EQUATIONS

The region enclosed by the curve of f and the x-axis is rotated 360 about the x-axis. Find the volume of the solid formed.

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

Solution of Nonlinear Equations

Lecture 8. Root finding II

BSM510 Numerical Analysis

Root-finding and optimisation

MA 114 Worksheet #01: Integration by parts

CS 221 Lecture 9. Tuesday, 1 November 2011

R x n. 2 R We simplify this algebraically, obtaining 2x n x n 1 x n x n

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

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

Numerical Methods. Roots of Equations

CALCULUS APPLICATIONS OF DIFFERENTIATION LESSON PLAN. C3 Topic Overview

The Fundamental Theorem of Calculus Part 3

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

Numerical Analysis & Computer Programming

Numerical Integration (Quadrature) Another application for our interpolation tools!

3.1: 1, 3, 5, 9, 10, 12, 14, 18

Comparative Analysis of Convergence of Various Numerical Methods

Hence a root lies between 1 and 2. Since f a is negative and f(x 0 ) is positive The root lies between a and x 0 i.e. 1 and 1.

TWO METHODS FOR OF EQUATIONS

Study Guide and Intervention. The Quadratic Formula and the Discriminant. Quadratic Formula. Replace a with 1, b with -5, and c with -14.

APPM 1360 Final Exam Spring 2016

SOLVING QUADRATICS. Copyright - Kramzil Pty Ltd trading as Academic Teacher Resources

Slopes and Rates of Change

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

MATH section 3.4 Curve Sketching Page 1 of 29

This procedure covers the determination of the moment of inertia about the neutral axis.

Calculus 1 - Lab ) f(x) = 1 x. 3.8) f(x) = arcsin( x+1., prove the equality cosh 2 x sinh 2 x = 1. Calculus 1 - Lab ) lim. 2.

AP Calculus AB Summer Assignment

Topic 4b. Open Methods for Root Finding

Excel for Scientists and Engineers Numerical Method s. E. Joseph Billo

Nonlinear Equations. Chapter The Bisection Method

UNIT - 2 Unit-02/Lecture-01

SECTION 4-3 Approximating Real Zeros of Polynomials Polynomial and Rational Functions

Math 2412 Activity 2(Due by EOC Feb. 27) Find the quadratic function that satisfies the given conditions. Show your work!

MATH 175: Final Exam Review for Pre-calculus

MTH 252 Lab Supplement

Derivative of a Constant Multiple of a Function Theorem: If f is a differentiable function and if c is a constant, then

Math 551 Homework Assignment 3 Page 1 of 6

abc Mathematics Further Pure General Certificate of Education SPECIMEN UNITS AND MARK SCHEMES

Chapter 1. Root Finding Methods. 1.1 Bisection method

1 The best of all possible worlds

The iteration formula for to find the root of the equation

PhysicsAndMathsTutor.com

Solution of Nonlinear Equations

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

Maths A Level Summer Assignment & Transition Work

Numerical Methods School of Mechanical Engineering Chung-Ang University

Universidad Carlos III de Madrid

Exact Differential Equations. The general solution of the equation is f x, y C. If f has continuous second partials, then M y 2 f

Lecture 7: Indeterminate forms; L Hôpitals rule; Relative rates of growth. If we try to simply substitute x = 1 into the expression, we get

In #1-5, find the indicated limits. For each one, if it does not exist, tell why not. Show all necessary work.

AP Calculus AB Summer Assignment

Lesson #33 Solving Incomplete Quadratics

Section 3.3 Graphs of Polynomial Functions

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

Math 231 Final Exam Review

11.4. Differentiating ProductsandQuotients. Introduction. Prerequisites. Learning Outcomes

Learning Targets: Standard Form: Quadratic Function. Parabola. Vertex Max/Min. x-coordinate of vertex Axis of symmetry. y-intercept.

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

AP Calculus Review Assignment Answer Sheet 1. Name: Date: Per. Harton Spring Break Packet 2015

4.3 Worksheet - Derivatives of Inverse Functions

Transcription:

Finding Roots of Equations

Solution Methods Overview Bisection/Half-interval Search Method of false position/regula Falsi Secant Method Newton Raphson Iteration Method Many more. Open Methods Bracketing Methods 2 Algebraic equation: a b c 0 Transcendental equation: 1 cos 5 0 CE 206: Engg. Computation sessional

Bracketing Methods: Bisection a new new old 100% Location of the root lies within the interval where the sign change occurs The absolute error is reduced by a factor of 2 for each iteration. CE 206: Engg. Computation sessional

MATLAB code: bisection method function [root,f,ea,iter]=bisect(func,l,u,es,mait) % [root,f,ea,iter]=bisect('func',l,u,es,mait): % uses bisection method to find the root of func % input: % func = name of function % l, u = lower and upper guesses % es = desired relative error (default = 0.0001) % mait = maimum allowable iterations (default = 50) % output: % root = real root % f = function value at root % ea = approimate relative error (%) % iter = number of iterations Comment lines if nargin<3,error('at least 3 input arguments required'),end test = feval('func',l)*feval('func',u); if test>0,error( roots cannot be found'),end if nargin<4 isempty(es), es=0.0001;end if nargin<5 isempty(mait), mait=50;end Checking whether the roots are within these bounds or not CE 206: Engg. Computation sessional

MATLAB code: bisection method (ctd) iter = 0; r = l; ea = 100; while (1) rold = r; r = (l + u)/2; iter = iter + 1; if r ~= 0,ea = abs((r - rold)/r) * 100;end test = feval('func',l)*feval('func',r); if test < 0 u = r; elseif test > 0 l = r; else ea = 0; end if ea <= es iter >= mait,break,end end root = r; f = feval('func',r); The variables that change their values within the code needs to be initialized Calculating appro. error a new new old 100% Stopping criteria CE 206: Engg. Computation sessional

func.m file definition function [value] = func() value = ^3-10*^2+5; Evaluating the function 3 10 2 5 [root,f,ea,iter]=bisect('func',0.6,0.8) root = 0.7346 f = 0.4430 ea = 5.1929e-005 iter = 19 Root of the function after 19 iterations ea<0.0001 was the stopping criterion CE 206: Engg. Computation sessional

Bracketing Methods: Regula Falsi the location of the intercept of the straight line ( r ): r u f ( u )( l u ) f ( l ) f ( u ) Try yourself: Modify the bisect.m function file to incorporate the regula falsi method bisection r = (l + u)/2; Regula Falsi r = u-feval( func,u)*(l-u) /(feval( func,l)-feval( func,u));

Newton-Raphson Method Based on forming the tangent line to the f() curve at some guess, then following the tangent line to where it crosses the -ais. ) ( ) ( 0 ) ( ) ( 1 1 i i i i i i i i f f f f a i1 i i1 100%

MATLAB code: newtraph.m function [root,ea,iter]=newtraph(func,dfunc,r,es,mait) if nargin<3, error('at least 3 input arguments required') end if nargin<4 isempty(es),es=0.0001;end if nargin<5 isempty(mait),mait=50;end iter = 0; while (1) rold = r; Derivative of the function (needs to be defined) r = r - feval('func',r)/feval('dfunc',r); iter = iter + 1; if r ~= 0, ea = abs((r - rold)/r) * 100; end if ea <= es iter >= mait, break, end end root = r; i1 i f ( i ) f ( ) i

Secant Method the derivative approimated by a backward finite divided difference: f ' ( i ) f ( i1 ) f ( i ) i1 i i1 i f ( ) i i1 i f ( i1 ) f ( i ) Note: Requires two initial guesses for f() f( i ) f( i-1 ) i-1 i Eercise: Can you modify newtraph.m function file and make it applicable for the secant method?

Secant Method: Eercise Apply the developed code for the secant method to find the first positive root of f() = sin + cos(1+ 2 ) 1 where is in radians. Use four iterations with initial guesses of (i) 1.0 and 3.0 (ii) 1.5 and 2.5, and (iii) 1.5 and 2.25

MATLAB s fzero function MATLAB s fzero provides the best qualities of both bracketing methods and open methods. Using an initial guess: = fzero(function, 0) [, f] = fzero(function, 0) Location of the root Evaluated at the root Function handle to the function being evaluated Using an initial bracket: Initial guess = fzero(function, [0 1]) [, f] = fzero(function, [0 1]) Initial guesses that bracket the root Using create or edit fzero options using optimset options = optimset('param1',value1,'param2',value2,...)

fzero eample options = optimset( display, iter ); Sets options to display each iteration of root finding process. Other optimset properties: MaIter, TolX [, f] = fzero(@() ^10-1, 0.5, options) Uses fzero to find roots of f()= 10-1 starting with an initial guess of =0.5. MATLAB reports = 1, f = 0 after 35 function counts

MATLAB s roots function Roots of polynomials: For an nth order equation, there are n real or comple roots. n = roots(c) f ( ) a 0 a a a is a column vector containing the roots 1 c is a row vector containing the polynomial coefficients 2 2 n n Eample: Find the roots of f()= 5-3.5 4 + 2.75 3 + 2.125 2-3.875 + 1.25 = roots([1-3.5 2.75 2.125-3.875 1.25])

Eercise 1 20 kips/ft 150 kip-ft Using singularity functions, the shear, bending moment and displacement along the simply supported beam can be epressed as follows: V( ) 20 15 kips 5 ft 2 ft 1 ft 2 ft 0 2 1 20 5 2 15 8 57 M( ) 10 0 10 5 15 8 150 7 57 5 4 5 4 15 2 2 57 3 u( ) 0 5 8 75 7 238. 25 6 6 6 6 Using any root location technique, find the points where shear and bending moment equal to zero and where the displacement is maimum. Also draw the shear force, bending moment and displacement diagrams 1 1 0 0

Eercise 1: solution hints 20 kips/ft 150 kip-ft 15 kips 5 ft 2 ft 1 ft 2 ft V( ) 20 0 1 20 5 1 15 8 0 57 function f = V() f=20*(sing(,0,1)-sing(,5,1))-15*sing(,8,0)-57; In addition, the singularity function can be set up as function s = sing(, a, n) if > a s = ( - a) ^ n; else s = 0; end a n ( a) 0 n when when a a Solution: V() = 0 at = 2.85 ft, M() = 0 at = 5.814 ft, U() = 0 at = 3.9357 ft

Eercise 2 The saturation concentration of dissolved oygen in freshwater can be calculated with the equation: ln O sat 1.57570110 139.34411 T a 5 6.64230810 T O sat = Saturation concentration of DO (mg/l) T a = T + 273.15 where T = temperature ( C) 2 a 7 1.243810 T 3 a 10 8.62194910 T 4 a 11 Fill up the following table (use bisection method): epress your results for an absolute error of 0.05 C O sat (mg/l) Temperature ( C) 8?? 10?? 12??

Eercise 2: solution hints First determine how many iterations you need for the specified absolute error using the formula (see your CE 205 notes): Bracket range 0 40 log n log 2 E a, d 0.05 2 Absolute error 9.6439 10 iterations should be enough Use bisect.m to compute the roots for maimum 10 iterations and also find the real roots using fzero function. Compare results. O sat Approimation Eact Error 8 26.75781 26.78017 0.0224 10 15.35156 15.38821 0.0366 12 7.46094 7.46519 0.0043 Less than 0.05

Concluding remarks Need to be judicious in choosing your initial guess (or initial brackets) of the root. A physical insight into the problem may help Apply common logic Some eamples: - Water level in a spherical tank cannot eceed the diameter - Temperature in natural water bodies usually within a specific range, (e.g. cannot be negative) - deflection of a beam is maimum where the du/d is zero - Water level in a tank cannot eceed tank depth (or cannot be negative) - etc.

Eercise Water is flowing in a trapezoidal channel at a rate of Q = 20 m 3 /s. The critical depth y for such a channel must satisfy the equation: Where g = 9.81 m 2 /s, A c = channel cross-sectional area (m 2 ) = 3y + y 2 /2 and B = width of the channel at the surface (m) = 3 + y. Solve for the critical depth (y) using both bisection and method of false position using the initial guesses 0.5 and 2.5 and iterate until the approimate error falls below 1% or the number of iterations eceed 10. Compare your results from both methods