Chapter 6 Finding the Roots of Equations

Slides:



Advertisements
Similar presentations
“Teach A Level Maths” Vol. 2: A2 Core Modules
Advertisements

Part 2 Chapter 6 Roots: Open Methods
Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W Th , F
Roots: Bracketing Methods
SOLVING QUADRATICS General Form: Where a, b and c are constants.
Flow Charts, Loop Structures
Chapter 1 Computing Tools Data Representation, Accuracy and Precision Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
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.
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.
Chapter 4 MATLAB Programming Logical Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Linear Simultaneous Equations
FP1: Chapter 2 Numerical Solutions of Equations
Chapter 5 Plotting Data Curve Fitting, Good Graphing Practices Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Matrix Mathematics in MATLAB and Excel
Chapter 9 Numerical Integration Numerical Integration Application: Normal Distributions Copyright © The McGraw-Hill Companies, Inc. Permission required.
Section 1.2 Homework questions? Slide 1 Copyright (c) The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
An Opportunity for Practice
Non-Linear Simultaneous Equations
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Linear Algebraic Equations ~ Gauss Elimination Chapter.
MATH 175: NUMERICAL ANALYSIS II Lecturer: Jomar Fajardo Rabajante IMSP, UPLB 2 nd Semester AY
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 31.
Chapter 14: Numerical Methods
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 Roots of Equations Why? But.
Continuity ( Section 1.8) Alex Karassev. Definition A function f is continuous at a number a if Thus, we can use direct substitution to compute the limit.
Chapter 9 Numerical Integration Flow Charts, Loop Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 1 Computing Tools Analytic and Algorithmic Solutions Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Chapter 111.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 5 Systems and Matrices Copyright © 2013, 2009, 2005 Pearson Education, Inc.
Copyright © Cengage Learning. All rights reserved. 4 Quadratic Functions.
Part 2 Chapter 5 Roots: Bracketing Methods PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill.
Precalculus Polynomial & Rational --- Part One V. J. Motto.
Key Concept 1. Example 1 Leading Coefficient Equal to 1 A. List all possible rational zeros of f (x) = x 3 – 3x 2 – 2x + 4. Then determine which, if any,
Lecture 3 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Roots of Equations ~ Open Methods Chapter 6 Credit:
Real Zeros of Polynomial Functions
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
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 3.
Zeros of Polynomials 2.5.
Copyright © 1999 by the McGraw-Hill Companies, Inc. Barnett/Ziegler/Byleen Precalculus: Functions & Graphs, 4 th Edition Chapter One Equations & Inequalities.
Newton’s Method, Root Finding with MATLAB and Excel
Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002.
Solution of Nonlinear Equations Topic: Bisection method
Numerical Methods Solution of Equation.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Applied Numerical Methods With MATLAB ® for Engineers.
Today’s class Numerical differentiation Roots of equation Bracketing methods Numerical Methods, Lecture 4 1 Prof. Jinbo Bi CSE, UConn.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 27.
1 © 2010 Pearson Education, Inc. All rights reserved © 2010 Pearson Education, Inc. All rights reserved Chapter 3 Polynomial and Rational Functions.
College Algebra Sixth Edition James Stewart Lothar Redlin Saleem Watson.
Chapter 2 Excel Fundamentals Logical IF (Decision) Statements Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 4 MATLAB Programming MATLAB Troubleshooting Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 6 - Chapters 22 and 23.
Copyright © 2014, The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Copyright © 2014, The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Real Zeros of Polynomial Functions
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 / Chapter 5.
Chapter 7 Matrix Mathematics
Numerical Methods and Analysis
Chapter 4 MATLAB Programming
Read Chapters 5 and 6 of the textbook
SOLUTION OF NONLINEAR EQUATIONS
Solutions for Nonlinear Equations
Presentation transcript:

Chapter 6 Finding the Roots of Equations The Bisection Method Chapter 6 Finding the Roots of Equations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Finding Roots of Equations In this chapter, we are examining equations with one independent variable. These equations may be linear or non-linear Non-linear equations may be polynomials or generally non-linear equations A root of the equation is simply a value of the independent variable that satisfies the equation Engineering Computation: An Introduction Using MATLAB and Excel

Classification of Equations Linear: independent variable appears to the first power only, either alone or multiplied by a constant Nonlinear: Polynomial: independent variable appears raised to powers of positive integers only General non-linear: all other equations Engineering Computation: An Introduction Using MATLAB and Excel

Finding Roots of Equations As with our method for solving simultaneous non-linear equations, we often set the equation to be equal to zero when the equation is satisfied Example: If we say that then when f(y) =0, the equation is satisfied Engineering Computation: An Introduction Using MATLAB and Excel

Solution Methods Linear: Easily solved analytically Polynomials: Some can be solved analytically (such as by quadratic formula), but most will require numerical solution General non-linear: unless very simple, will require numerical solution Engineering Computation: An Introduction Using MATLAB and Excel

The Bisection Method In the bisection method, we start with an interval (initial low and high guesses) and halve its width until the interval is sufficiently small As long as the initial guesses are such that the function has opposite signs at the two ends of the interval, this method will converge to a solution Example: Consider the function Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example Consider an initial interval of ylower = -10 to yupper = 10 Since the signs are opposite, we know that the method will converge to a root of the equation The value of the function at the midpoint of the interval is: Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example The method can be better understood by looking at a graph of the function: Interval Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example Now we eliminate half of the interval, keeping the half where the sign of f(midpoint) is opposite the sign of f(endpoint) In this case, since f(ymid) = -6 and f(yupper) = 64, we keep the upper half of the interval, since the function crosses zero in this interval Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example Now we eliminate half of the interval, keeping the half where the sign of f(midpoint) is opposite the sign of f(endpoint) In this case, since f(ymid) = -6 and f(yupper) = 64, we keep the upper half of the interval, since the function crosses zero in this interval Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example The interval has now been bisected, or halved: New Interval Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example New interval: ylower = 0, yupper = 10, ymid = 5 Function values: Since f(ylower) and f(ymid) have opposite signs, the lower half of the interval is kept Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example At each step, the difference between the high and low values of y is compared to 2*(allowable error) If the difference is greater, than the procedure continues Suppose we set the allowable error at 0.0005. As long as the width of the interval is greater than 0.001, we will continue to halve the interval When the width is less than 0.001, then the midpoint of the range becomes our answer Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example Excel solution: Initial Guesses Evaluate function at lower and mid values. Is interval width narrow enough to stop? If signs are same (+ product), eliminate lower half of interval. Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example Next iteration: Evaluate function at lower and mid values. New Interval (if statements based on product at the end of previous row) If signs are different (- product), eliminate upper half of interval. Is interval width narrow enough to stop? Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example Continue until interval width < 2*error (16 iterations) Answer: y = 0.857 Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example Or course, we know that the exact answer is 6/7 (0.857143) If we wanted our answer accurate to 5 decimal places, we could set the allowable error to 0.000005 This increases the number of iterations only from 16 to 22 – the halving process quickly reduces the interval to very small values Even if the initial guesses are set to -10,000 and 10000, only 32 iterations are required to get a solution accurate to 5 decimal places Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example - Polynomial Now consider this example: Use the bisection method, with allowed error of 0.0001 Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example - Polynomial If limits of -10 to 0 are selected, the solution converges to x = -2 Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example - Polynomial If limits of 0 to 10 are selected, the solution converges to x = 4 Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example - Polynomial If limits of -10 to 10 are selected, which root is found? In this case f(-10) and f(10) are both positive, and f(0) is negative Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example - Polynomial Which half of the interval is kept? Depends on the algorithm used – in our example, if the function values for the lower limit and midpoint are of opposite signs, we keep the lower half of the interval Engineering Computation: An Introduction Using MATLAB and Excel

Bisection Method Example - Polynomial Therefore, we converge to the negative root Engineering Computation: An Introduction Using MATLAB and Excel

In-Class Exercise Draw a flow chart of the algorithm used to find a root of an equation using the bisection method Write the MATLAB code to determine a root of within the interval x = 0 to 10 Engineering Computation: An Introduction Using MATLAB and Excel

Input lower and upper limits low and high Define tolerance tol Input lower and upper limits low and high while high-low > 2*tol mid = (high+low)/2 Evaluate function at lower limit and midpoint: fl = f(low), fm = f(mid) Keep lower half of range: high = mid fl*fm > 0? Keep upper half of range: low = mid NO YES Display root (mid)

MATLAB Solution Consider defining the function as a MATLAB function “fun1” This will allow our bisection program to be used on other functions without editing the program – only the MATLAB function needs to be modified Engineering Computation: An Introduction Using MATLAB and Excel

MATLAB Function Check values at x = 0 and x = 10: function y = fun1(x) y = exp(x) - 15*x -10; Check values at x = 0 and x = 10: >> fun1(0) ans = -9 >> fun1(10) 2.1866e+004 Different signs, so a root exists within this range Engineering Computation: An Introduction Using MATLAB and Excel

Set tolerance to 0.00001; answer will be accurate to 5 decimal places Engineering Computation: An Introduction Using MATLAB and Excel

Engineering Computation: An Introduction Using MATLAB and Excel

Engineering Computation: An Introduction Using MATLAB and Excel

Engineering Computation: An Introduction Using MATLAB and Excel

Engineering Computation: An Introduction Using MATLAB and Excel

Engineering Computation: An Introduction Using MATLAB and Excel

Engineering Computation: An Introduction Using MATLAB and Excel

Find Root >> bisect Enter the lower limit 0 Enter the upper limit 10 Root found: 4.3135 Engineering Computation: An Introduction Using MATLAB and Excel

What if No Root Exists? Try interval of 0 to 3: >> bisect Enter the lower limit 0 Enter the upper limit 3 Root found: 3.0000 This value is not a root – we might want to add a check to see if the converged value is a root Engineering Computation: An Introduction Using MATLAB and Excel

Modified Code Add “solution tolerance” (usually looser than convergence tolerance): Add check at end of program: Engineering Computation: An Introduction Using MATLAB and Excel

Check Revised Code >> bisect Enter the lower limit 0 Enter the upper limit 3 No root found Engineering Computation: An Introduction Using MATLAB and Excel

Numerical Tools Of course, Excel and MATLAB have built-in tools for finding roots of equations However, the examples we have considered illustrate an important concept about non-linear solutions: Remember that there may be many roots to a non-linear equation. Even when specifying an interval to be searched, keep in mind that there may be multiple solutions (or no solution) within the interval. Engineering Computation: An Introduction Using MATLAB and Excel