function [] = chap_6_sec_6_prob_2() % % % Written by: % -- % John L. Weatherwax 2007-04-23 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; clc; % perform all iterations (and tabulate chain links): % N_INFTY = 15; % assign the initial conditions for our two by two example % and our phi function iterations % x0 = 10; y0 = 10; t0 = 0; % the "N" matrix (needed for the iterations): % N = (1/12000)*[ 310 -20 ; 290 20 ]; % plot the iterates: % fi=figure; plot( x0, y0, 'b.', 'MarkerSize', 15 ); hold on; grid on; %figure(fi); plot( x0, y0, 'gs', 'MarkerSize', 15 ); hold on; grid on; title( 'the iterates' ); % Iterate each scheme: % xn=x0; yn=y0; tn=t0; errs=zeros(N_INFTY,2); %fprintf(''); fprintf('ii=%3d: K=(%12.6f,%12.6f,%16s) T=(%12.6f,%16s)\n',0,xn,yn,'',tn,''); for ii=1:N_INFTY, % iterate our modified Newton-Raphson method: fvn = [ xn^2 + yn^2 - 200; yn^3 + xn*yn - xn^3 ]; nTmsf = N * fvn; xnp1 = xn - nTmsf(1); ynp1 = yn - nTmsf(2); %[ xnp1, ynp1 ] %[ xn-xnp1, yn-ynp1 ] errs(ii,1) = norm( [ xn-xnp1, yn-ynp1 ] ); xn=xnp1; yn=ynp1; figure(fi); plot( xn, yn, 'x', 'MarkerSize', 10, 'MarkerEdgeColor', [ 0 1 0 ], 'MarkerFaceColor', [ 0 1 0 ] ); % iterate our phi function: tnp1 = 1/6 + (tn^2)/6 + (tn^3)/300; errs(ii,2) = norm( [ tn - tnp1 ] ); tn=tnp1; fprintf('ii=%3d: K=(%12.6f,%12.6f,%16.6g) T=(%12.6f,%16.6g)\n',ii,... xn,yn,errs(ii,1),tn,errs(ii,2)); %pause; end % plot the error observing the various convergence: % figure; semilogy( errs+eps, 'o' ); grid on; legend( gca, 'Mod Newton', 'Phi' ); %saveas( gcf, '../WriteUp/Pictures/chap_6_sec_6_prob_2_conv.eps' );