%use these values
c1=.5
c2=1/4
c3=-1/2
c4=-1
F(1,1)=x(1)^2-x(2)+c1;
F(2,1)=x(2)^2-x(1)+c1;
return
function J= jacobi(x)
%Jacobian is the derivative of each term of the matrix
J(1,1)=2*x(1);
J(1,2)=2;
J(2,1)=-1;
J(2,2)=2*x(2);
return
function[x,F,Counter]= mynewton(equation, jacobi, g,tol,iter,varargin)
%function used to find zero
%input
: given
system of equations
%counter returns the number of of turns
counter=0;
error =tol +1;
x=G;
while error >=tol & counter < iter
J=faval(equation, x, varargin{:});
delta=-j\f;
x=x+delta;
error=norm(delta);
counter=counter+1 ;
end
if (counter==iter &error>tol)
fprintf(['fails to converge within max number of turns','.'the returned has relative residual
% of e
']'F
);
else
fprint (['the method onverges at iteration','%i'],counter);
end
return
JXVzZSB0aGVzZSB2YWx1ZXMKYzE9LjUKYzI9MS80CmMzPS0xLzIKYzQ9LTEKCiUgc3lzdGVtIG9mIGVxdWF0aW9ucwpGKDEsMSk9eCgxKV4yLXgoMikrYzE7CkYoMiwxKT14KDIpXjIteCgxKStjMTsKCnJldHVybgoKCmZ1bmN0aW9uIEo9IGphY29iaSh4KQolSmFjb2JpYW4gaXMgdGhlIGRlcml2YXRpdmUgb2YgZWFjaCB0ZXJtIG9mIHRoZSBtYXRyaXgKSigxLDEpPTIqeCgxKTsgCkooMSwyKT0yOwpKKDIsMSk9LTE7CkooMiwyKT0yKngoMik7CgpyZXR1cm4KCmZ1bmN0aW9uW3gsRixDb3VudGVyXT0gbXluZXd0b24oZXF1YXRpb24sIGphY29iaSwgZyx0b2wsaXRlcix2YXJhcmdpbikKJWZ1bmN0aW9uIHVzZWQgdG8gZmluZCB6ZXJvCiVpbnB1dDogZ2l2ZW4gc3lzdGVtIG9mIGVxdWF0aW9ucwolY291bnRlciByZXR1cm5zIHRoZSBudW1iZXIgb2Ygb2YgdHVybnMKY291bnRlcj0wOwplcnJvciA9dG9sICsxOwp4PUc7Cgp3aGlsZSBlcnJvciA+PXRvbCAmIGNvd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