SlideShare a Scribd company logo
n this module, I include a file called Bisection Technique. I use
an example similar to the textbook described in section 2.1. I
start to solve the example by hand and complete it using
MATLAB. After reading the Bisection technique lesson 4 and
section 2.1 of the textbook, answer the following discussion
question in your own words.
When running the Bisection method in lesson 4 (program 1.1),
with a tolerance of 0.001 the answer is 1.3652 which is
equivalent to p9 according to the table 2.1 from the textbook.
When running p13 in lesson 4 (program 1.2), the answer is
1.3651 which is equivalent to p13. Which one of the answers
do you think is the most accurate answer closest to the solution
and why? Which of the two calculation methods do you prefer
and why? Elaborate in your answers.
file attached
Lesson 4
Bisection Technique
To find a solution or root of an equation f(x) we can apply the
bisection method, which is an
approximation technique to get closer and closer to the value of
the root by dividing the
interval in half after each iteration. The bisection method or
binary search technique is based
on the Intermediate Value Theorem. Suppose f is a continuous
function on the interval [a,b]
with f(a) and f(b) of opposite sign, the Intermediate Value
Theorem implies that a number p
exists in [a,b] with f(p) = 0. The method calls for a repeated
halving or bisecting of subintervals
of [a,b] and at each step locating the half containing p.
Example:
Does
f(x) = x
3
+4x
2
-10
has a root or solution in
[a,b] = [1,2]?
1) Let’s check if f(1) and f(2) have opposite signs according to
the Intermediate Value
Theorem.
f(a) = f(1)
= (1)
3
+ 4(1)
2
– 10 = -5
(negative)
f(b) = f(2)
= (2)
3
+ 4(2)
2
– 10 = 8+16-10 = 14
(positive)
The answer is yes, which means since f is continuous there must
be a solution in the
interval [1,2].
2) Let p be the solution we are searching for and let p1 be the
first midpoint of [a,b] = [1,2].
p1
= (a+b)/2 = (1+2)/2 = 3/2 = 1.5
f(p1)
=
f(1.5)
= (1.5)
3
+4(1.5)
2
-10 = 2.375
(positive)
3) If
f(p1)
= 0
then p1 is the root or the solution, so p= p1. Done.
Otherwise, if
f(p1)
is not equal to zero, which is the case, we’re going to replace
either a or b by
p1 to obtain a new interval closer to the root or the solution.
How do we know which one to replace? Simple. The goal is to
keep two intervals of which
their functions have opposite signs when we calculate the
function
f
at these two intervals. The
question to ask is rather which of the two
f(a)
and
f(b)
has opposite sign to the function
f(p1)
?
a) If
f(p1)
and
f(a)
have the same sign, then they don’t satisfy the Intermediate
Value
Theorem. We replace
a
by
p1
, so the new interval that contains the solution p will be
[p1, b].
b) If
f(p1)
and
f(a)
have opposite signs, then they satisfy the Intermediate Value
Theorem.
We replace
b
by
p1
so the new interval that contains the solution p will be [a, p1].
In our case,
f(a) which is f(1)
has opposite sign to
f(p1) which is f(1.5)
. We replace (
b
which is 2 by
p1
which is 1.5). The new interval that contains a solution is [a,
p1] = [1,
1.5].
Next we go back to step 2 and step 3 by repeating this process
again to find the new
midpoint p2, check if p2 is the solution, if not obtain a new
interval.
Let’s continue with steps 2 and 3.
Step 2:
a. let p2 be the second midpoint of [a, p1] = [1, 1.5].
p2
= (a+p1)/2 = (1+1.5)/2 = 2.5/2 = 1.25
f(p2)
= f(1.25) = (1.25)
3
+4(1.25)
2
-10 = -1.796875
(negative)
Step 3:
Which of the two
f(a)
and
f(p1)
has opposite sign to the function
f(p2)
OR
Which of the two
f(1)
and
f(1.5)
has opposite sign to the function
f(1.25)
?
f(a)
=
f(1)
= -5;
f(p1) = f(1.5) = 2.375;
f(p2) = f(1.25) = -1.796875
The answer is
f(p1) = f(1.5)
and
f(p2) = f(1.25), so we replace a by p2.
Therefore, the new interval that contains a solution i s: [p2, p1]
= [1.25, 1.5].
We repeat steps 2 and 3 again and again until
f(midpoint) = 0
or within a Tolerance, let’s
say 0.001 = 10
-4
.
To do this we can use the MATLAB tool. The following
program 1.1 can be used to find
the root of the same function using bisection method with a
tolerance of 0.001 = 10
-4
%Program 1.1 Bisection Method
%Computes approximate solution of f(x)=0
%Input: inline function f; a,b such that f(a)*f(b)<0,
% and tolerance tol
%Output: Approximate solution xc
function xc = bisect(f,a,b,tol)
if sign(f(a))*sign(f(b)) >= 0,
error('f(a)f(b)<0 not satisfied!')
%ceases execution
end
fa=f(a);
fb=f(b);
k = 0;
while (b-a)/2>tol
c=(a+b)/2;
fc=f(c);
if fc == 0
%c is a solution, done
break
end
if sign(fc)*sign(fa)<0 %
a and c make the new interval
b=c;fb=fc;
else %
c and b make the new interval
a=c;fa=fc;
end
end
xc=(a+b)/2;
%new midpoint is best estimate
1. Copy and paste this program in MATLAB in the editor
window.
2. Save the program as bisect.
3. To run the program, type the following in the command
window:
>> bisect(@(x) x^3+4*x^2-10,1,2,0.0001)
@(x) x^3+4*x^2-10
represents the function
1,2
represents the interval
0.01
represents the Tolerance.
The output is:
ans =
1.3652
The following MATLAB program 1.2 can be used to find the
root of the same function
using bisection method with 13 iterations meaning that we will
find the midpoint 13 times pn =
p13.
%Program 1.2 Bisection Method
function [x e] = mybisect(f,a,b,n)
% function [x e] = mybisect(f,a,b,n)
% Does n iterations of the bisection method for a function f
% Inputs: f -- an inline function
% a,b -- left and right edges of the interval
% n -- the number of bisections to do.
% Outputs: x -- the estimated solution of f(x) = 0
% e -- an upper bound on the error
format long
c = f(a); d = f(b);
if c*d > 0.0
error('Function has same sign at both endpoints.')
end
disp(' x y')
for i = 1:n
x = (a + b)/2;
y = f(x);
disp([ x y])
if y == 0.0
% solved the equation exactly
e = 0;
break
% jumps out of the for loop
end
if c*y < 0
b=x;
else
a=x;
end
end
e = (b-a)/2;
1. Copy and paste this program in MATLAB in the editor
window.
2. Save the program as bisection.
3. To run the program, type the following in the command
window:
>> bisection(@(x) x^3+4*x^2-10,1,2,13)
@(x) x^3+4*x^2-10
represents the function
1,2
represents the interval
13
represents the number of iterations.
The output is:
x
y
1.500000000000000 2.375000000000000
1.250000000000000 -1.796875000000000
1.375000000000000 0.162109375000000
1.312500000000000 -0.848388671875000
1.343750000000000 -0.350982666015625
1.359375000000000 -0.096408843994141
1.367187500000000 0.032355785369873
1.363281250000000 -0.032149970531464
1.365234375000000 0.000072024762630
1.364257812500000 -0.016046690754592
1.364746093750000 -0.007989262812771
1.364990234375000 -0.003959101522923
1.365112304687500 -0.001943659010067
ans =
1.365112304687500

More Related Content

PPT
Bisection method in maths 4
PPTX
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
PPTX
Bisection Method
DOCX
Hi- Can you answer this question- Please show all your work and show i.docx
PPTX
Bisection method
PPTX
Bisection & Regual falsi methods
PPTX
Bisection method
PPTX
bisectionmethod-130831052031-phpapp02.pptx
Bisection method in maths 4
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
Bisection Method
Hi- Can you answer this question- Please show all your work and show i.docx
Bisection method
Bisection & Regual falsi methods
Bisection method
bisectionmethod-130831052031-phpapp02.pptx

Similar to n this module, I include a file called Bisection Technique. I us (20)

PPT
ROOTS EQUATIONS
PDF
NA-Ch2-Student.pdf numerical computing chapter 2 solution
PPTX
Numerical Method 2
PPTX
PPTX
Quantitive Techniques: Bisection method
PPTX
Bisection
PDF
The Bisection Method: A Simple & Reliable Root-Finding Algorithm
PPTX
PO_groupVI_Term assignment.pptx
PDF
Nl eqn lab
DOCX
Bisection method
 
PPTX
Presentation on the bisection method.pptx
PDF
PPTX
BIsection method maths linear and .pptx
PPT
Applications of numerical methods
PPTX
PDF
Adv. Num. Tech. 1 Roots of function.pdf
PDF
Matlab lecture 5 bisection method@taj
PDF
Chapter 2 solving nonlinear equations
PPTX
Analysis for engineers _roots_ overeruption
PPT
Bisection and fixed point method
ROOTS EQUATIONS
NA-Ch2-Student.pdf numerical computing chapter 2 solution
Numerical Method 2
Quantitive Techniques: Bisection method
Bisection
The Bisection Method: A Simple & Reliable Root-Finding Algorithm
PO_groupVI_Term assignment.pptx
Nl eqn lab
Bisection method
 
Presentation on the bisection method.pptx
BIsection method maths linear and .pptx
Applications of numerical methods
Adv. Num. Tech. 1 Roots of function.pdf
Matlab lecture 5 bisection method@taj
Chapter 2 solving nonlinear equations
Analysis for engineers _roots_ overeruption
Bisection and fixed point method

More from EstelaJeffery653 (20)

DOCX
Individual ProjectMedical TechnologyWed, 9617Num.docx
DOCX
Individual ProjectThe Post-Watergate EraWed, 3817Numeric.docx
DOCX
Individual ProjectArticulating the Integrated PlanWed, 31.docx
DOCX
Individual Multilingualism Guidelines1)Where did the a.docx
DOCX
Individual Implementation Strategiesno new messagesObjectives.docx
DOCX
Individual Refine and Finalize WebsiteDueJul 02View m.docx
DOCX
Individual Cultural Communication Written Assignment  (Worth 20 of .docx
DOCX
Individual ProjectThe Basic Marketing PlanWed, 3117N.docx
DOCX
Individual ProjectFinancial Procedures in a Health Care Organiza.docx
DOCX
Individual Expanded Website PlanView more »Expand view.docx
DOCX
Individual Expanded Website PlanDueJul 02View more .docx
DOCX
Individual Communicating to Management Concerning Information Syste.docx
DOCX
Individual Case Analysis-MatavIn max 4 single-spaced total pag.docx
DOCX
Individual Assignment Report Format• Report should contain not m.docx
DOCX
Include LOCO api that allows user to key in an address and get the d.docx
DOCX
Include the title, the name of the composer (if known) and of the .docx
DOCX
include as many events as possible to support your explanation of th.docx
DOCX
Incorporate the suggestions that were provided by your fellow projec.docx
DOCX
inal ProjectDUE Jun 25, 2017 1155 PMGrade DetailsGradeNA.docx
DOCX
include 1page proposal- short introduction to research paper and yo.docx
Individual ProjectMedical TechnologyWed, 9617Num.docx
Individual ProjectThe Post-Watergate EraWed, 3817Numeric.docx
Individual ProjectArticulating the Integrated PlanWed, 31.docx
Individual Multilingualism Guidelines1)Where did the a.docx
Individual Implementation Strategiesno new messagesObjectives.docx
Individual Refine and Finalize WebsiteDueJul 02View m.docx
Individual Cultural Communication Written Assignment  (Worth 20 of .docx
Individual ProjectThe Basic Marketing PlanWed, 3117N.docx
Individual ProjectFinancial Procedures in a Health Care Organiza.docx
Individual Expanded Website PlanView more »Expand view.docx
Individual Expanded Website PlanDueJul 02View more .docx
Individual Communicating to Management Concerning Information Syste.docx
Individual Case Analysis-MatavIn max 4 single-spaced total pag.docx
Individual Assignment Report Format• Report should contain not m.docx
Include LOCO api that allows user to key in an address and get the d.docx
Include the title, the name of the composer (if known) and of the .docx
include as many events as possible to support your explanation of th.docx
Incorporate the suggestions that were provided by your fellow projec.docx
inal ProjectDUE Jun 25, 2017 1155 PMGrade DetailsGradeNA.docx
include 1page proposal- short introduction to research paper and yo.docx

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Sports Quiz easy sports quiz sports quiz
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Complications of Minimal Access Surgery at WLH
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O7-L3 Supply Chain Operations - ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
GDM (1) (1).pptx small presentation for students
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial disease of the cardiovascular and lymphatic systems
01-Introduction-to-Information-Management.pdf
Pharma ospi slides which help in ospi learning
VCE English Exam - Section C Student Revision Booklet
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Sports Quiz easy sports quiz sports quiz
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Final Presentation General Medicine 03-08-2024.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

n this module, I include a file called Bisection Technique. I us

  • 1. n this module, I include a file called Bisection Technique. I use an example similar to the textbook described in section 2.1. I start to solve the example by hand and complete it using MATLAB. After reading the Bisection technique lesson 4 and section 2.1 of the textbook, answer the following discussion question in your own words. When running the Bisection method in lesson 4 (program 1.1), with a tolerance of 0.001 the answer is 1.3652 which is equivalent to p9 according to the table 2.1 from the textbook. When running p13 in lesson 4 (program 1.2), the answer is 1.3651 which is equivalent to p13. Which one of the answers do you think is the most accurate answer closest to the solution and why? Which of the two calculation methods do you prefer and why? Elaborate in your answers. file attached Lesson 4 Bisection Technique To find a solution or root of an equation f(x) we can apply the bisection method, which is an approximation technique to get closer and closer to the value of the root by dividing the interval in half after each iteration. The bisection method or binary search technique is based
  • 2. on the Intermediate Value Theorem. Suppose f is a continuous function on the interval [a,b] with f(a) and f(b) of opposite sign, the Intermediate Value Theorem implies that a number p exists in [a,b] with f(p) = 0. The method calls for a repeated halving or bisecting of subintervals of [a,b] and at each step locating the half containing p. Example: Does f(x) = x 3 +4x 2 -10 has a root or solution in [a,b] = [1,2]? 1) Let’s check if f(1) and f(2) have opposite signs according to the Intermediate Value Theorem. f(a) = f(1)
  • 3. = (1) 3 + 4(1) 2 – 10 = -5 (negative) f(b) = f(2) = (2) 3 + 4(2) 2 – 10 = 8+16-10 = 14 (positive) The answer is yes, which means since f is continuous there must be a solution in the interval [1,2]. 2) Let p be the solution we are searching for and let p1 be the first midpoint of [a,b] = [1,2]. p1
  • 4. = (a+b)/2 = (1+2)/2 = 3/2 = 1.5 f(p1) = f(1.5) = (1.5) 3 +4(1.5) 2 -10 = 2.375 (positive) 3) If f(p1) = 0 then p1 is the root or the solution, so p= p1. Done. Otherwise, if f(p1) is not equal to zero, which is the case, we’re going to replace either a or b by
  • 5. p1 to obtain a new interval closer to the root or the solution. How do we know which one to replace? Simple. The goal is to keep two intervals of which their functions have opposite signs when we calculate the function f at these two intervals. The question to ask is rather which of the two f(a) and f(b) has opposite sign to the function f(p1) ? a) If f(p1) and f(a) have the same sign, then they don’t satisfy the Intermediate Value
  • 6. Theorem. We replace a by p1 , so the new interval that contains the solution p will be [p1, b]. b) If f(p1) and f(a) have opposite signs, then they satisfy the Intermediate Value Theorem. We replace b by p1 so the new interval that contains the solution p will be [a, p1].
  • 7. In our case, f(a) which is f(1) has opposite sign to f(p1) which is f(1.5) . We replace ( b which is 2 by p1 which is 1.5). The new interval that contains a solution is [a, p1] = [1, 1.5]. Next we go back to step 2 and step 3 by repeating this process again to find the new midpoint p2, check if p2 is the solution, if not obtain a new interval. Let’s continue with steps 2 and 3. Step 2: a. let p2 be the second midpoint of [a, p1] = [1, 1.5].
  • 8. p2 = (a+p1)/2 = (1+1.5)/2 = 2.5/2 = 1.25 f(p2) = f(1.25) = (1.25) 3 +4(1.25) 2 -10 = -1.796875 (negative) Step 3: Which of the two f(a) and f(p1) has opposite sign to the function f(p2) OR Which of the two
  • 9. f(1) and f(1.5) has opposite sign to the function f(1.25) ? f(a) = f(1) = -5; f(p1) = f(1.5) = 2.375; f(p2) = f(1.25) = -1.796875 The answer is f(p1) = f(1.5) and f(p2) = f(1.25), so we replace a by p2. Therefore, the new interval that contains a solution i s: [p2, p1] = [1.25, 1.5].
  • 10. We repeat steps 2 and 3 again and again until f(midpoint) = 0 or within a Tolerance, let’s say 0.001 = 10 -4 . To do this we can use the MATLAB tool. The following program 1.1 can be used to find the root of the same function using bisection method with a tolerance of 0.001 = 10 -4 %Program 1.1 Bisection Method %Computes approximate solution of f(x)=0 %Input: inline function f; a,b such that f(a)*f(b)<0, % and tolerance tol %Output: Approximate solution xc function xc = bisect(f,a,b,tol) if sign(f(a))*sign(f(b)) >= 0,
  • 11. error('f(a)f(b)<0 not satisfied!') %ceases execution end fa=f(a); fb=f(b); k = 0; while (b-a)/2>tol c=(a+b)/2; fc=f(c); if fc == 0 %c is a solution, done break end if sign(fc)*sign(fa)<0 % a and c make the new interval b=c;fb=fc;
  • 12. else % c and b make the new interval a=c;fa=fc; end end xc=(a+b)/2; %new midpoint is best estimate 1. Copy and paste this program in MATLAB in the editor window. 2. Save the program as bisect. 3. To run the program, type the following in the command window: >> bisect(@(x) x^3+4*x^2-10,1,2,0.0001) @(x) x^3+4*x^2-10 represents the function 1,2 represents the interval 0.01 represents the Tolerance.
  • 13. The output is: ans = 1.3652 The following MATLAB program 1.2 can be used to find the root of the same function using bisection method with 13 iterations meaning that we will find the midpoint 13 times pn = p13. %Program 1.2 Bisection Method function [x e] = mybisect(f,a,b,n) % function [x e] = mybisect(f,a,b,n) % Does n iterations of the bisection method for a function f % Inputs: f -- an inline function % a,b -- left and right edges of the interval % n -- the number of bisections to do. % Outputs: x -- the estimated solution of f(x) = 0
  • 14. % e -- an upper bound on the error format long c = f(a); d = f(b); if c*d > 0.0 error('Function has same sign at both endpoints.') end disp(' x y') for i = 1:n x = (a + b)/2; y = f(x); disp([ x y]) if y == 0.0 % solved the equation exactly e = 0; break % jumps out of the for loop end if c*y < 0
  • 15. b=x; else a=x; end end e = (b-a)/2; 1. Copy and paste this program in MATLAB in the editor window. 2. Save the program as bisection. 3. To run the program, type the following in the command window: >> bisection(@(x) x^3+4*x^2-10,1,2,13) @(x) x^3+4*x^2-10 represents the function 1,2 represents the interval
  • 16. 13 represents the number of iterations. The output is: x y 1.500000000000000 2.375000000000000 1.250000000000000 -1.796875000000000 1.375000000000000 0.162109375000000 1.312500000000000 -0.848388671875000 1.343750000000000 -0.350982666015625 1.359375000000000 -0.096408843994141 1.367187500000000 0.032355785369873 1.363281250000000 -0.032149970531464 1.365234375000000 0.000072024762630 1.364257812500000 -0.016046690754592