The function below is


Matlab Problems

1. The function below is broken.

  • It does not always correctly report a zero at an endpoint of the supplied bracketing interval [a, b].
  • Something is wrong with the implementation of the Bisection Algorithm
  • It should return the midpoint of the last bracket after exiting the while loop.

Submit a printout of the corrected function.

Also use the diary command to capture the output of the following test code on the Matlab command

line and submit that as well.

----------------

>> f=inline('(x-1)*(x-2)')

>> BisectionMethod(f,3,3,0.01,10)

>> BisectionMethod(f,1.5,2,0.01,10)

>> BisectionMethod(f,1,3,0.01,10)

>> BisectionMethod(f,1.5,3,0.01,10)

>> BisectionMethod(f,1.5,3,0.001,10)

>> BisectionMethod(f,1.5,3,0.001,100)

2259_Matlab Function.jpg

2. Below is a function that implements Newton's Method. Modify it so it instead implements the secant method (without calling another function ). Don't forget to rename it and modify the comments below the function name. Submit your function typed. Recommendtesting it before submit it. However, output is not requested.

function x = NewtonsMethod(f,fp,x0,N)
%Required parameters: a function f, its derivative fp, a starting point
%and the number of iterations to perform.
xcurrent=x0;
for i=1:N
xnew=xcurrent-feval(f,xcurrent)/feval(fp,xcurrent);
xcurrent=xnew;
end
x=xcurrent;
end

Solution Preview :

Prepared by a verified Expert
Mathematics: The function below is
Reference No:- TGS01120716

Now Priced at $20 (50% Discount)

Recommended (94%)

Rated (4.6/5)