Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

X Bisection Method 1 solution submitted (max: 10) View my solutions Implement the bisection method as a function: function [p, n] = bisect(f, a,b, tol)

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
X Bisection Method 1 solution submitted (max: 10) View my solutions Implement the bisection method as a function: function [p, n] = bisect(f, a,b, tol) We seek a root of the anonymous function f in the interval [a, b]. The function should return an approximation p that is within a user input tol of the actual root as well as the number of iterations n it took to converge As a class convention, we will take p to be the midpoint of the first interval smaller than tol As a class convention, we will count the first bisection as the midpoint of the supplied interval ab You do not need to worry about the exceptional case when a bisection lands exactly on a root (You can if you want to, but you may assume this does not occur) Debugging tips: . If you are receiving an error message Unrecognized function or variable 'p' along with other errors and no test passed, check your stopping criteria. If you use the incorrect stopping criteria, your code will go into an Infinite loop on one of the tests and never finish (so no outputs will be defined, hence the error message) There may be other problems, but this is most likely the cause If test 1 is your only correct test, you are actually very close to correct code! It is likely that you stopped when the interval was shorter than tol, however, your value of p was not the midpoint of this interval. If you correct this, it is likely that this will provide passing results on all tests . If you number of iterations n is off by one, try changing your initialization of n and/or the location of udating n in the loop. The first bisection (n=1) counts as the midpoint of the first interval 1 function (p.n] - bisect(f.a,b, tol) 2 Xinput f, anonymous function for which we'd like to find a root 3 Xinputs a,b left and right ends for which f(a) f(b)

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

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago