SlideShare a Scribd company logo
1 of 3
Hi, Can you answer this question. Please show all your work and show important comment
sections ( Please comment what the codes of lines do!!). Please avoid command fucntions like
nargin function command. Code w/ MATLab 2015a or higher. I know hw to do the math but
failed toomany times at coding. THank you again!!! =)
Write a function file for the bisection method to find the roots of a function. Test your code on e
a functionrition. Determine what cos(x) = x 5. the following function. Determine what your
inputs and outputs should be.
Solution
The given Matlab code uses the string facility to pass the name of a function to bisection. A %
indicates the comments
function d = bisection(fn,a1,b1,tol)
% d = bisection('fn',a1,b1,tol)
%
% Â Â This function locates a root of the function fn on the interval
%Â Â [a1,b1] to within a tolerance of tol.
% Evaluating the function to the endpoints and checking if it
% changes sign.
Fa1 = feval(fn,a1);
Fb2 = feval(fn,b1);
if Fa1*Fb2 >= 0
error('Tis fn have opposite signs at a and b')
end
% done is used to flag the unlikely event that we find
% the root exactly before the interval has been sufficiently reduced.
done = 0;
% Bisect the interval
d = (a1+b1)/2;
% Main loop
while abs(a1-b1) > 2*tol & ~done
% Evaluate the function at the midpoint
Fc1 = feval(fn,d);
if Fa1*Fc1 < 0Â Â Â Â Â Â % The root is left of d
b1 = d;
Fb1 = Fc1;
d = (a1+b1)/2;
elseif Fc1*Fb1 < 0Â Â % The root is right of d
a1 = d;
Fa1 = Fc1;
d = (a1+b1)/2;
else              % the root
done = 1;
end
end
the file is named as bisect.m, it can be run as follows:
Bisection Method Root Finding Function

More Related Content

Similar to Bisection Method Root Finding Function

Being functional in PHP
Being functional in PHPBeing functional in PHP
Being functional in PHPDavid de Boer
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013amanabr
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Kurmendra Singh
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3Ibrahim Reda
 
Funkcija, objekt, python
Funkcija, objekt, pythonFunkcija, objekt, python
Funkcija, objekt, pythonRobert Lujo
 
Functions, Types, Programs and Effects
Functions, Types, Programs and EffectsFunctions, Types, Programs and Effects
Functions, Types, Programs and EffectsRaymond Roestenburg
 
Gnu octave help book 02 of 02
Gnu octave help book 02 of 02Gnu octave help book 02 of 02
Gnu octave help book 02 of 02Arun Umrao
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...ssuserd6b1fd
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C BasicsBharat Kalia
 
OpenWRT Makefile reference
OpenWRT Makefile referenceOpenWRT Makefile reference
OpenWRT Makefile reference家榮 吳
 
Elena Macro Processor
Elena Macro ProcessorElena Macro Processor
Elena Macro ProcessorArun C S
 

Similar to Bisection Method Root Finding Function (20)

Being functional in PHP
Being functional in PHPBeing functional in PHP
Being functional in PHP
 
functions
functionsfunctions
functions
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013Dsp lab _eec-652__vi_sem_18012013
Dsp lab _eec-652__vi_sem_18012013
 
Microcontroller lec 3
Microcontroller  lec 3Microcontroller  lec 3
Microcontroller lec 3
 
Funkcija, objekt, python
Funkcija, objekt, pythonFunkcija, objekt, python
Funkcija, objekt, python
 
Functions, Types, Programs and Effects
Functions, Types, Programs and EffectsFunctions, Types, Programs and Effects
Functions, Types, Programs and Effects
 
3.5
3.53.5
3.5
 
2. operator
2. operator2. operator
2. operator
 
Gnu octave help book 02 of 02
Gnu octave help book 02 of 02Gnu octave help book 02 of 02
Gnu octave help book 02 of 02
 
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
Notes for GNU Octave - Numerical Programming - for Students - 02 of 02 by aru...
 
F# 101
F# 101F# 101
F# 101
 
Cbasic
CbasicCbasic
Cbasic
 
Programming in C Basics
Programming in C BasicsProgramming in C Basics
Programming in C Basics
 
What is c
What is cWhat is c
What is c
 
C Programming
C ProgrammingC Programming
C Programming
 
OpenWRT Makefile reference
OpenWRT Makefile referenceOpenWRT Makefile reference
OpenWRT Makefile reference
 
Haskell Jumpstart
Haskell JumpstartHaskell Jumpstart
Haskell Jumpstart
 
Elena Macro Processor
Elena Macro ProcessorElena Macro Processor
Elena Macro Processor
 
Learn C
Learn CLearn C
Learn C
 

More from tpaula2

How can I calculate the missing amounts for each of the independent ca.docx
How can I calculate the missing amounts for each of the independent ca.docxHow can I calculate the missing amounts for each of the independent ca.docx
How can I calculate the missing amounts for each of the independent ca.docxtpaula2
 
How can other countries respond to international piracy-Solutiona-) St.docx
How can other countries respond to international piracy-Solutiona-) St.docxHow can other countries respond to international piracy-Solutiona-) St.docx
How can other countries respond to international piracy-Solutiona-) St.docxtpaula2
 
How do I block a certain range of IP addresses in a CENTOS server from.docx
How do I block a certain range of IP addresses in a CENTOS server from.docxHow do I block a certain range of IP addresses in a CENTOS server from.docx
How do I block a certain range of IP addresses in a CENTOS server from.docxtpaula2
 
How can we reduce software requirement errors -SolutionIf we want to r.docx
How can we reduce software requirement errors -SolutionIf we want to r.docxHow can we reduce software requirement errors -SolutionIf we want to r.docx
How can we reduce software requirement errors -SolutionIf we want to r.docxtpaula2
 
How do arrays compare with variables and how do they differ- Give a si.docx
How do arrays compare with variables and how do they differ- Give a si.docxHow do arrays compare with variables and how do they differ- Give a si.docx
How do arrays compare with variables and how do they differ- Give a si.docxtpaula2
 
How can the use of Internet search engines to locate information about.docx
How can the use of Internet search engines to locate information about.docxHow can the use of Internet search engines to locate information about.docx
How can the use of Internet search engines to locate information about.docxtpaula2
 
How change in a corporation-'s natural and societal environments can a.docx
How change in a corporation-'s natural and societal environments can a.docxHow change in a corporation-'s natural and societal environments can a.docx
How change in a corporation-'s natural and societal environments can a.docxtpaula2
 
How can you prevent intruders from accessing your wireless network- a).docx
How can you prevent intruders from accessing your wireless network- a).docxHow can you prevent intruders from accessing your wireless network- a).docx
How can you prevent intruders from accessing your wireless network- a).docxtpaula2
 
How are standing waves similar to beats and how are they different- Ty.docx
How are standing waves similar to beats and how are they different- Ty.docxHow are standing waves similar to beats and how are they different- Ty.docx
How are standing waves similar to beats and how are they different- Ty.docxtpaula2
 
How are corporate abuse of power corporate fraud- and corporate econom.docx
How are corporate abuse of power corporate fraud- and corporate econom.docxHow are corporate abuse of power corporate fraud- and corporate econom.docx
How are corporate abuse of power corporate fraud- and corporate econom.docxtpaula2
 
How can biometric technology be used to fight cybercrime and cyber rel.docx
How can biometric technology be used to fight cybercrime and cyber rel.docxHow can biometric technology be used to fight cybercrime and cyber rel.docx
How can biometric technology be used to fight cybercrime and cyber rel.docxtpaula2
 
Holmes- CPA- assisted Williams Corporation in preparing its financial.docx
Holmes- CPA- assisted Williams Corporation in preparing its financial.docxHolmes- CPA- assisted Williams Corporation in preparing its financial.docx
Holmes- CPA- assisted Williams Corporation in preparing its financial.docxtpaula2
 
HNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docx
HNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docxHNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docx
HNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docxtpaula2
 
Hi! I think the answer is C Outsource the software- I juyst wanted to.docx
Hi! I think the answer is C Outsource the software- I juyst wanted to.docxHi! I think the answer is C Outsource the software- I juyst wanted to.docx
Hi! I think the answer is C Outsource the software- I juyst wanted to.docxtpaula2
 
Hi all! someone help me pls Fraud examination I need to write an essay.docx
Hi all! someone help me pls Fraud examination I need to write an essay.docxHi all! someone help me pls Fraud examination I need to write an essay.docx
Hi all! someone help me pls Fraud examination I need to write an essay.docxtpaula2
 
Herbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docx
Herbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docxHerbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docx
Herbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docxtpaula2
 
Here is a list of the main characters in Shakespeare-'s Romeo and Juli.docx
Here is a list of the main characters in Shakespeare-'s Romeo and Juli.docxHere is a list of the main characters in Shakespeare-'s Romeo and Juli.docx
Here is a list of the main characters in Shakespeare-'s Romeo and Juli.docxtpaula2
 
1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docx
1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docx1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docx
1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docxtpaula2
 
1- How does having a scope and WBS help project teams during project e.docx
1- How does having a scope and WBS help project teams during project e.docx1- How does having a scope and WBS help project teams during project e.docx
1- How does having a scope and WBS help project teams during project e.docxtpaula2
 
1- How did the Roman Catholc church influence music in the Middle Ages.docx
1- How did the Roman Catholc church influence music in the Middle Ages.docx1- How did the Roman Catholc church influence music in the Middle Ages.docx
1- How did the Roman Catholc church influence music in the Middle Ages.docxtpaula2
 

More from tpaula2 (20)

How can I calculate the missing amounts for each of the independent ca.docx
How can I calculate the missing amounts for each of the independent ca.docxHow can I calculate the missing amounts for each of the independent ca.docx
How can I calculate the missing amounts for each of the independent ca.docx
 
How can other countries respond to international piracy-Solutiona-) St.docx
How can other countries respond to international piracy-Solutiona-) St.docxHow can other countries respond to international piracy-Solutiona-) St.docx
How can other countries respond to international piracy-Solutiona-) St.docx
 
How do I block a certain range of IP addresses in a CENTOS server from.docx
How do I block a certain range of IP addresses in a CENTOS server from.docxHow do I block a certain range of IP addresses in a CENTOS server from.docx
How do I block a certain range of IP addresses in a CENTOS server from.docx
 
How can we reduce software requirement errors -SolutionIf we want to r.docx
How can we reduce software requirement errors -SolutionIf we want to r.docxHow can we reduce software requirement errors -SolutionIf we want to r.docx
How can we reduce software requirement errors -SolutionIf we want to r.docx
 
How do arrays compare with variables and how do they differ- Give a si.docx
How do arrays compare with variables and how do they differ- Give a si.docxHow do arrays compare with variables and how do they differ- Give a si.docx
How do arrays compare with variables and how do they differ- Give a si.docx
 
How can the use of Internet search engines to locate information about.docx
How can the use of Internet search engines to locate information about.docxHow can the use of Internet search engines to locate information about.docx
How can the use of Internet search engines to locate information about.docx
 
How change in a corporation-'s natural and societal environments can a.docx
How change in a corporation-'s natural and societal environments can a.docxHow change in a corporation-'s natural and societal environments can a.docx
How change in a corporation-'s natural and societal environments can a.docx
 
How can you prevent intruders from accessing your wireless network- a).docx
How can you prevent intruders from accessing your wireless network- a).docxHow can you prevent intruders from accessing your wireless network- a).docx
How can you prevent intruders from accessing your wireless network- a).docx
 
How are standing waves similar to beats and how are they different- Ty.docx
How are standing waves similar to beats and how are they different- Ty.docxHow are standing waves similar to beats and how are they different- Ty.docx
How are standing waves similar to beats and how are they different- Ty.docx
 
How are corporate abuse of power corporate fraud- and corporate econom.docx
How are corporate abuse of power corporate fraud- and corporate econom.docxHow are corporate abuse of power corporate fraud- and corporate econom.docx
How are corporate abuse of power corporate fraud- and corporate econom.docx
 
How can biometric technology be used to fight cybercrime and cyber rel.docx
How can biometric technology be used to fight cybercrime and cyber rel.docxHow can biometric technology be used to fight cybercrime and cyber rel.docx
How can biometric technology be used to fight cybercrime and cyber rel.docx
 
Holmes- CPA- assisted Williams Corporation in preparing its financial.docx
Holmes- CPA- assisted Williams Corporation in preparing its financial.docxHolmes- CPA- assisted Williams Corporation in preparing its financial.docx
Holmes- CPA- assisted Williams Corporation in preparing its financial.docx
 
HNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docx
HNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docxHNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docx
HNO2 has a Ka of 4-00x10^-3- What is the pH of a solution prepared by.docx
 
Hi! I think the answer is C Outsource the software- I juyst wanted to.docx
Hi! I think the answer is C Outsource the software- I juyst wanted to.docxHi! I think the answer is C Outsource the software- I juyst wanted to.docx
Hi! I think the answer is C Outsource the software- I juyst wanted to.docx
 
Hi all! someone help me pls Fraud examination I need to write an essay.docx
Hi all! someone help me pls Fraud examination I need to write an essay.docxHi all! someone help me pls Fraud examination I need to write an essay.docx
Hi all! someone help me pls Fraud examination I need to write an essay.docx
 
Herbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docx
Herbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docxHerbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docx
Herbie Corp-'s Balance Sheet showed the following at 12-31-13 Common S.docx
 
Here is a list of the main characters in Shakespeare-'s Romeo and Juli.docx
Here is a list of the main characters in Shakespeare-'s Romeo and Juli.docxHere is a list of the main characters in Shakespeare-'s Romeo and Juli.docx
Here is a list of the main characters in Shakespeare-'s Romeo and Juli.docx
 
1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docx
1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docx1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docx
1- How many ATOMS of sulfur are present in 2-25 moles of sulfur trioxi.docx
 
1- How does having a scope and WBS help project teams during project e.docx
1- How does having a scope and WBS help project teams during project e.docx1- How does having a scope and WBS help project teams during project e.docx
1- How does having a scope and WBS help project teams during project e.docx
 
1- How did the Roman Catholc church influence music in the Middle Ages.docx
1- How did the Roman Catholc church influence music in the Middle Ages.docx1- How did the Roman Catholc church influence music in the Middle Ages.docx
1- How did the Roman Catholc church influence music in the Middle Ages.docx
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Bisection Method Root Finding Function

  • 1. Hi, Can you answer this question. Please show all your work and show important comment sections ( Please comment what the codes of lines do!!). Please avoid command fucntions like nargin function command. Code w/ MATLab 2015a or higher. I know hw to do the math but failed toomany times at coding. THank you again!!! =) Write a function file for the bisection method to find the roots of a function. Test your code on e a functionrition. Determine what cos(x) = x 5. the following function. Determine what your inputs and outputs should be. Solution The given Matlab code uses the string facility to pass the name of a function to bisection. A % indicates the comments function d = bisection(fn,a1,b1,tol) % d = bisection('fn',a1,b1,tol) % % Â Â This function locates a root of the function fn on the interval %Â Â [a1,b1] to within a tolerance of tol. % Evaluating the function to the endpoints and checking if it % changes sign. Fa1 = feval(fn,a1); Fb2 = feval(fn,b1); if Fa1*Fb2 >= 0 error('Tis fn have opposite signs at a and b')
  • 2. end % done is used to flag the unlikely event that we find % the root exactly before the interval has been sufficiently reduced. done = 0; % Bisect the interval d = (a1+b1)/2; % Main loop while abs(a1-b1) > 2*tol & ~done % Evaluate the function at the midpoint Fc1 = feval(fn,d); if Fa1*Fc1 < 0      % The root is left of d b1 = d; Fb1 = Fc1; d = (a1+b1)/2; elseif Fc1*Fb1 < 0  % The root is right of d a1 = d; Fa1 = Fc1; d = (a1+b1)/2; else              % the root done = 1; end end the file is named as bisect.m, it can be run as follows: