Answered step by step
Verified Expert Solution
Link Copied!

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 = bisect(f,a,b,tol)
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.
8BISECT Find root using the bisection method
8 Function BISECT approximates the root of a function of a single
& variable f on the interval [a b] within a tolerance. The given
interval
8 must contain a sign change for f. This is because we rely on the
Intermediate Value Theorem to guarantee a solution.
Syntax:
m=bisect(f,a,b)
Input:
f- function of a single variable, in-line or anonymous
a - left endpoint of interval
b - right endpoint of interval
--Optional--
tol - error tolerance of final result, default 1e-10
Output:
m - approximate root, midpoint of final interval
& Check inputs
if a>b
temp =ai???
)
)
end
if nargin 4
tol =1e-10;
end
assert , 'The function must differ in sign at the
endpoints')
while ?abs(a-b)>2*** tol
scompute midpoint
end
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions