
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Solve the equations using the Secant method in MATLAB
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

f = @(x) x^3-7x^2+14x-6;
x0=3.2; x1=4; % x0,x1 initial approximations to location of root TOL=10^(-5); % absolute error convergence tolerance Nmax=100;% maximum number of iterations to be performed
flag=0; older = x0; old = x1; folder = feval(f,older);
for i = 2 : Nmax fold = feval(f,old); dx = fold * ( old - older ) / ( fold - folder ); new = old - dx;
fprintf('\t\t %3d \t %.15f \n' , i, new )
if ( abs(dx) < TOL ) flag=1; break else older = old; old = new; folder = fold; end
end
if flag == 0 disp('Maximum number of iterations exceeded' ) end 2 3. 3 3. 4 3. 5 3. 6 3. 7 3. 8 3. 9 3. 10 3. 11 3.