Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a matlab program to implement the secant root finding method in matlab. Th

ID: 3690347 • Letter: W

Question

Write a matlab program to implement the secant root finding method in matlab.

The function name should be Secant and it should take the equation as input whoes root has to be found and the two initial values of a and b and maximum tolerable error.

Consider the following example:

Your code should generate the following:

>> secantAssg5(@(x)(x^4+x^2+x+10),2,3,0.0001)

   Xn-1      f(Xn-1)      Xn      f(Xn)      Xn+1      f(Xn+1)

2.0000   32.0000    3.0000 103.0000    1.5493   19.7111

…..

…..

…..

Root is x = 0.13952

ans =

    0.1395

Explanation / Answer

PFB the MATLAB code function y = secant(f,a,b,maxerr) c = (a*f(b) - b*f(a))/(f(b) - f(a)); disp(' Xn-1 f(Xn-1) Xn f(Xn) Xn+1 f(Xn+1)'); disp([a f(a) b f(b) c f(c)]); while abs(f(c)) > maxerr a = b; b = c; c = (a*f(b) - b*f(a))/(f(b) - f(a)); disp([a f(a) b f(b) c f(c)]); flag = flag + 1; if(flag == 100) break; end end display(['Root is x = ' num2str(c)]); y = c;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote