Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
