Question
****READING IS KEY**** ***THIS IS FOR MATLAB ONLY*** ***THIS IS FOR MATLAB ONLY*** ***THIS IS FOR MATLAB ONLY*** ***************************I ONLY NEED HELP WITH PART D)****************************
****READING IS KEY****
***THIS IS FOR MATLAB ONLY*** ***THIS IS FOR MATLAB ONLY*** ***THIS IS FOR MATLAB ONLY***
***************************I ONLY NEED HELP WITH PART D)****************************
***************************I ONLY NEED HELP WITH PART D)****************************
***************************I ONLY NEED HELP WITH PART D)****************************
PARTS B) AND C) ARE MENTIONED IN PART D) FOR REFERENCE
PLEASE READ INSTRUCTIONS CAREFULLY AS I HAVE PROVIDED THE BISECTION ALGORITHM FOR YOU TO USE
**********BISECTION ALGORITHM***********
function r = bisection(f, a, b, tol, maxits) i=1; FA=f(a); r=[]; while i0 a=p; FA=FP; else b=p; end if i == maxits && p >= maxtol fprintf(' ') warning('Maximum number of iterations reached before convergence') fprintf(' Solution not obtained in %d iterations. ',maxits); end end fprintf('Method failed after %d iterations ',maxits)
**************************************************************************************
2. Read doc fzero to learn how to use MATLAB's fzero routine. This is an accelcrated version of bisection called the Brent-Dekker algorithm, not covered in the textbook (but referenced briefly in $2.7.) (a) Try it out on the previous example: fzero (osin, [a b]), replacing a and b with the ones you used. How many digits are correct? (b) Try out fzero's Display option: fzero (Otan, [1 2]) fzero (Otan, [1 2], optimset ('Display', 'iter)) (Note: the second command may help you complete Question 1(b).) (c) Try out fzero's PlotFcns option: fzero(Osin, [3 4], optinset ('PlotFcns',Coptimplotfval)) (d) Add an optional sixth input argument to your function bisection, so that bisection(f, a, b, tol, maxits, 'iter') outputs all approximations to the root, not just the last one see Part (b)and so that bisection(f. a. b, tol, axits, 'plot') generates a plot of the iteration history see Part (c). (You'll need to use varargin and strcmp.)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started