SHARE
TWEET

Scilab, newton function

SilLAwNeD Nov 15th, 2018 123 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top