Hi, I'm trying to solve an nonlinear system with Newton's method.

I was trying to do this by my-self but since my code doens't work I looked around for a code and I found this one.

I'm new in matlab and maybe understanding this code is easier I can imagine, but actually I can't get what is written here:

`function [x, nit] = newtonsys(F, J, x0, toll, nmax, p)[n,m]=size(F);nit=0;Fxn=zeros(n,1);x=x0;err=toll+1;for i=1:n, for j=1:n, Jxn(i,j)=eval(J((i-1)*n+j,:)); end; end[L,U,P]=lu(Jxn); step=0;while err>toll if step == p step = 0; for i=1:n; Fxn(i)=eval(F(i,:)); for j=1:n; Jxn(i,j)=eval(J((i-1)*n+j,:)); end end [L,U,P]=lu(Jxn); else for i=1:n, Fxn(i)=eval(F(i,:)); end end nit=nit+1; step=step+1; Fxn=-P*Fxn; y=forwardcol(L,Fxn);deltax=backwardcol(U,y);x=x+deltax; err=norm(deltax); if nit>nmax disp(’ Fails to converge within maximum number of iterations ’); break end end`

Doesn someone understand the idea in background? Can someone explain me what the code does? I neither understand why it uses "eval" function (I checked on matlab documentation but I can't understand this function here).

Thank you in advance

source: Numerical Mathematics (Alfio Quarteroni, Riccardo Sacco, Fausto Saleri)

## Best Answer