0% found this document useful (0 votes)
40 views13 pages

Lecture No. 2

The document discusses the Bisection Method, a numerical technique for finding roots of non-linear algebraic equations. It explains the method's basis, algorithm, advantages, and disadvantages, along with a detailed example of finding a root for the equation f(x)=x^3-x-1. Additionally, it provides MATLAB code for implementing the Bisection Method and poses questions for practice.

Uploaded by

Muneeb Tahir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views13 pages

Lecture No. 2

The document discusses the Bisection Method, a numerical technique for finding roots of non-linear algebraic equations. It explains the method's basis, algorithm, advantages, and disadvantages, along with a detailed example of finding a root for the equation f(x)=x^3-x-1. Additionally, it provides MATLAB code for implementing the Bisection Method and poses questions for practice.

Uploaded by

Muneeb Tahir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Lecture 3

Root finding in non-linear


Algebraic equation
(Bisection Method)
Dr. Abdul Haleem Hamid
Root of non-linear Algebraic
equation
• Roots of an equation are the values of x that
make f(x) =0. These roots are also known as
solutions or can be real or complex. Some
time the exact roots of nonlinear algebraic
equation are easy to find. So Numerical
methods are used to approximate these
roots with a specified level of accuracy.
Many method are used to find root of
nonlinear algebraic equation . The first
method is bisection method:
Bisection Method
• The Bisection Method is a simple and reliable
numerical technique used to find the root of a
continuous function f(x) within a given interval
[a,b]. The method is based on the Intermediate
Value Theorem, which states that if f (a) and f (b)
have opposite signs (f (a) ⋅f (b) <0), then there is
at least one root in the interval [a,b].
Basis of Bisection Method
• An equation f(x)=0, where f(x) is a real continuous
function, has at least one root between x1 and x2 if f(x1)
f(x2) < 0.

𝑥1
𝑥2
Algorithm for Bisection
Method
• Initial Condition: The function f(x) must be continuous in [,b]
and f(a) and f(b) must have opposite signs.
Step1:Find the midpoint of the interval: c= (a+b)/2.
Step2:Evaluate f(c):
Step3:If f(c) =0, c is the root.
• If f(a)⋅f(c)< 0, the root lies in [a,c] update b=c
• If f (b) ⋅f(c) <0, the root lies in [c,b]; update a=c.
Step4:Repeat until the interval is sufficiently small or a desired
accuracy is achieved.
Advantages
• Simple and easy to implement.
• Always convergent
• The root bracket gets halved with each iteration -
guaranteed.
Disadvantages
 Slow convergence
 If one of the initial guesses is close to the root, the
convergence is slower
 If a function f(x) is such that it just touches the x-axis it
will be unable to find the lower and upper guesses.
 Function changes sign but root does not exist
Example 1
Find a root of an equation f(x)=x^3-x-1 using Bisection method
Solution
Since
f(x)=x^3-x-1
x=0 then f(0)=-1 <0
x=1 then f(1)=-1 <0
x=2 then f(2)=5 >0
So root lies between x= 1 and x=2

x 0 1 2
f(x) -1 -1 5
Example 1(Cont.)
• 1st iteration :

Here f(1)=-1<0 and f(2)=5>0

∴ Now, Root lies between 1 and 2

x0=(1+2)/2=1.5

f(x0)=f(1.5)=0.875>0

2nd iteration :

Here f(1)=-1<0 and f(1.5)=0.875>0

∴ Now, Root lies between 1 and 1.5

x1=(1+1.5)/2=1.25

f(x1)=f(1.25)=-0.29688<0
Example 1(Cont.)
3rd iteration :

Here f(1.25)=-0.29688<0 and f(1.5)=0.875>0

∴ Now, Root lies between 1.25 and 1.5

x2=(1.25+1.5)/2=1.375

f(x2)=f(1.375)=0.22461>0

4th iteration :

Here f(1.25)=-0.29688<0 and f(1.375)=0.22461>0

∴ Now, Root lies between 1.25 and 1.375

x3=(1.25+1.375)2=1.3125

f(x3)=f(1.3125)=-0.05151<0
Table
n a f(a) b f(b) c=(a+b)2 f(c) Update
1 1 -1 2 5 1.5 0.875 b=c
2 1 -1 1.5 0.875 1.25 -0.29688 a=c
3 1.25 -0.29688 1.5 0.875 1.375 0.22461 b=c
4 1.25 -0.29688 1.375 0.22461 1.3125 -0.05151 a=c
5 1.3125 -0.05151 1.375 0.22461 1.34375 0.08261 b=c
6 1.3125 -0.05151 1.34375 0.08261 1.32812 0.01458 b=c
7 1.3125 -0.05151 1.32812 0.01458 1.32031 -0.01871 a=c
8 1.32031 -0.01871 1.32812 0.01458 1.32422 -0.00213 a=c
9 1.32422 -0.00213 1.32812 0.01458 1.32617 0.00621 b=c
10 1.32422 -0.00213 1.32617 0.00621 1.3252 0.00204 b=c
11 1.32422 -0.00213 1.3252 0.00204 1.32471 -0.00005 a=c
Questions
• Find a root of the following
equation using Bisection method
i) f(x)=x^2 – sin(x) – 0.5
ii) f(x)=2x^3-2x-5
iii) f(x)= cos(x) – x *e^x
iv) f(x)=3x + sin(x) – e^x
Matlab code
• clc
• f=@(x)x^2-sin(x)-0.5 %main function
• a=0; % value of x1
• b=2; %value of x2
• c=(a+b)/2 %calculate x3
• for i=1:15
• iteration = i+1
• if f(a)*f(b)<0
• if f(a)<0 && f(c)<0
• a=c;
• else
• b=c;
• end
• end
• c=(a+b)/2
• end

You might also like