function [] = chap_6_sec_6_prob_3() % % % 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 = 0; y0 = 0; t0 = 0; % the negative "M^{-1}" matrix (needed for the iterations): % mInv = (1/1000)*[ 28 9 ; 4 37 ]; % 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; t1n=t0; t2n=t0; errs=zeros(N_INFTY,3); %fprintf(''); fprintf('ii=%3d: K=(%12.6f,%12.6f,%16s) T1=(%12.6f,%16s) T2=(%12.6f,%16s)\n',0,xn,yn,'',t1n,'',t2n,''); for ii=1:N_INFTY, % iterate our modified Newton-Raphson method: fvn = [ xn^5 + yn^5 + 25; (xn^3)*(yn^3) + 18 ]; nTmsf = mInv * fvn; xnp1 = nTmsf(1); ynp1 = 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 first phi function: t1np1 = 0.862 + (280/5000)*(t1n^5) + (222/6000)*(t1n^6); errs(ii,2) = norm( [ t1n - t1np1 ] ); t1n=t1np1; % iterate our second phi function: t2np1 = 0.862 + (280/5000)*(t2n^5) + (54/6000)*(t2n^6); errs(ii,3) = norm( [ t2n - t2np1 ] ); t2n=t2np1; fprintf('ii=%3d: K=(%12.6f,%12.6f,%16.6g) T1=(%12.6f,%16.6g) T2=(%12.6f,%16.6g)\n',ii,... xn,yn,errs(ii,1),t1n,errs(ii,2),t2n,errs(ii,3)); %pause; end % plot the error observing the various convergence: % figure; semilogy( errs+eps, 'o' ); grid on; legend( gca, 'Mod Newton', 'Phi fn 1', 'Phi fn 2' ); %saveas( gcf, '../WriteUp/Pictures/chap_6_sec_6_prob_2_conv.eps' );