Advertisement
SilLAwNeD

Scilab, newton function

Nov 15th, 2018
1,581
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 0.38 KB | None | 0 0
  1. function [x, k] = newton(foncjac, tol, N, x0)
  2.     dx = 0;
  3.     x = x0;
  4.     [F0,J0] = foncjac(x0)
  5.     nF0 = norm(F0)
  6.    
  7.     for k = 1:N
  8.         [F , J] = foncjac(x)
  9.         h = -J \ F;
  10.         x = x + h;
  11.         dx = norm(F) / nF0;
  12.         if dx < tol then
  13.             return [x, k];
  14.         end
  15.     end
  16.    
  17.     error("Pas de convergence en N itérations.")
  18.  
  19. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement