SlideShare a Scribd company logo
Chapter 6
Finding the Roots of
Equations
The Bisection Method
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:
Engineering Computation: An Introduction Using MATLAB and Excel
Interval
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:
Engineering Computation: An Introduction Using MATLAB and Excel
New Interval
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:
Engineering Computation: An Introduction Using MATLAB and Excel
Initial
Guesses
Is interval width
narrow enough to stop?
Evaluate function at
lower and mid values.
If signs are same (+ product),
eliminate lower half of interval.
Bisection Method Example
• Next iteration:
Engineering Computation: An Introduction Using MATLAB and Excel
New Interval (if statements
based on product at the end
of previous row)
Is interval width narrow
enough to stop?
Evaluate function at
lower and mid values.
If signs are different (- product),
eliminate upper half of interval.
Bisection Method Example
• Continue until interval width < 2*error (16
iterations)
Engineering Computation: An Introduction Using MATLAB and Excel
Answer:
y = 0.857
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
while high-low > 2*tol
mid = (high+low)/2
Evaluate function at
lower limit and
midpoint:
fl = f(low), fm = f(mid)
fl*fm > 0?
Keep upper half of
range:
low = mid
Keep lower half
of range:
high = mid
Display root (mid)
YESNO
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
function y = fun1(x)
y = exp(x) - 15*x -10;
Check values at x = 0 and x = 10:
>> fun1(0)
ans =
-9
>> fun1(10)
ans =
2.1866e+004
Different signs, so a root exists within this range
Engineering Computation: An Introduction Using MATLAB and Excel
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
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

More Related Content

PPTX
Numerical analysis ppt
PDF
Introduction to Numerical Analysis
PPTX
PPTX
Partial differential equations
PPT
Eigenvalues and Eigenvectors
PPT
numerical methods
PDF
Introduction of Partial Differential Equations
PDF
Numerical method for solving non linear equations
Numerical analysis ppt
Introduction to Numerical Analysis
Partial differential equations
Eigenvalues and Eigenvectors
numerical methods
Introduction of Partial Differential Equations
Numerical method for solving non linear equations

What's hot (20)

PPTX
Bisection method
PPTX
Finite difference method
PPTX
Homogeneous Linear Differential Equations
PPTX
Numerical methods and its applications
PPTX
A presentation on differencial calculus
PPTX
Bisection & Regual falsi methods
PPTX
Linear differential equation
PPTX
Application of Numerical method in Real Life
PDF
partial diffrentialequations
PPT
1st order differential equations
PPTX
lagrange interpolation
PPTX
Engineering mathematics 1
PDF
Stability of Differential Equations
PPTX
Bessel’s equation
PDF
2nd order ode applications
PDF
Lesson 2: Vectors and the Dot Product
PDF
Partial Differential Equation - Notes
PPT
Secant Method
PPT
first order ode with its application
PPTX
Ode powerpoint presentation1
Bisection method
Finite difference method
Homogeneous Linear Differential Equations
Numerical methods and its applications
A presentation on differencial calculus
Bisection & Regual falsi methods
Linear differential equation
Application of Numerical method in Real Life
partial diffrentialequations
1st order differential equations
lagrange interpolation
Engineering mathematics 1
Stability of Differential Equations
Bessel’s equation
2nd order ode applications
Lesson 2: Vectors and the Dot Product
Partial Differential Equation - Notes
Secant Method
first order ode with its application
Ode powerpoint presentation1
Ad

Similar to bisection method (20)

PPTX
03 Chapter MATLAB finite precision arithmatic
PPT
Applications of numerical methods
PPTX
Analysis for engineers _roots_ overeruption
PPTX
Bisection
PPT
Bisection method in maths 4
PDF
Nl eqn lab
PPTX
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
DOCX
n this module, I include a file called Bisection Technique. I us
DOCX
Hi- Can you answer this question- Please show all your work and show i.docx
PPTX
PPTX
Numerical Method 2
PDF
Matlab lecture 5 bisection method@taj
PPTX
Bisection method
PPTX
bisectionmethod-130831052031-phpapp02.pptx
PPTX
BIsection method maths linear and .pptx
PPTX
Solving of Non-Linear Equations-1.pptx
PDF
NA-Ch2-Student.pdf numerical computing chapter 2 solution
PDF
PPT
ROOTS EQUATIONS
PDF
Numerical Methods for Engineers 7th Edition Chapra Solutions Manual
03 Chapter MATLAB finite precision arithmatic
Applications of numerical methods
Analysis for engineers _roots_ overeruption
Bisection
Bisection method in maths 4
Nl eqn lab
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
n this module, I include a file called Bisection Technique. I us
Hi- Can you answer this question- Please show all your work and show i.docx
Numerical Method 2
Matlab lecture 5 bisection method@taj
Bisection method
bisectionmethod-130831052031-phpapp02.pptx
BIsection method maths linear and .pptx
Solving of Non-Linear Equations-1.pptx
NA-Ch2-Student.pdf numerical computing chapter 2 solution
ROOTS EQUATIONS
Numerical Methods for Engineers 7th Edition Chapra Solutions Manual
Ad

Recently uploaded (20)

PPTX
Artificial Intelligence
PPTX
UNIT - 3 Total quality Management .pptx
PDF
737-MAX_SRG.pdf student reference guides
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
Safety Seminar civil to be ensured for safe working.
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
Soil Improvement Techniques Note - Rabbi
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
PPT on Performance Review to get promotions
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
Artificial Intelligence
UNIT - 3 Total quality Management .pptx
737-MAX_SRG.pdf student reference guides
III.4.1.2_The_Space_Environment.p pdffdf
Safety Seminar civil to be ensured for safe working.
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
Soil Improvement Techniques Note - Rabbi
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
R24 SURVEYING LAB MANUAL for civil enggi
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Abrasive, erosive and cavitation wear.pdf
PPT on Performance Review to get promotions
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Categorization of Factors Affecting Classification Algorithms Selection
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
86236642-Electric-Loco-Shed.pdf jfkduklg
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Fundamentals of Mechanical Engineering.pptx
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...

bisection method

  • 1. Chapter 6 Finding the Roots of Equations The Bisection Method Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
  • 2. 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
  • 3. 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
  • 4. 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
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. Bisection Method Example • The method can be better understood by looking at a graph of the function: Engineering Computation: An Introduction Using MATLAB and Excel Interval
  • 9. 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
  • 10. 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
  • 11. Bisection Method Example • The interval has now been bisected, or halved: Engineering Computation: An Introduction Using MATLAB and Excel New Interval
  • 12. 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
  • 13. 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
  • 14. Bisection Method Example • Excel solution: Engineering Computation: An Introduction Using MATLAB and Excel Initial Guesses Is interval width narrow enough to stop? Evaluate function at lower and mid values. If signs are same (+ product), eliminate lower half of interval.
  • 15. Bisection Method Example • Next iteration: Engineering Computation: An Introduction Using MATLAB and Excel New Interval (if statements based on product at the end of previous row) Is interval width narrow enough to stop? Evaluate function at lower and mid values. If signs are different (- product), eliminate upper half of interval.
  • 16. Bisection Method Example • Continue until interval width < 2*error (16 iterations) Engineering Computation: An Introduction Using MATLAB and Excel Answer: y = 0.857
  • 17. 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
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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
  • 23. Bisection Method Example - Polynomial • Therefore, we converge to the negative root Engineering Computation: An Introduction Using MATLAB and Excel
  • 24. 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
  • 25. Input lower and upper limits low and high Define tolerance tol while high-low > 2*tol mid = (high+low)/2 Evaluate function at lower limit and midpoint: fl = f(low), fm = f(mid) fl*fm > 0? Keep upper half of range: low = mid Keep lower half of range: high = mid Display root (mid) YESNO
  • 26. 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
  • 27. MATLAB Function function y = fun1(x) y = exp(x) - 15*x -10; Check values at x = 0 and x = 10: >> fun1(0) ans = -9 >> fun1(10) ans = 2.1866e+004 Different signs, so a root exists within this range Engineering Computation: An Introduction Using MATLAB and Excel
  • 28. Engineering Computation: An Introduction Using MATLAB and Excel Set tolerance to 0.00001; answer will be accurate to 5 decimal places
  • 29. Engineering Computation: An Introduction Using MATLAB and Excel
  • 30. Engineering Computation: An Introduction Using MATLAB and Excel
  • 31. Engineering Computation: An Introduction Using MATLAB and Excel
  • 32. Engineering Computation: An Introduction Using MATLAB and Excel
  • 33. Engineering Computation: An Introduction Using MATLAB and Excel
  • 34. Engineering Computation: An Introduction Using MATLAB and Excel
  • 35. 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
  • 36. 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
  • 37. Modified Code • Add “solution tolerance” (usually looser than convergence tolerance): • Add check at end of program: Engineering Computation: An Introduction Using MATLAB and Excel
  • 38. 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
  • 39. 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