Question: Please complete in MATLAB! Use this as base code: Modify provided code to calculate the root of a function according to the secant method. The

Please complete in MATLAB!

Please complete in MATLAB! Use this as base code: Modify provided code

Use this as base code: Modify provided code to calculate the root of a function according to the secant method. The calculations should be using the minimum number of function evaluations. The inputs should be % Newton-Raphson method for root location x0,x1,t, and the maximum number of iterations, n. The execution should be terminated when clear ; f=@(x)xtan(x)1.0; the error drops below the tolerance or when the maximum number of iterations is exceeded. In fp=@(x)tan(x)+(x/((cos(x))2)); the script file, report the root estimate using the fprintf command. Also, implement xr= input('Provide initial estimate xr: ') ; t= input('Provide tolerance t: ' ') ; consistency check [evaluation of f(xr)] n= input('Provide max number of iterations: ') ; plot the relative error vs iterations in semi-log format. Consider testing the script of the secant es =10(t);j=0;x=zeros(1,n);y=zeros(1,n); method for the function while 1 xr=xr(f(xr)/fp(xr));er=abs((xrxr)/xr); j=j+1;xr=xr;x(j)=j;y(j)=er; fprintf(,j=%dxr=%15.10f(n,j,xr); Use the script of the secant method to determine all real (positive and negative) roots of the if j>=n er

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!