% _________________________________________________________________________ % To get accurate root of given equation by Secant method % By Mahesha MG, MIT % Date: 09/04/2013 % _________________________________INPUT___________________________________ clc; clear; y = inline('x^2+x-2.5'); %Equation x0=input('Enter first approximate root: '); %Example: 3 x1=input('Enter second approximate root: '); %Example: 4 e=input('Enter the accuracy: '); %Example: 1e-5 % _____________________________Secant method_______________________________ while abs(feval(y,x1))>e x2=((x0*feval(y,x1))-(x1*feval(y,x0)))/(feval(y,x1)-feval(y,x0)); x0=x1; x1=x2; end % _________________________________________________________________________ root=x2