Question: (a) Develop an M-file function to implement Brents root-location method. Base your function on Fig. 6.10, but with the beginning of the function changed to
(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


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
![]()
Example 5.6

function b= fzerosimp (x1, xu) a = x1; b = xu; fa = f(a); fb = f(b); c = a; fc = fa; d = b = c; e = d; while (1) if fb == 0, break, end if sign (fa) == sign (fb) If needed, rearrange points a = c; fa = fc; d = b = c; e = d; end if abs (fa) < abs (fb) c = b; b = a; a = c; fc = fb; fb = fa; fa = fc; end m = 0.5* (a - b); Termination test and possible exit tol = 2 * eps if abs (m) = tol & abs (fc) > abs (fb) 8 = fb/fc; if a == c P = 2*m*s; q = 1 - s; else end q= fc/fa; r = fb/fa; P = 8 * (2*m*q q end else max (abs (b), 1); end else end if p > 0, q = -q; else p = -p; end; if 2*p < 3*m*q - abs (tol*q) & p < aba (0.5*e*g) e = d; d = p/q; d = m; e = m; d = m; e = m; *Secant method *Inverse quadratic interpolation (q 1) (r - 1) (8 - 1); (qr) (b- c) * (x - 1)); Bisection c = b; fc = fb; if abs (d) > tol, b=b+d; else b-b-sign (b-a) *tol; end fb = f(b);
Step by Step Solution
3.42 Rating (161 Votes )
There are 3 Steps involved in it
To implement Brents rootlocation method in an Mfile function and test it as described well start by reworking the skeleton provided in the images The ... View full answer
Get step-by-step solutions from verified subject matter experts
