Using the newtmultm MATLAB function determine the solution o
Using the newtmult.m MATLAB function, determine the solution of the simultaneous nonlinear equations:
Use initial guesses x1=1.5, x2=1.5
x1^2 = 5 – x2^2
x2^2 + 1 = x1^2
Solution
matlab function:
[x,f,ea,iter]=newtmult(func,x0,es,maxit,p1,p2,...):
 % uses the Newton-Raphson method to find the roots of
 % a system of nonlinear equations
 % input:
 % func = name of function that returns f and J
 % x0 = initial guess
 % es = desired percent relative error (default = 0.0001%)
 % maxit = maximum allowable iterations (default = 50)
 % p1,p2,... = additional parameters used by function
 % output:
 % x = vector of roots
 % f = vector of functions evaluated at roots
 % ea = approximate percent relative error (%)
 % iter = number of iterations
if nargin<2,error(\'at least 2 input arguments required\'),end
 if nargin<3|isempty(es),es=0.0001;end
 if nargin<4|isempty(maxit),maxit=50;end
 iter = 0;
 x=x0;
 while (1)
 [J,f]=func(x,varargin{:});
 dx=J\\f;
 x=x-dx;
 iter = iter + 1;
 ea=100*max(abs(dx./x));
 if iter>=maxit|ea<=es, break, end
 end

