% HW 4 Problem 1 - SAMPLE CODE
%
% Driver for Mueller's method
% 
% YOUR NAME

tol = 1e-5;
maxit = 20;
format long

fprintf(' --- B&F 2.6.3  d --- \n');
p = [1 0 2 -1 -3];

fprintf('%6s %6s %6s %8s %13s\n','z0','z1','z2','iterations','root');

z0=0; z1=1; z2=2; 
[z,k]=muller(z0,z1,z2,p,maxit,tol);
fprintf('%6.2f %6.2f %6.2f %8d %13.8f + %13.8fi\n',z0,z1,z2,k,real(z),imag(z));

z0=2; z1=3; z2=4; 
[z,k]=muller(z0,z1,z2,p,maxit,tol);
fprintf('%6.2f %6.2f %6.2f %8d %13.8f + %13.8fi\n',z0,z1,z2,k,real(z),imag(z));

z0=-2; z1=0; z2=-1; 
[z,k]=muller(z0,z1,z2,p,maxit,tol);
fprintf('%6.2f %6.2f %6.2f %8d %13.8f + %13.8fi\n',z0,z1,z2,k,real(z),imag(z));

fprintf('the remaining root is conjugate of the previous one\n');


% Here is some sample output from this problem. The roots command
% is to double check our computations.
% 
%   >> prob1_sample
%    --- B&F 2.6.3  d --- 
%       z0     z1     z2 iterations          root
%     0.00   1.00   2.00        4    1.12412303 +    0.00000000i
%     2.00   3.00   4.00       11   -0.12403496 +   -1.74096108i
%    -2.00   0.00  -1.00        4   -0.87605312 +    0.00000000i
%   the remaining root is conjugate of the previous one
%   >> roots(p)
%   
%   ans =
%   
%    -0.124034956943601 + 1.740961083530082i
%    -0.124034956943601 - 1.740961083530082i
%     1.124123029704315                     
%    -0.876053115817114                     
%   

