Answered step by step
Verified Expert Solution
Question
1 Approved Answer
USE THIS CODE and finish it using these credentials: bisect.m Write a function that implements the bisection method. Its syntax is m = bisect (
USE THIS CODE and finish it using these credentials:
bisect.m
Write a function that implements the bisection method. Its syntax is
m bisectfabtol
where m f a b and tol are all defined as in the notes. Use the included bisect.m as a starting point.
No credit will be given for scripts or for functions that prompt the user for input. The functions must accept arguments in the proper order as part of the function call and return outputs of the correct type. Also, do not show any intermediate calculations in the Command Window. Only the output of the function should appear.
BISECT Find root using the bisection method
Function BISECT approximates the root of a function of a single
& variable on the interval a b within a tolerance. The given
interval
must contain a sign change for This is because we rely on the
Intermediate Value Theorem to guarantee a solution.
Syntax:
bisect
Input:
function of a single variable, inline or anonymous
a left endpoint of interval
b right endpoint of interval
Optional
tol error tolerance of final result, default e
Output:
m approximate root, midpoint of final interval
& Check inputs
if
temp
end
if nargin
tol ;
end
assert 'The function must differ in sign at the
endpoints'
while tol
scompute midpoint
end
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