clear % x0 = input('enter the value of x0 = '); % x1 = input('enter the value of x1 = '); % tolerance=input('inter the tolerance = '); x0 = 0; x1 = 3; tolerance= 1.0e-17; % f =@(x) sin(2*pi*x)+ exp(1.2*x) + x - 2.5; f =@(x) 2-(x-2)^2; result = zeros(20,3); for i=2:10 x2= x1 - (f(x1)* (x1-x0)/(f(x1)-f(x0))) ; c = f(x2); [i x2 c] result(i,1) = i; result(i,2) = x2; result(i,3) = c; absolute_c= abs(c); if absolute_c < tolerance break end if f(x0)*c <0 x1=x2; continue else x0=x2; continue end end