clear all; close all; % This is the main code that calls bisection or secant % function, provided in the same directory, to % compute a zero r of the function f, which needs to be % available in the file f.m in the same directory. % The bisection and secant functions output the % sequence of approximations to the zero r, which is % then feeded into the function get_convergence_movie, % provided in the same directory, to generate an animation file % movie.avi, in the same directory. % bisection a=-2; b=1; n_max=100; bisection_tolerance=1e-5; [r,sequence_x,sequence_fx]=bisection('f',a,b,n_max,bisection_tolerance); % secant x_0=-pi/2-1; x_1=3*pi/2-1+1e-2; n_max=100; secant_tolerance=1e-14; %[r,sequence_x,sequence_fx]=secant('f',x_0,x_1,n_max,secant_tolerance); nframes = 10; %number of movie frames. 10 frames produce ~10Mb 640x480 movie.avi file get_convergence_movie('f',sequence_x,sequence_fx,nframes)