Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [i, x]=nuton(x0, f, J)
- N=100, eps=0.00001, maxval=10000.0, i=0
- while (N>0)
- JJ=J(x0),
- if(abs(det(JJ))<eps) then error('try new x0'),
- abort,
- end;
- xn=x0-inv(JJ)*f(x0),
- if(abs(f(xn))<eps) then x=xn,
- return,
- end;
- if(abs(f(x0))>maxval) then disp(100-N),
- error('sol div'), abort,
- end;
- N=N-1, x0=xn, i=i+1,
- end;
- error('no conv'), abort;
- endfunction
- Матрица Якоби:
- function [J]=jacob(x)
- J=numderivative(ValEq,x)
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement