Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.50 KB | None | 0 0
  1. function [i, x]=nuton(x0, f, J)
  2.    N=100, eps=0.00001, maxval=10000.0, i=0
  3.    while (N>0)
  4.    JJ=J(x0),
  5.    if(abs(det(JJ))<eps) then error('try new x0'),
  6.    abort,
  7.    end;
  8.    xn=x0-inv(JJ)*f(x0),
  9.    if(abs(f(xn))<eps) then x=xn,
  10.    return,
  11.    end;
  12.    if(abs(f(x0))>maxval) then disp(100-N),
  13.    error('sol div'), abort,
  14.    end;
  15.    N=N-1, x0=xn, i=i+1,
  16.    end;
  17.    error('no conv'), abort;
  18.  endfunction
  19.  
  20. Матрица Якоби:
  21.  
  22. function [J]=jacob(x)
  23.   J=numderivative(ValEq,x)
  24. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement