Hi all, I have built a code for modified secant method to find the root of the function f(x)= which is given below. The output of the code should give an answer of about 0.5671 but instead it is giving 56.71…. something answer. HOw to solve this problem? Code is mentioned below:
clear allclose allclcn=100;f=@(x) exp(-x)-x;dx=0.01;x0=1;x(1)=x0;i=0;err=0.0048;for i=1:n x(i+1)=x(i)-((f(x(i)*dx)/(f(x(i)+dx)-f(x(i))))); if abs((x(i+1)-x(i))/x(i+1))*100<err roots=x(i); break; endenddisp(roots)
Best Answer