(a) Develop an M-file function to implement Brent's root-location method. Base your function on Fig. 6.10, but with the beginning of the function changed to
function [b,fb] = fzeronew(f,xl,xu,varargin)% fzeronew: Brent root location zeroes% [b,fb] = fzeronew(f,xl,xu,p1,p2,...):% uses Brent's method to find the root of f% input:% f = name of function% xl, xu = lower and upper guesses% p1,p2,... = additional parameters used by f% output:% b = real root% fb = function value at root
Make the appropriate modifications so that the function performs as outlined in the documentation statements. In addition, include error traps to ensure that the function's three required arguments (f, xl, xu) are prescribed, and that the initial guesses bracket a root.
(b) Test your function by using it to solve for the root of the function from Example 5.6 using
>> [x, fx] = fzeronew(@(x, n) x^n-1,0,1.3,10)
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.