2x22x32 14 x12 2x22 9 x1 3x22 x32x the vector function the matrix of partial

2x22x32 14 x12 2x22 9 x1 3x22 x32x the vector

This preview shows page 7 - 13 out of 18 pages.

f = inline('[x(1).^2+x(2).^2+x(3).^2 - 14 ;x(1).^2 + 2*x(2).^2 - 9; x(1) - 3*x(2).^2 + x(3).^2]','x'); % the vector function % the matrix of partial derivatives Df = inline('[2*x(1), 2*x(2), 2*x(3) ; 2*x(1),4*x(2),0;1,-6*x(2), 2*x(3)]','x'); disp('Solution by Multi-dimensional Newton-Raphson Method:'); x = [1;1;1]; % starting guess disp(['Initial Guess Values are',num2str(x')]); xold = x; ei = [0;0;0]; for i = 1:n Dx = -Df(x)\f(x); % solve for increment x = x + Dx; % add on to get new guess for j=1:size(x) ei(j)=abs((x(j)-xold(j))/x(j))*100; end xold = x; disp(['Iteration number = ',num2str(i)]); disp(' x_1 x_2 x_3'); disp(x'); disp(' Ex_1 Ex_2 Ex_3'); disp(ei'); end
Image of page 7
28 January 2019 8 ME262 Numerical Analysis Sessional Systems of Nonlinear Equations disp(['Iteration number = ',num2str(i)]); disp(' x_1 x_2 x_3'); disp(x'); disp(' Ex_1 Ex_2 Ex_3'); disp(ei'); end
Image of page 8