Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Implement the bisection method (textbook $2.1). Your function should have the following signature, function r -bisection(f, a, b, tol, maxits) where f is a

image text in transcribed

1. Implement the bisection method (textbook $2.1). Your function should have the following signature, function r -bisection(f, a, b, tol, maxits) where f is a function handle and a, b, tol, maxits, and r are numbers. Your implementation can assume that . sign(f(a))sign(f(b)) f is continuous on [a, bl. tol is nonnegative, and maxits is a positive integer Your implementation should estimate the absolute error as one-half the width of the current search interval and terminate once this estimate no longer exceeds tol. Additionally, your implementation should perform at most maxits iterations, and should report a warning to the user if your error estimate still exceeds tol after maxits iterations. (This matches the functionality in the textbook's implementation, Algorithm 2.1.) (a) Test your code by using it to approximate the root of sin(z). (Pick a and b to 'bracket' this root.) Find values of tol and maxits so that the six leading digits of r are correct (3.14159). (b) Use your code to try to find a root of tan(x) on the interval [1,2. Explain what happens. (c) Challenge (optional/ungraded) Implement bisection using recursion (vs. iteration) d) Challenge (optional/ungraded The textbook claims that it is preferable (in floating point) to compute the midpoint as c a+(b-a)/2, rather than c - (a+b)/2. Find an interval [a, bl where this makes a difference, and explain what might go wrong when using the latter formula

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

More Books

Students also viewed these Databases questions